Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote branch 'mainstream/master'

Conflicts:
	activesupport/lib/active_support/core_ext/hash/conversions.rb
  • Loading branch information...
commit 5446d5cb05b50a9a3f317ded774be438e0eff909 2 parents 9754deb + f8877d4
@lifo lifo authored
Showing with 7,218 additions and 6,607 deletions.
  1. +2 −2 .gitignore
  2. +6 −0 .gitmodules
  3. +36 −0 Gemfile
  4. +2 −2 Rakefile
  5. +11 −10 actionmailer/Rakefile
  6. +2 −1  actionmailer/lib/action_mailer.rb
  7. +86 −229 actionmailer/lib/action_mailer/base.rb
  8. +57 −0 actionmailer/lib/action_mailer/delivery_method.rb
  9. +21 −0 actionmailer/lib/action_mailer/delivery_method/file.rb
  10. +22 −0 actionmailer/lib/action_mailer/delivery_method/sendmail.rb
  11. +31 −0 actionmailer/lib/action_mailer/delivery_method/smtp.rb
  12. +12 −0 actionmailer/lib/action_mailer/delivery_method/test.rb
  13. +44 −0 actionmailer/lib/action_mailer/deprecated_body.rb
  14. +0 −114 actionmailer/lib/action_mailer/helpers.rb
  15. +2 −0  actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/parser.rb
  16. +13 −3 actionmailer/test/abstract_unit.rb
  17. +32 −4 actionmailer/test/delivery_method_test.rb
  18. +11 −10 actionmailer/test/mail_helper_test.rb
  19. +6 −2 actionmailer/test/mail_layout_test.rb
  20. +23 −3 actionmailer/test/mail_render_test.rb
  21. +94 −62 actionmailer/test/mail_service_test.rb
  22. +4 −2 actionmailer/test/test_helper_test.rb
  23. +23 −21 actionmailer/test/url_test.rb
  24. +0 −15 actionpack/Gemfile
  25. +5 −17 actionpack/Rakefile
  26. +4 −2 actionpack/actionpack.gemspec
  27. +1 −0  actionpack/lib/abstract_controller.rb
  28. +4 −6 actionpack/lib/abstract_controller/callbacks.rb
  29. +70 −11 actionpack/lib/abstract_controller/helpers.rb
  30. +42 −11 actionpack/lib/abstract_controller/layouts.rb
  31. +49 −0 actionpack/lib/abstract_controller/localized_cache.rb
  32. +5 −19 actionpack/lib/abstract_controller/logger.rb
  33. +23 −2 actionpack/lib/abstract_controller/rendering_controller.rb
  34. +6 −8 actionpack/lib/action_controller.rb
  35. +1 −0  actionpack/lib/action_controller/base.rb
  36. +36 −25 actionpack/lib/action_controller/caching.rb
  37. +99 −114 actionpack/lib/action_controller/caching/actions.rb
  38. +7 −19 actionpack/lib/action_controller/caching/fragments.rb
  39. +2 −8 actionpack/lib/action_controller/caching/pages.rb
  40. +1 −1  actionpack/lib/action_controller/caching/sweeping.rb
  41. +2 −0  actionpack/lib/action_controller/deprecated.rb
  42. +1 −1  actionpack/lib/action_controller/dispatch/dispatcher.rb
  43. +0 −256 actionpack/lib/action_controller/legacy/layout.rb
  44. +7 −3 actionpack/lib/action_controller/metal.rb
  45. +2 −21 actionpack/lib/action_controller/metal/benchmarking.rb
  46. +5 −3 actionpack/lib/action_controller/metal/compatibility.rb
  47. +4 −37 actionpack/lib/action_controller/metal/conditional_get.rb
  48. +28 −0 actionpack/lib/action_controller/metal/configuration.rb
  49. +29 −18 actionpack/lib/action_controller/metal/cookies.rb
  50. +23 −42 actionpack/lib/action_controller/metal/filter_parameter_logging.rb
  51. +23 −25 actionpack/lib/action_controller/metal/flash.rb
  52. +27 −0 actionpack/lib/action_controller/metal/head.rb
  53. +5 −66 actionpack/lib/action_controller/metal/helpers.rb
  54. +0 −21 actionpack/lib/action_controller/metal/layouts.rb
  55. +3 −6 actionpack/lib/action_controller/metal/mime_responds.rb
  56. +1 −1  actionpack/lib/action_controller/metal/rack_convenience.rb
  57. +1 −1  actionpack/lib/action_controller/metal/redirector.rb
  58. +9 −55 actionpack/lib/action_controller/metal/rendering_controller.rb
  59. +23 −33 actionpack/lib/action_controller/metal/request_forgery_protection.rb
  60. +28 −18 actionpack/lib/action_controller/metal/responder.rb
  61. +3 −12 actionpack/lib/action_controller/metal/session_management.rb
  62. +0 −2  actionpack/lib/action_controller/metal/streaming.rb
  63. +2 −2 actionpack/lib/action_controller/metal/verification.rb
  64. +20 −20 actionpack/lib/action_controller/middleware.rb
  65. +10 −0 actionpack/lib/action_controller/notifications.rb
  66. +7 −34 actionpack/lib/action_controller/{routing/generation → }/polymorphic_routes.rb
  67. +0 −199 actionpack/lib/action_controller/routing/builder.rb
  68. +0 −130 actionpack/lib/action_controller/routing/optimisations.rb
  69. +0 −167 actionpack/lib/action_controller/routing/recognition_optimisation.rb
  70. +0 −685 actionpack/lib/action_controller/routing/resources.rb
  71. +0 −267 actionpack/lib/action_controller/routing/route.rb
  72. +0 −4 actionpack/lib/action_controller/routing/routing_ext.rb
  73. +0 −343 actionpack/lib/action_controller/routing/segments.rb
  74. +1 −1  actionpack/lib/action_controller/testing/process.rb
  75. +8 −1 actionpack/lib/action_controller/testing/test_case.rb
  76. +2 −2 actionpack/lib/action_controller/translation.rb
  77. 0  actionpack/lib/action_controller/{routing/generation → }/url_rewriter.rb
  78. +2 −0  actionpack/lib/action_dispatch.rb
  79. +1 −0  actionpack/lib/action_dispatch/http/mime_type.rb
  80. +16 −19 actionpack/lib/action_dispatch/http/request.rb
  81. +2 −0  actionpack/lib/action_dispatch/http/response.rb
  82. +4 −4 actionpack/lib/action_dispatch/middleware/callbacks.rb
  83. +4 −2 actionpack/lib/action_dispatch/middleware/stack.rb
  84. +11 −19 actionpack/lib/{action_controller → action_dispatch}/routing.rb
  85. +878 −0 actionpack/lib/action_dispatch/routing/deprecated_mapper.rb
  86. +327 −0 actionpack/lib/action_dispatch/routing/mapper.rb
  87. +49 −0 actionpack/lib/action_dispatch/routing/route.rb
  88. +175 −163 actionpack/lib/{action_controller → action_dispatch}/routing/route_set.rb
  89. +16 −3 actionpack/lib/action_dispatch/testing/assertions.rb
  90. +7 −3 actionpack/lib/action_dispatch/testing/integration.rb
  91. +25 −11 actionpack/lib/action_view/base.rb
  92. +1 −0  actionpack/lib/action_view/erb/util.rb
  93. +4 −2 actionpack/lib/action_view/helpers.rb
  94. +16 −12 actionpack/lib/action_view/helpers/active_model_helper.rb
  95. +16 −12 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  96. +0 −54 actionpack/lib/action_view/helpers/benchmark_helper.rb
  97. +11 −2 actionpack/lib/action_view/helpers/form_helper.rb
  98. +1 −1  actionpack/lib/action_view/helpers/translation_helper.rb
  99. +2 −2 actionpack/lib/action_view/helpers/url_helper.rb
  100. +2 −2 actionpack/lib/action_view/locale/en.yml
  101. +3 −6 actionpack/lib/action_view/render/rendering.rb
  102. +1 −1  actionpack/lib/action_view/safe_buffer.rb
  103. +8 −3 actionpack/lib/action_view/template/handlers/erb.rb
  104. +1 −1  actionpack/lib/action_view/template/resolver.rb
  105. +2 −2 actionpack/lib/action_view/template/template.rb
  106. +5 −3 actionpack/lib/action_view/template/text.rb
  107. +1 −0  actionpack/lib/action_view/test_case.rb
  108. +51 −14 actionpack/test/abstract/helper_test.rb
  109. +42 −13 actionpack/test/abstract/layouts_test.rb
  110. +57 −0 actionpack/test/abstract/localized_cache_test.rb
  111. +88 −0 actionpack/test/abstract/render_test.rb
  112. +32 −14 actionpack/test/abstract_unit.rb
  113. +6 −8 actionpack/test/activerecord/polymorphic_routes_test.rb
  114. +12 −12 actionpack/test/controller/base_test.rb
  115. +17 −16 actionpack/test/controller/caching_test.rb
  116. +11 −5 actionpack/test/controller/cookie_test.rb
  117. +9 −9 actionpack/test/controller/filter_params_test.rb
  118. +0 −1  actionpack/test/controller/filters_test.rb
  119. +6 −40 actionpack/test/controller/helper_test.rb
  120. +19 −1 actionpack/test/controller/integration_test.rb
  121. +28 −0 actionpack/test/controller/mime_responds_test.rb
  122. +1 −1  actionpack/test/controller/new_base/content_negotiation_test.rb
  123. +2 −2 actionpack/test/controller/new_base/metal_test.rb
  124. +1 −1  actionpack/test/controller/new_base/render_action_test.rb
  125. +11 −1 actionpack/test/controller/render_test.rb
  126. +4 −4 actionpack/test/controller/rescue_test.rb
  127. +11 −11 actionpack/test/controller/resources_test.rb
  128. +460 −277 actionpack/test/controller/routing_test.rb
  129. +17 −0 actionpack/test/controller/test_test.rb
  130. +8 −10 actionpack/test/controller/url_rewriter_test.rb
  131. +2 −2 actionpack/test/controller/verification_test.rb
  132. +1 −1  actionpack/test/dispatch/request/json_params_parsing_test.rb
  133. +2 −2 actionpack/test/dispatch/request/query_string_parsing_test.rb
  134. +1 −1  actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
  135. +2 −2 actionpack/test/dispatch/request/xml_params_parsing_test.rb
  136. +4 −0 actionpack/test/dispatch/request_test.rb
  137. +391 −0 actionpack/test/dispatch/routing_test.rb
  138. +1 −1  actionpack/test/dispatch/session/cookie_store_test.rb
  139. +1 −1  actionpack/test/dispatch/session/mem_cache_store_test.rb
  140. +2 −2 actionpack/test/dispatch/session/test_session_test.rb
  141. +2 −2 actionpack/test/dispatch/test_request_test.rb
  142. +1 −1  actionpack/test/fixtures/layouts/block_with_layout.erb
  143. +6 −1 actionpack/test/lib/controller/fake_controllers.rb
  144. +42 −0 actionpack/test/template/active_model_helper_i18n_test.rb
  145. +1 −1  actionpack/test/template/{active_record_helper_test.rb → active_model_helper_test.rb}
  146. +0 −51 actionpack/test/template/active_record_helper_i18n_test.rb
  147. +10 −0 actionpack/test/template/asset_tag_helper_test.rb
  148. +55 −11 actionpack/test/template/form_helper_test.rb
  149. +3 −0  actionpack/test/template/form_tag_helper_test.rb
  150. +1 −1  actionpack/test/template/number_helper_test.rb
  151. +1 −1  actionpack/test/{view → template}/safe_buffer_test.rb
  152. +9 −4 actionpack/test/template/test_case_test.rb
  153. +1 −2  actionpack/test/template/test_test.rb
  154. +32 −7 actionpack/test/template/url_helper_test.rb
  155. +2 −2 actionpack/test/ts_isolated.rb
  156. +16 −15 activemodel/Rakefile
  157. +2 −0  activemodel/lib/active_model.rb
  158. +9 −10 activemodel/lib/active_model/errors.rb
  159. +5 −4 activemodel/lib/active_model/naming.rb
  160. +64 −0 activemodel/lib/active_model/translation.rb
  161. +5 −6 activemodel/lib/active_model/validations.rb
  162. +9 −9 {activerecord/lib/active_record → activemodel/lib/active_model}/validator.rb
  163. +9 −3 activemodel/test/cases/helper.rb
  164. +1 −1  activemodel/test/cases/naming_test.rb
  165. +51 −0 activemodel/test/cases/translation_test.rb
  166. +0 −1  activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
  167. +8 −0 activemodel/test/cases/validations/i18n_validation_test.rb
  168. +4 −4 activemodel/test/cases/validations/with_validation_test.rb
  169. +7 −7 activerecord/Rakefile
  170. +1 −0  activerecord/activerecord.gemspec
  171. +24 −8 activerecord/lib/active_record.rb
  172. +12 −8 activerecord/lib/active_record/association_preload.rb
  173. +156 −214 activerecord/lib/active_record/associations.rb
  174. +1 −1  activerecord/lib/active_record/associations/association_collection.rb
  175. +10 −13 activerecord/lib/active_record/associations/association_proxy.rb
  176. +2 −2 activerecord/lib/active_record/associations/belongs_to_association.rb
  177. +10 −12 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  178. +9 −9 activerecord/lib/active_record/associations/has_many_association.rb
  179. +1 −1  activerecord/lib/active_record/associations/has_many_through_association.rb
  180. +1 −1  activerecord/lib/active_record/associations/through_association_scope.rb
  181. +3 −4 activerecord/lib/active_record/attribute_methods.rb
  182. +3 −10 activerecord/lib/active_record/attribute_methods/before_type_cast.rb
  183. +0 −2  activerecord/lib/active_record/attribute_methods/dirty.rb
  184. +3 −17 activerecord/lib/active_record/attribute_methods/query.rb
  185. +4 −45 activerecord/lib/active_record/attribute_methods/read.rb
  186. +10 −38 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
  187. +2 −7 activerecord/lib/active_record/attribute_methods/write.rb
  188. +37 −0 activerecord/lib/active_record/attributes.rb
  189. +42 −0 activerecord/lib/active_record/attributes/aliasing.rb
  190. +15 −0 activerecord/lib/active_record/attributes/store.rb
  191. +117 −0 activerecord/lib/active_record/attributes/typecasting.rb
  192. +189 −234 activerecord/lib/active_record/base.rb
  193. +87 −116 activerecord/lib/active_record/calculations.rb
  194. +2 −2 activerecord/lib/active_record/callbacks.rb
  195. +8 −6 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  196. +4 −31 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  197. +0 −6 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  198. +5 −11 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  199. +2 −13 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  200. +1 −14 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  201. +8 −7 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  202. +15 −12 activerecord/lib/active_record/locking/optimistic.rb
  203. +28 −31 activerecord/lib/active_record/migration.rb
  204. +2 −0  activerecord/lib/active_record/nested_attributes.rb
  205. +5 −0 activerecord/lib/active_record/notifications.rb
  206. +127 −0 activerecord/lib/active_record/relation.rb
  207. +38 −0 activerecord/lib/active_record/types.rb
  208. +30 −0 activerecord/lib/active_record/types/number.rb
  209. +37 −0 activerecord/lib/active_record/types/object.rb
  210. +33 −0 activerecord/lib/active_record/types/serialize.rb
  211. +20 −0 activerecord/lib/active_record/types/time_with_zone.rb
  212. +37 −0 activerecord/lib/active_record/types/unknown.rb
  213. +1 −92 activerecord/lib/active_record/validations.rb
  214. +0 −12 activerecord/test/cases/adapter_test.rb
  215. +1 −1  activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  216. +0 −2  activerecord/test/cases/associations/eager_load_nested_include_test.rb
  217. +5 −5 activerecord/test/cases/associations/eager_test.rb
  218. +4 −4 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  219. +12 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  220. +1 −1  activerecord/test/cases/associations/inner_join_association_test.rb
  221. +0 −19 activerecord/test/cases/associations_test.rb
  222. +20 −0 activerecord/test/cases/attributes/aliasing_test.rb
  223. +120 −0 activerecord/test/cases/attributes/typecasting_test.rb
  224. +6 −6 activerecord/test/cases/base_test.rb
  225. +1 −1  activerecord/test/cases/calculations_test.rb
  226. +2 −2 activerecord/test/cases/copy_table_test_sqlite.rb
  227. +2 −2 activerecord/test/cases/finder_test.rb
  228. +9 −2 activerecord/test/cases/helper.rb
  229. +3 −3 activerecord/test/cases/i18n_test.rb
  230. +2 −2 activerecord/test/cases/inheritance_test.rb
  231. +8 −5 activerecord/test/cases/locking_test.rb
  232. +3 −3 activerecord/test/cases/method_scoping_test.rb
  233. +4 −4 activerecord/test/cases/named_scope_test.rb
  234. +20 −3 activerecord/test/cases/pooled_connections_test.rb
  235. +4 −4 activerecord/test/cases/reflection_test.rb
  236. +150 −0 activerecord/test/cases/relations_test.rb
  237. +30 −0 activerecord/test/cases/types/number_test.rb
  238. +24 −0 activerecord/test/cases/types/object_test.rb
  239. +20 −0 activerecord/test/cases/types/serialize_test.rb
  240. +42 −0 activerecord/test/cases/types/time_with_zone_test.rb
  241. +29 −0 activerecord/test/cases/types/unknown_test.rb
  242. +32 −0 activerecord/test/cases/types_test.rb
  243. +9 −120 activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
  244. +0 −732 activerecord/test/cases/validations/i18n_validation_test.rb
  245. +0 −31 activerecord/test/cases/validations_test.rb
  246. +2 −0  activerecord/test/models/company.rb
  247. +1 −1  activerecord/test/models/pirate.rb
  248. +1 −1  activerecord/test/models/ship.rb
  249. +12 −13 activeresource/Rakefile
  250. +36 −16 activeresource/lib/active_resource/base.rb
  251. +84 −15 activeresource/lib/active_resource/connection.rb
  252. +11 −2 activeresource/test/abstract_unit.rb
  253. +146 −24 activeresource/test/cases/authorization_test.rb
  254. +0 −1  activeresource/test/cases/base/load_test.rb
  255. +6 −0 activeresource/test/cases/base_test.rb
  256. +15 −0 activeresource/test/connection_test.rb
  257. +4 −0 activesupport/CHANGELOG
  258. +20 −22 activesupport/Rakefile
  259. +4 −3 activesupport/lib/active_support/autoload.rb
  260. +59 −0 activesupport/lib/active_support/benchmarkable.rb
  261. +0 −1  activesupport/lib/active_support/buffered_logger.rb
  262. +23 −16 activesupport/lib/active_support/cache.rb
  263. +12 −4 activesupport/lib/active_support/cache/mem_cache_store.rb
  264. +450 −170 activesupport/lib/active_support/callbacks.rb
  265. +10 −6 activesupport/lib/active_support/concern.rb
  266. +0 −27 activesupport/lib/active_support/concurrent_hash.rb
  267. +35 −0 activesupport/lib/active_support/configurable.rb
  268. +0 −16 activesupport/lib/active_support/core_ext/array/conversions.rb
  269. +4 −9 activesupport/lib/active_support/core_ext/array/wrap.rb
  270. +0 −1  activesupport/lib/active_support/core_ext/boolean.rb
  271. +0 −11 activesupport/lib/active_support/core_ext/boolean/conversions.rb
  272. +39 −21 activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
  273. +17 −12 activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
  274. +0 −7 activesupport/lib/active_support/core_ext/date.rb
  275. +1 −0  activesupport/lib/active_support/core_ext/date/calculations.rb
  276. +0 −2  activesupport/lib/active_support/core_ext/date/conversions.rb
  277. +0 −5 activesupport/lib/active_support/core_ext/date_time.rb
  278. +1 −1  activesupport/lib/active_support/core_ext/date_time/calculations.rb
  279. +0 −9 activesupport/lib/active_support/core_ext/enumerable.rb
  280. +2 −18 activesupport/lib/active_support/core_ext/hash/conversions.rb
  281. +6 −0 activesupport/lib/active_support/core_ext/hash/slice.rb
  282. +1 −1  activesupport/lib/active_support/core_ext/integer.rb
  283. +0 −16 activesupport/lib/active_support/core_ext/integer/even_odd.rb
  284. +6 −0 activesupport/lib/active_support/core_ext/integer/multiple.rb
  285. +1 −0  activesupport/lib/active_support/core_ext/kernel/debugger.rb
  286. +3 −1 activesupport/lib/active_support/core_ext/name_error.rb
  287. +0 −1  activesupport/lib/active_support/core_ext/nil.rb
  288. +0 −5 activesupport/lib/active_support/core_ext/nil/conversions.rb
  289. +2 −16 activesupport/lib/active_support/core_ext/object/conversions.rb
  290. +7 −1 activesupport/lib/active_support/core_ext/object/duplicable.rb
  291. +0 −27 activesupport/lib/active_support/core_ext/object/extending.rb
  292. +0 −7 activesupport/lib/active_support/core_ext/object/instance_variables.rb
  293. +0 −1  activesupport/lib/active_support/core_ext/object/misc.rb
  294. +0 −16 activesupport/lib/active_support/core_ext/object/tap.rb
  295. +47 −0 activesupport/lib/active_support/core_ext/object/to_param.rb
  296. +27 −0 activesupport/lib/active_support/core_ext/object/to_query.rb
  297. +0 −22 activesupport/lib/active_support/core_ext/regexp.rb
  298. +0 −1  activesupport/lib/active_support/core_ext/string.rb
  299. +2 −0  activesupport/lib/active_support/core_ext/string/access.rb
  300. +0 −5 activesupport/lib/active_support/core_ext/string/bytesize.rb
Sorry, we could not display the entire diff because too many files (826) changed.
View
4 .gitignore
@@ -27,7 +27,7 @@ railties/guides/output
*.rbc
*.swp
*.swo
-actionpack/bin
+*.tmproj
+bin
vendor/gems/
-*/vendor/gems/
railties/tmp
View
6 .gitmodules
@@ -0,0 +1,6 @@
+[submodule "arel"]
+ path = arel
+ url = git://github.com/rails/arel.git
+[submodule "rack-mount"]
+ path = rack-mount
+ url = git://github.com/rails/rack-mount.git
View
36 Gemfile
@@ -0,0 +1,36 @@
+clear_sources
+source 'http://gemcutter.org'
+
+gem "rake", ">= 0.8.7"
+gem "mocha", ">= 0.9.8"
+
+gem "rails", "3.0.pre", :vendored_at => "railties"
+%w(activesupport activemodel actionpack actionmailer activerecord activeresource).each do |lib|
+ gem lib, '3.0.pre', :vendored_at => lib
+end
+
+# AR
+gem "arel", "0.2.pre", :git => "git://github.com/rails/arel.git"
+gem "sqlite3-ruby", ">= 1.2.5"
+gem "pg", ">= 0.8.0"
+gem "mysql", ">= 2.8.1"
+
+# AP
+gem "rack", "1.0.1", :git => "git://github.com/rails/rack.git"
+gem "rack-mount", :git => "git://github.com/rails/rack-mount.git"
+gem "RedCloth", ">= 4.2.2"
+
+if ENV['CI']
+ disable_system_gems
+
+ gem "nokogiri", ">= 1.4.0"
+ gem "memcache-client", ">= 1.7.6"
+
+ # fcgi gem doesn't compile on 1.9
+ # avoid minitest strangeness on 1.9
+ if RUBY_VERSION < '1.9.0'
+ gem "fcgi", ">= 0.8.7"
+ else
+ gem "test-unit", ">= 2.0.5"
+ end
+end
View
4 Rakefile
@@ -10,9 +10,9 @@ Dir["#{File.dirname(__FILE__)}/*/lib/*/version.rb"].each do |version_path|
end
desc 'Run all tests by default'
-task :default => :test
+task :default => %w(test test:isolated)
-%w(test isolated_test rdoc pgem package release gem gemspec).each do |task_name|
+%w(test test:isolated rdoc pgem package release gem gemspec).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
errors = []
View
21 actionmailer/Rakefile
@@ -24,14 +24,16 @@ Rake::TestTask.new { |t|
t.libs << "test"
t.pattern = 'test/*_test.rb'
t.verbose = true
- t.warning = false
+ t.warning = true
}
-task :isolated_test do
- ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
- Dir.glob("test/*_test.rb").all? do |file|
- system(ruby, '-Ilib:test', file)
- end or raise "Failures"
+namespace :test do
+ task :isolated do
+ ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
+ Dir.glob("test/*_test.rb").all? do |file|
+ system(ruby, '-Ilib:test', file)
+ end or raise "Failures"
+ end
end
# Generate the RDoc documentation
@@ -44,25 +46,24 @@ Rake::RDocTask.new { |rdoc|
rdoc.rdoc_files.include('README', 'CHANGELOG')
rdoc.rdoc_files.include('lib/action_mailer.rb')
rdoc.rdoc_files.include('lib/action_mailer/*.rb')
+ rdoc.rdoc_files.include('lib/action_mailer/delivery_method/*.rb')
}
spec = eval(File.read('actionmailer.gemspec'))
Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
- p.need_tar = true
- p.need_zip = true
end
desc "Publish the API documentation"
-task :pgem => [:package] do
+task :pgem => [:package] do
require 'rake/contrib/sshpublisher'
Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
`ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
end
desc "Publish the API documentation"
-task :pdoc => [:rdoc] do
+task :pdoc => [:rdoc] do
require 'rake/contrib/sshpublisher'
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/am", "doc").upload
end
View
3  actionmailer/lib/action_mailer.rb
@@ -32,8 +32,9 @@ def self.load_all!
end
autoload :AdvAttrAccessor, 'action_mailer/adv_attr_accessor'
+ autoload :DeprecatedBody, 'action_mailer/deprecated_body'
autoload :Base, 'action_mailer/base'
- autoload :Helpers, 'action_mailer/helpers'
+ autoload :DeliveryMethod, 'action_mailer/delivery_method'
autoload :Part, 'action_mailer/part'
autoload :PartContainer, 'action_mailer/part_container'
autoload :Quoting, 'action_mailer/quoting'
View
315 actionmailer/lib/action_mailer/base.rb
@@ -1,8 +1,4 @@
-require 'tmpdir'
-
-require "active_support/core_ext/class"
-# Use the old layouts until actionmailer gets refactored
-require "action_controller/legacy/layout"
+require 'active_support/core_ext/class'
module ActionMailer #:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
@@ -232,7 +228,7 @@ module ActionMailer #:nodoc:
# * <tt>raise_delivery_errors</tt> - Whether or not errors should be raised if the email fails to be delivered.
#
# * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, <tt>:test</tt>,
- # and <tt>:file</tt>.
+ # and <tt>:file</tt>. Or you may provide a custom delivery method object eg. MyOwnDeliveryMethodClass.new
#
# * <tt>perform_deliveries</tt> - Determines whether <tt>deliver_*</tt> methods are actually carried out. By default they are,
# but this can be turned off to help functional testing.
@@ -256,13 +252,20 @@ module ActionMailer #:nodoc:
# +implicit_parts_order+.
class Base
include AdvAttrAccessor, PartContainer, Quoting, Utils
- extend AbstractController::RenderingController
+
+ include AbstractController::RenderingController
+ include AbstractController::LocalizedCache
+ include AbstractController::Layouts
+
+ include AbstractController::Helpers
+ helper MailHelper
if Object.const_defined?(:ActionController)
include ActionController::UrlWriter
- include ActionController::Layout
end
+ include ActionMailer::DeprecatedBody
+
private_class_method :new #:nodoc:
class_inheritable_accessor :view_paths
@@ -270,35 +273,9 @@ class Base
cattr_accessor :logger
- @@smtp_settings = {
- :address => "localhost",
- :port => 25,
- :domain => 'localhost.localdomain',
- :user_name => nil,
- :password => nil,
- :authentication => nil,
- :enable_starttls_auto => true,
- }
- cattr_accessor :smtp_settings
-
- @@sendmail_settings = {
- :location => '/usr/sbin/sendmail',
- :arguments => '-i -t'
- }
- cattr_accessor :sendmail_settings
-
- @@file_settings = {
- :location => defined?(Rails) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
- }
-
- cattr_accessor :file_settings
-
@@raise_delivery_errors = true
cattr_accessor :raise_delivery_errors
- superclass_delegating_accessor :delivery_method
- self.delivery_method = :smtp
-
@@perform_deliveries = true
cattr_accessor :perform_deliveries
@@ -317,17 +294,12 @@ class Base
@@default_implicit_parts_order = [ "text/html", "text/enriched", "text/plain" ]
cattr_accessor :default_implicit_parts_order
+ @@protected_instance_variables = []
cattr_reader :protected_instance_variables
- @@protected_instance_variables = %w(@body)
# Specify the BCC addresses for the message
adv_attr_accessor :bcc
- # Define the body of the message. This is either a Hash (in which case it
- # specifies the variables to pass to the template when it is rendered),
- # or a string, in which case it specifies the actual text of the message.
- adv_attr_accessor :body
-
# Specify the CC addresses for the message.
adv_attr_accessor :cc
@@ -372,43 +344,42 @@ class Base
# have multiple mailer methods share the same template.
adv_attr_accessor :template
+ # The mail and action_name instances referenced by this mailer.
+ attr_reader :mail, :action_name
+
+ # Where the response body is stored.
+ attr_internal :response_body
+
# Override the mailer name, which defaults to an inflected version of the
# mailer's class name. If you want to use a template in a non-standard
# location, you can use this to specify that location.
+ attr_writer :mailer_name
+
def mailer_name(value = nil)
if value
- self.mailer_name = value
+ @mailer_name = value
else
- self.class.mailer_name
+ @mailer_name || self.class.mailer_name
end
end
- def mailer_name=(value)
- self.class.mailer_name = value
- end
-
- # The mail object instance referenced by this mailer.
- attr_reader :mail
- attr_reader :template_name, :default_template_name, :action_name
-
- def controller_path
- self.class.controller_path
- end
-
- def formats
- @template.formats
- end
+ # Alias controller_path to mailer_name so render :partial in views work.
+ alias :controller_path :mailer_name
class << self
attr_writer :mailer_name
+ delegate :settings, :settings=, :to => ActionMailer::DeliveryMethod::File, :prefix => :file
+ delegate :settings, :settings=, :to => ActionMailer::DeliveryMethod::Sendmail, :prefix => :sendmail
+ delegate :settings, :settings=, :to => ActionMailer::DeliveryMethod::Smtp, :prefix => :smtp
+
def mailer_name
@mailer_name ||= name.underscore
end
- # for ActionView compatibility
- alias_method :controller_name, :mailer_name
- alias_method :controller_path, :mailer_name
+ def delivery_method=(method_name)
+ @delivery_method = ActionMailer::DeliveryMethod.lookup_method(method_name)
+ end
def respond_to?(method_symbol, include_private = false) #:nodoc:
matches_dynamic_method?(method_symbol) || super
@@ -459,6 +430,7 @@ def template_root
self.view_paths && self.view_paths.first
end
+ # Should template root overwrite the whole view_paths?
def template_root=(root)
self.view_paths = ActionView::Base.process_view_paths(root)
end
@@ -470,73 +442,36 @@ def matches_dynamic_method?(method_name) #:nodoc:
end
end
+ # Configure delivery method. Check ActionMailer::DeliveryMethod for more
+ # instructions.
+ superclass_delegating_reader :delivery_method
+ self.delivery_method = :smtp
+
# Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
# will be initialized according to the named method. If not, the mailer will
# remain uninitialized (useful when you only need to invoke the "receive"
# method, for instance).
def initialize(method_name=nil, *parameters) #:nodoc:
+ @_response_body = nil
+ super()
create!(method_name, *parameters) if method_name
end
# Initialize the mailer via the given +method_name+. The body will be
# rendered and a new TMail::Mail object created.
def create!(method_name, *parameters) #:nodoc:
- ActiveSupport::Orchestra.instrument(:create_mail, :name => method_name) do
- initialize_defaults(method_name)
- __send__(method_name, *parameters)
-
- # If an explicit, textual body has not been set, we check assumptions.
- unless String === @body
- # First, we look to see if there are any likely templates that match,
- # which include the content-type in their file name (i.e.,
- # "the_template_file.text.html.erb", etc.). Only do this if parts
- # have not already been specified manually.
- # if @parts.empty?
- template_root.find_all(@template, {}, template_path).each do |template|
- @parts << Part.new(
- :content_type => template.mime_type ? template.mime_type.to_s : "text/plain",
- :disposition => "inline",
- :charset => charset,
- :body => render_template(template, @body)
- )
- end
-
- if @parts.size > 1
- @content_type = "multipart/alternative" if @content_type !~ /^multipart/
- @parts = sort_parts(@parts, @implicit_parts_order)
- end
- # end
-
- # Then, if there were such templates, we check to see if we ought to
- # also render a "normal" template (without the content type). If a
- # normal template exists (or if there were no implicit parts) we render
- # it.
- # ====
- # TODO: Revisit this
- # template_exists = @parts.empty?
- # template_exists ||= template_root.find("#{mailer_name}/#{@template}")
- # @body = render_message(@template, @body) if template_exists
-
- # Finally, if there are other message parts and a textual body exists,
- # we shift it onto the front of the parts and set the body to nil (so
- # that create_mail doesn't try to render it in addition to the parts).
- # ====
- # TODO: Revisit this
- # if !@parts.empty? && String === @body
- # @parts.unshift Part.new(:charset => charset, :body => @body)
- # @body = nil
- # end
- end
+ initialize_defaults(method_name)
+ __send__(method_name, *parameters)
- # If this is a multipart e-mail add the mime_version if it is not
- # already set.
- @mime_version ||= "1.0" if !@parts.empty?
+ # Create e-mail parts
+ create_parts
- # build the mail object itself
- @mail = create_mail
- end
+ # Set the subject if not set yet
+ @subject ||= I18n.t(:subject, :scope => [:actionmailer, mailer_name, method_name],
+ :default => method_name.humanize)
- @mail
+ # build the mail object itself
+ @mail = create_mail
end
# Delivers a TMail::Mail object. By default, it delivers the cached mail
@@ -545,14 +480,14 @@ def create!(method_name, *parameters) #:nodoc:
def deliver!(mail = @mail)
raise "no mail object available for delivery!" unless mail
- unless logger.nil?
+ if logger
logger.info "Sent mail to #{Array(recipients).join(', ')}"
logger.debug "\n#{mail.encoded}"
end
- ActiveSupport::Orchestra.instrument(:deliver_mail, :mail => @mail) do
+ ActiveSupport::Notifications.instrument(:deliver_mail, :mail => @mail) do
begin
- __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
+ self.delivery_method.perform_delivery(mail) if perform_deliveries
rescue Exception => e # Net::SMTP errors or sendmail pipe errors
raise e if raise_delivery_errors
end
@@ -562,93 +497,61 @@ def deliver!(mail = @mail)
end
private
+
# Set up the default values for the various instance variables of this
# mailer. Subclasses may override this method to provide different
# defaults.
def initialize_defaults(method_name)
- @charset ||= @@default_charset.dup
- @content_type ||= @@default_content_type.dup
+ @charset ||= @@default_charset.dup
+ @content_type ||= @@default_content_type.dup
@implicit_parts_order ||= @@default_implicit_parts_order.dup
- @template ||= method_name
- @default_template_name = @action_name = @template
- @mailer_name ||= self.class.name.underscore
- @parts ||= []
+ @mime_version ||= @@default_mime_version.dup if @@default_mime_version
+
+ @mailer_name ||= self.class.mailer_name
+ @template ||= method_name
+ @action_name = @template
+
+ @parts ||= []
@headers ||= {}
- @body ||= {}
- @mime_version = @@default_mime_version.dup if @@default_mime_version
@sent_on ||= Time.now
- end
- def render_template(template, body)
- if template.respond_to?(:mime_type)
- @current_template_content_type = template.mime_type && template.mime_type.to_sym.to_s
- end
-
- @template = initialize_template_class(body)
- layout = _pick_layout(layout, true) unless
- ActionController::Base.exempt_from_layout.include?(template.handler)
- @template._render_template(template, layout, {})
- ensure
- @current_template_content_type = nil
+ super # Run deprecation hooks
end
- def render_message(method_name, body)
- render :file => method_name, :body => body
- ensure
- @current_template_content_type = nil
- end
+ def create_parts
+ super # Run deprecation hooks
- def render(opts)
- layout, file = opts.delete(:layout), opts[:file]
-
- begin
- @template = initialize_template_class(opts.delete(:body))
-
- if file
- prefix = mailer_name unless file =~ /\//
- template = view_paths.find(file, {:formats => formats}, prefix)
+ if String === response_body
+ @parts.unshift Part.new(
+ :content_type => "text/plain",
+ :disposition => "inline",
+ :charset => charset,
+ :body => response_body
+ )
+ else
+ self.class.template_root.find_all(@template, {}, mailer_name).each do |template|
+ @parts << Part.new(
+ :content_type => template.mime_type ? template.mime_type.to_s : "text/plain",
+ :disposition => "inline",
+ :charset => charset,
+ :body => render_to_body(:_template => template)
+ )
end
- layout = _pick_layout(layout,
- !template || ActionController::Base.exempt_from_layout.include?(template.handler))
-
- if template
- @template._render_template(template, layout, opts)
- elsif inline = opts[:inline]
- @template._render_inline(inline, layout, opts)
+ if @parts.size > 1
+ @content_type = "multipart/alternative" if @content_type !~ /^multipart/
+ @parts = sort_parts(@parts, @implicit_parts_order)
end
- end
- end
- def default_template_format
- if @current_template_content_type
- Mime::Type.lookup(@current_template_content_type).to_sym
- else
- :html
+ # If this is a multipart e-mail add the mime_version if it is not
+ # already set.
+ @mime_version ||= "1.0" if !@parts.empty?
end
end
- def template_root
- self.class.template_root
- end
-
- def template_root=(root)
- self.class.template_root = root
- end
-
- def template_path
- "#{mailer_name}"
- end
-
- def initialize_template_class(assigns)
- template = ActionView::Base.new(self.class.view_paths, assigns, self)
- template.formats = [default_template_format]
- template
- end
-
def sort_parts(parts, order = [])
order = order.collect { |s| s.downcase }
-
+
parts = parts.sort do |a, b|
a_ct = a.content_type.downcase
b_ct = b.content_type.downcase
@@ -697,14 +600,6 @@ def create_mail
m.set_content_type(real_content_type, nil, ctype_attrs)
m.body = normalize_new_lines(@parts.first.body)
else
- if String === body
- part = TMail::Mail.new
- part.body = normalize_new_lines(body)
- part.set_content_type(real_content_type, nil, ctype_attrs)
- part.set_content_disposition "inline"
- m.parts << part
- end
-
@parts.each do |p|
part = (TMail::Mail === p ? p : p.to_mail(self))
m.parts << part
@@ -719,43 +614,5 @@ def create_mail
@mail = m
end
- def perform_delivery_smtp(mail)
- destinations = mail.destinations
- mail.ready_to_send
- sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']
-
- smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
- smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
- smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password],
- smtp_settings[:authentication]) do |smtp|
- smtp.sendmail(mail.encoded, sender, destinations)
- end
- end
-
- def perform_delivery_sendmail(mail)
- sendmail_args = sendmail_settings[:arguments]
- sendmail_args += " -f \"#{mail['return-path']}\"" if mail['return-path']
- IO.popen("#{sendmail_settings[:location]} #{sendmail_args}","w+") do |sm|
- sm.print(mail.encoded.gsub(/\r/, ''))
- sm.flush
- end
- end
-
- def perform_delivery_test(mail)
- deliveries << mail
- end
-
- def perform_delivery_file(mail)
- FileUtils.mkdir_p file_settings[:location]
-
- (mail.to + mail.cc + mail.bcc).uniq.each do |to|
- File.open(File.join(file_settings[:location], to), 'a') { |f| f.write(mail) }
- end
- end
- end
-
- Base.class_eval do
- include Helpers
- helper MailHelper
end
end
View
57 actionmailer/lib/action_mailer/delivery_method.rb
@@ -0,0 +1,57 @@
+require "active_support/core_ext/class"
+module ActionMailer
+ module DeliveryMethod
+
+ autoload :File, 'action_mailer/delivery_method/file'
+ autoload :Sendmail, 'action_mailer/delivery_method/sendmail'
+ autoload :Smtp, 'action_mailer/delivery_method/smtp'
+ autoload :Test, 'action_mailer/delivery_method/test'
+
+ # Creates a new DeliveryMethod object according to the given options.
+ #
+ # If no arguments are passed to this method, then a new
+ # ActionMailer::DeliveryMethod::Stmp object will be returned.
+ #
+ # If you pass a Symbol as the first argument, then a corresponding
+ # delivery method class under the ActionMailer::DeliveryMethod namespace
+ # will be created.
+ # For example:
+ #
+ # ActionMailer::DeliveryMethod.lookup_method(:sendmail)
+ # # => returns a new ActionMailer::DeliveryMethod::Sendmail object
+ #
+ # If the first argument is not a Symbol, then it will simply be returned:
+ #
+ # ActionMailer::DeliveryMethod.lookup_method(MyOwnDeliveryMethod.new)
+ # # => returns MyOwnDeliveryMethod.new
+ def self.lookup_method(delivery_method)
+ case delivery_method
+ when Symbol
+ method_name = delivery_method.to_s.camelize
+ method_class = ActionMailer::DeliveryMethod.const_get(method_name)
+ method_class.new
+ when nil # default
+ Smtp.new
+ else
+ delivery_method
+ end
+ end
+
+ # An abstract delivery method class. There are multiple delivery method classes.
+ # See the classes under the ActionMailer::DeliveryMethod, e.g.
+ # ActionMailer::DeliveryMethod::Smtp.
+ # Smtp is the default delivery method for production
+ # while Test is used in testing.
+ #
+ # each delivery method exposes just one method
+ #
+ # delivery_method = ActionMailer::DeliveryMethod::Smtp.new
+ # delivery_method.perform_delivery(mail) # send the mail via smtp
+ #
+ class Method
+ superclass_delegating_accessor :settings
+ self.settings = {}
+ end
+
+ end
+end
View
21 actionmailer/lib/action_mailer/delivery_method/file.rb
@@ -0,0 +1,21 @@
+require 'tmpdir'
+
+module ActionMailer
+ module DeliveryMethod
+
+ # A delivery method implementation which writes all mails to a file.
+ class File < Method
+ self.settings = {
+ :location => defined?(Rails) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
+ }
+
+ def perform_delivery(mail)
+ FileUtils.mkdir_p settings[:location]
+
+ (mail.to + mail.cc + mail.bcc).uniq.each do |to|
+ ::File.open(::File.join(settings[:location], to), 'a') { |f| f.write(mail) }
+ end
+ end
+ end
+ end
+end
View
22 actionmailer/lib/action_mailer/delivery_method/sendmail.rb
@@ -0,0 +1,22 @@
+module ActionMailer
+ module DeliveryMethod
+
+ # A delivery method implementation which sends via sendmail.
+ class Sendmail < Method
+ self.settings = {
+ :location => '/usr/sbin/sendmail',
+ :arguments => '-i -t'
+ }
+
+ def perform_delivery(mail)
+ sendmail_args = settings[:arguments]
+ sendmail_args += " -f \"#{mail['return-path']}\"" if mail['return-path']
+ IO.popen("#{settings[:location]} #{sendmail_args}","w+") do |sm|
+ sm.print(mail.encoded.gsub(/\r/, ''))
+ sm.flush
+ end
+ end
+ end
+
+ end
+end
View
31 actionmailer/lib/action_mailer/delivery_method/smtp.rb
@@ -0,0 +1,31 @@
+module ActionMailer
+ module DeliveryMethod
+ # A delivery method implementation which sends via smtp.
+ class Smtp < Method
+
+ self.settings = {
+ :address => "localhost",
+ :port => 25,
+ :domain => 'localhost.localdomain',
+ :user_name => nil,
+ :password => nil,
+ :authentication => nil,
+ :enable_starttls_auto => true,
+ }
+
+ def perform_delivery(mail)
+ destinations = mail.destinations
+ mail.ready_to_send
+ sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']
+
+ smtp = Net::SMTP.new(settings[:address], settings[:port])
+ smtp.enable_starttls_auto if settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
+ smtp.start(settings[:domain], settings[:user_name], settings[:password],
+ settings[:authentication]) do |smtp|
+ smtp.sendmail(mail.encoded, sender, destinations)
+ end
+ end
+ end
+
+ end
+end
View
12 actionmailer/lib/action_mailer/delivery_method/test.rb
@@ -0,0 +1,12 @@
+module ActionMailer
+ module DeliveryMethod
+
+ # A delivery method implementation designed for testing, which just appends each record to the :deliveries array
+ class Test < Method
+ def perform_delivery(mail)
+ ActionMailer::Base.deliveries << mail
+ end
+ end
+
+ end
+end
View
44 actionmailer/lib/action_mailer/deprecated_body.rb
@@ -0,0 +1,44 @@
+module ActionMailer
+ # TODO Remove this module all together in a next release. Ensure that super
+ # hooks in ActionMailer::Base are removed as well.
+ module DeprecatedBody
+ def self.included(base)
+ base.class_eval do
+ # Define the body of the message. This is either a Hash (in which case it
+ # specifies the variables to pass to the template when it is rendered),
+ # or a string, in which case it specifies the actual text of the message.
+ adv_attr_accessor :body
+ end
+ end
+
+ def initialize_defaults(method_name)
+ @body ||= {}
+ end
+
+ def create_parts
+ if String === @body
+ ActiveSupport::Deprecation.warn('body is deprecated. To set the body with a text ' <<
+ 'call render(:text => "body").', caller[0,10])
+ self.response_body = @body
+ elsif @body.is_a?(Hash) && !@body.empty?
+ ActiveSupport::Deprecation.warn('body is deprecated. To set assigns simply ' <<
+ 'use instance variables', caller[0,10])
+ @body.each { |k, v| instance_variable_set(:"@#{k}", v) }
+ end
+ end
+
+ def render(*args)
+ options = args.last.is_a?(Hash) ? args.last : {}
+ if options[:body]
+ ActiveSupport::Deprecation.warn(':body is deprecated. To set assigns simply ' <<
+ 'use instance variables', caller[0,1])
+
+ options.delete(:body).each do |k, v|
+ instance_variable_set(:"@#{k}", v)
+ end
+ end
+
+ super
+ end
+ end
+end
View
114 actionmailer/lib/action_mailer/helpers.rb
@@ -1,114 +0,0 @@
-require 'active_support/dependencies'
-
-module ActionMailer
- module Helpers #:nodoc:
- def self.included(base) #:nodoc:
- # Initialize the base module to aggregate its helpers.
- base.class_inheritable_accessor :master_helper_module
- base.master_helper_module = Module.new
-
- # Extend base with class methods to declare helpers.
- base.extend(ClassMethods)
-
- base.class_eval do
- # Wrap inherited to create a new master helper module for subclasses.
- class << self
- alias_method_chain :inherited, :helper
- end
-
- # Wrap initialize_template_class to extend new template class
- # instances with the master helper module.
- alias_method_chain :initialize_template_class, :helper
- end
- end
-
- module ClassMethods
- # Makes all the (instance) methods in the helper module available to templates rendered through this controller.
- # See ActionView::Helpers (link:classes/ActionView/Helpers.html) for more about making your own helper modules
- # available to the templates.
- def add_template_helper(helper_module) #:nodoc:
- master_helper_module.module_eval "include #{helper_module}"
- end
-
- # Declare a helper:
- # helper :foo
- # requires 'foo_helper' and includes FooHelper in the template class.
- # helper FooHelper
- # includes FooHelper in the template class.
- # helper { def foo() "#{bar} is the very best" end }
- # evaluates the block in the template class, adding method +foo+.
- # helper(:three, BlindHelper) { def mice() 'mice' end }
- # does all three.
- def helper(*args, &block)
- args.flatten.each do |arg|
- case arg
- when Module
- add_template_helper(arg)
- when String, Symbol
- file_name = arg.to_s.underscore + '_helper'
- class_name = file_name.camelize
-
- require_dependency(file_name, "Missing helper file helpers/%s.rb")
- # begin
- # require_dependency(file_name)
- # rescue LoadError => load_error
- # requiree = / -- (.*?)(\.rb)?$/.match(load_error.message).to_a[1]
- # msg = (requiree == file_name) ? "Missing helper file helpers/#{file_name}.rb" : "Can't load file: #{requiree}"
- # raise LoadError.new(msg).copy_blame!(load_error)
- # end
-
- add_template_helper(class_name.constantize)
- else
- raise ArgumentError, 'helper expects String, Symbol, or Module argument'
- end
- end
-
- # Evaluate block in template class if given.
- master_helper_module.module_eval(&block) if block_given?
- end
-
- # Declare a controller method as a helper. For example,
- # helper_method :link_to
- # def link_to(name, options) ... end
- # makes the link_to controller method available in the view.
- def helper_method(*methods)
- methods.flatten.each do |method|
- master_helper_module.module_eval <<-end_eval
- def #{method}(*args, &block)
- controller.__send__(%(#{method}), *args, &block)
- end
- end_eval
- end
- end
-
- # Declare a controller attribute as a helper. For example,
- # helper_attr :name
- # attr_accessor :name
- # makes the name and name= controller methods available in the view.
- # The is a convenience wrapper for helper_method.
- def helper_attr(*attrs)
- attrs.flatten.each { |attr| helper_method(attr, "#{attr}=") }
- end
-
- private
- def inherited_with_helper(child)
- inherited_without_helper(child)
- begin
- child.master_helper_module = Module.new
- child.master_helper_module.__send__(:include, master_helper_module)
- child.helper child.name.to_s.underscore
- rescue MissingSourceFile => e
- raise unless e.is_missing?("#{child.name.to_s.underscore}_helper")
- end
- end
- end
-
- private
- # Extend the template class instance with our controller's helper module.
- def initialize_template_class_with_helper(assigns)
- initialize_template_class_without_helper(assigns).tap do |template|
- template.extend self.class.master_helper_module
- end
- end
- end
-end
View
2  actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/parser.rb
@@ -43,6 +43,7 @@ module Racc
class Parser
+ old_verbose, $VERBOSE = $VERBOSE, nil
Racc_Runtime_Version = '1.4.5'
Racc_Runtime_Revision = '$Revision: 1.7 $'.split[1]
@@ -71,6 +72,7 @@ class Parser
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
Racc_Runtime_Type = 'ruby'
end
+ $VERBOSE = old_verbose
def Parser.racc_runtime_type
Racc_Runtime_Type
View
16 actionmailer/test/abstract_unit.rb
@@ -1,9 +1,17 @@
+root = File.expand_path('../../..', __FILE__)
+begin
+ require "#{root}/vendor/gems/environment"
+rescue LoadError
+ $:.unshift("#{root}/activesupport/lib")
+ $:.unshift("#{root}/actionpack/lib")
+end
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
+
require 'rubygems'
require 'test/unit'
-$:.unshift "#{File.dirname(__FILE__)}/../lib"
-$:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
-$:.unshift "#{File.dirname(__FILE__)}/../../actionpack/lib"
require 'action_mailer'
require 'action_mailer/test_case'
@@ -14,6 +22,8 @@
ActionView::Template.register_template_handler :haml, lambda { |template| "Look its HAML!".inspect }
ActionView::Template.register_template_handler :bak, lambda { |template| "Lame backup".inspect }
+ActionView::Base::DEFAULT_CONFIG = { :assets_dir => '/nowhere' }
+
$:.unshift "#{File.dirname(__FILE__)}/fixtures/helpers"
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
View
36 actionmailer/test/delivery_method_test.rb
@@ -11,6 +11,21 @@ class FileDeliveryMethodMailer < ActionMailer::Base
self.delivery_method = :file
end
+class CustomDeliveryMethod
+ attr_accessor :custom_deliveries
+ def initialize()
+ @customer_deliveries = []
+ end
+
+ def self.perform_delivery(mail)
+ self.custom_deliveries << mail
+ end
+end
+
+class CustomerDeliveryMailer < ActionMailer::Base
+ self.delivery_method = CustomDeliveryMethod.new
+end
+
class ActionMailerBase_delivery_method_Test < Test::Unit::TestCase
def setup
set_delivery_method :smtp
@@ -21,7 +36,7 @@ def teardown
end
def test_should_be_the_default_smtp
- assert_equal :smtp, ActionMailer::Base.delivery_method
+ assert_instance_of ActionMailer::DeliveryMethod::Smtp, ActionMailer::Base.delivery_method
end
end
@@ -35,7 +50,7 @@ def teardown
end
def test_should_be_the_default_smtp
- assert_equal :smtp, DefaultDeliveryMethodMailer.delivery_method
+ assert_instance_of ActionMailer::DeliveryMethod::Smtp, DefaultDeliveryMethodMailer.delivery_method
end
end
@@ -49,7 +64,7 @@ def teardown
end
def test_should_be_the_set_delivery_method
- assert_equal :sendmail, NonDefaultDeliveryMethodMailer.delivery_method
+ assert_instance_of ActionMailer::DeliveryMethod::Sendmail, NonDefaultDeliveryMethodMailer.delivery_method
end
end
@@ -63,7 +78,7 @@ def teardown
end
def test_should_be_the_set_delivery_method
- assert_equal :file, FileDeliveryMethodMailer.delivery_method
+ assert_instance_of ActionMailer::DeliveryMethod::File, FileDeliveryMethodMailer.delivery_method
end
def test_should_default_location_to_the_tmpdir
@@ -71,3 +86,16 @@ def test_should_default_location_to_the_tmpdir
end
end
+class CustomDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase
+ def setup
+ set_delivery_method :smtp
+ end
+
+ def teardown
+ restore_delivery_method
+ end
+
+ def test_should_be_the_set_delivery_method
+ assert_instance_of CustomDeliveryMethod, CustomerDeliveryMailer.delivery_method
+ end
+end
View
21 actionmailer/test/mail_helper_test.rb
@@ -20,28 +20,29 @@ def use_example_helper(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
- self.body = { :text => "emphasize me!" }
+
+ @text = "emphasize me!"
end
def use_mail_helper(recipient)
recipients recipient
subject "using mailing helpers"
from "tester@example.com"
- self.body = { :text =>
- "But soft! What light through yonder window breaks? It is the east, " +
- "and Juliet is the sun. Arise, fair sun, and kill the envious moon, " +
- "which is sick and pale with grief that thou, her maid, art far more " +
- "fair than she. Be not her maid, for she is envious! Her vestal " +
- "livery is but sick and green, and none but fools do wear it. Cast " +
- "it off!"
- }
+
+ @text = "But soft! What light through yonder window breaks? It is the east, " +
+ "and Juliet is the sun. Arise, fair sun, and kill the envious moon, " +
+ "which is sick and pale with grief that thou, her maid, art far more " +
+ "fair than she. Be not her maid, for she is envious! Her vestal " +
+ "livery is but sick and green, and none but fools do wear it. Cast " +
+ "it off!"
end
def use_helper_method(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
- self.body = { :text => "emphasize me!" }
+
+ @text = "emphasize me!"
end
private
View
8 actionmailer/test/mail_layout_test.rb
@@ -11,14 +11,18 @@ def spam(recipient)
recipients recipient
subject "You have a mail"
from "tester@example.com"
- body render(:inline => "Hello, <%= @world %>", :layout => 'spam', :body => { :world => "Earth" })
+
+ @world = "Earth"
+ render(:inline => "Hello, <%= @world %>", :layout => 'spam')
end
def nolayout(recipient)
recipients recipient
subject "You have a mail"
from "tester@example.com"
- body render(:inline => "Hello, <%= @world %>", :layout => false, :body => { :world => "Earth" })
+
+ @world = "Earth"
+ render(:inline => "Hello, <%= @world %>", :layout => false)
end
def multipart(recipient, type = nil)
View
26 actionmailer/test/mail_render_test.rb
@@ -5,14 +5,27 @@ def inline_template(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
- body render(:inline => "Hello, <%= @world %>", :body => { :world => "Earth" })
+
+ @world = "Earth"
+ render :inline => "Hello, <%= @world %>"
end
def file_template(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
- body render(:file => "signed_up", :body => { :recipient => recipient })
+
+ @recipient = recipient
+ render :file => "templates/signed_up"
+ end
+
+ def implicit_body(recipient)
+ recipients recipient
+ subject "using helpers"
+ from "tester@example.com"
+
+ @recipient = recipient
+ render :template => "templates/signed_up"
end
def rxml_template(recipient)
@@ -31,7 +44,9 @@ def included_old_subtemplate(recipient)
recipients recipient
subject "Including another template in the one being rendered"
from "tester@example.com"
- body render(:inline => "Hello, <%= render \"subtemplate\" %>", :body => { :world => "Earth" })
+
+ @world = "Earth"
+ render :inline => "Hello, <%= render \"subtemplate\" %>"
end
def initialize_defaults(method_name)
@@ -69,6 +84,11 @@ def teardown
restore_delivery_method
end
+ def test_implicit_body
+ mail = RenderMailer.create_implicit_body(@recipient)
+ assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip
+ end
+
def test_inline_template
mail = RenderMailer.create_inline_template(@recipient)
assert_equal "Hello, Earth", mail.body.strip
View
156 actionmailer/test/mail_service_test.rb
@@ -15,18 +15,20 @@ def multipart_with_template_path_with_dots(recipient)
class TestMailer < ActionMailer::Base
def signed_up(recipient)
- @recipients = recipient
- @subject = "[Signed up] Welcome #{recipient}"
- @from = "system@loudthinking.com"
- @body["recipient"] = recipient
+ recipients recipient
+ subject "[Signed up] Welcome #{recipient}"
+ from "system@loudthinking.com"
+
+ @recipient = recipient
end
def cancelled_account(recipient)
- self.recipients = recipient
- self.subject = "[Cancelled] Goodbye #{recipient}"
- self.from = "system@loudthinking.com"
- self.sent_on = Time.local(2004, 12, 12)
- self.body = "Goodbye, Mr. #{recipient}"
+ recipients recipient
+ subject "[Cancelled] Goodbye #{recipient}"
+ from "system@loudthinking.com"
+ sent_on Time.local(2004, 12, 12)
+
+ render :text => "Goodbye, Mr. #{recipient}"
end
def cc_bcc(recipient)
@@ -36,7 +38,8 @@ def cc_bcc(recipient)
sent_on Time.local(2004, 12, 12)
cc "nobody@loudthinking.com"
bcc "root@loudthinking.com"
- body "Nothing to see here."
+
+ render :text => "Nothing to see here."
end
def different_reply_to(recipient)
@@ -45,50 +48,55 @@ def different_reply_to(recipient)
from "system@loudthinking.com"
sent_on Time.local(2008, 5, 23)
reply_to "atraver@gmail.com"
- body "Nothing to see here."
+
+ render :text => "Nothing to see here."
end
def iso_charset(recipient)
- @recipients = recipient
- @subject = "testing isø charsets"
- @from = "system@loudthinking.com"
- @sent_on = Time.local 2004, 12, 12
- @cc = "nobody@loudthinking.com"
- @bcc = "root@loudthinking.com"
- @body = "Nothing to see here."
- @charset = "iso-8859-1"
+ recipients recipient
+ subject "testing isø charsets"
+ from "system@loudthinking.com"
+ sent_on Time.local(2004, 12, 12)
+ cc "nobody@loudthinking.com"
+ bcc "root@loudthinking.com"
+ charset "iso-8859-1"
+
+ render :text => "Nothing to see here."
end
def unencoded_subject(recipient)
- @recipients = recipient
- @subject = "testing unencoded subject"
- @from = "system@loudthinking.com"
- @sent_on = Time.local 2004, 12, 12
- @cc = "nobody@loudthinking.com"
- @bcc = "root@loudthinking.com"
- @body = "Nothing to see here."
+ recipients recipient
+ subject "testing unencoded subject"
+ from "system@loudthinking.com"
+ sent_on Time.local(2004, 12, 12)
+ cc "nobody@loudthinking.com"
+ bcc "root@loudthinking.com"
+
+ render :text => "Nothing to see here."
end
def extended_headers(recipient)
- @recipients = recipient
- @subject = "testing extended headers"
- @from = "Grytøyr <stian1@example.net>"
- @sent_on = Time.local 2004, 12, 12
- @cc = "Grytøyr <stian2@example.net>"
- @bcc = "Grytøyr <stian3@example.net>"
- @body = "Nothing to see here."
- @charset = "iso-8859-1"
+ recipients recipient
+ subject "testing extended headers"
+ from "Grytøyr <stian1@example.net>"
+ sent_on Time.local(2004, 12, 12)
+ cc "Grytøyr <stian2@example.net>"
+ bcc "Grytøyr <stian3@example.net>"
+ charset "iso-8859-1"
+
+ render :text => "Nothing to see here."
end
def utf8_body(recipient)
- @recipients = recipient
- @subject = "testing utf-8 body"
- @from = "Foo áëô îü <extended@example.net>"
- @sent_on = Time.local 2004, 12, 12
- @cc = "Foo áëô îü <extended@example.net>"
- @bcc = "Foo áëô îü <extended@example.net>"
- @body = "åœö blah"
- @charset = "utf-8"
+ recipients recipient
+ subject "testing utf-8 body"
+ from "Foo áëô îü <extended@example.net>"
+ sent_on Time.local(2004, 12, 12)
+ cc "Foo áëô îü <extended@example.net>"
+ bcc "Foo áëô îü <extended@example.net>"
+ charset "utf-8"
+
+ render :text => "åœö blah"
end
def multipart_with_mime_version(recipient)
@@ -128,7 +136,6 @@ def explicitly_multipart_example(recipient, ct=nil)
subject "multipart example"
from "test@example.com"
sent_on Time.local(2004, 12, 12)
- body "plain text default"
content_type ct if ct
part "text/html" do |p|
@@ -138,15 +145,18 @@ def explicitly_multipart_example(recipient, ct=nil)
attachment :content_type => "image/jpeg", :filename => "foo.jpg",
:body => "123456789"
+
+ render :text => "plain text default"
end
def implicitly_multipart_example(recipient, cs = nil, order = nil)
- @recipients = recipient
- @subject = "multipart example"
- @from = "test@example.com"
- @sent_on = Time.local 2004, 12, 12
- @body = { "recipient" => recipient }
- @charset = cs if cs
+ recipients recipient
+ subject "multipart example"
+ from "test@example.com"
+ sent_on Time.local(2004, 12, 12)
+
+ @charset = cs if cs
+ @recipient = recipient
@implicit_parts_order = order if order
end
@@ -155,20 +165,22 @@ def implicitly_multipart_with_utf8
subject "Foo áëô îü"
from "some.one@somewhere.test"
template "implicitly_multipart_example"
- body ({ "recipient" => "no.one@nowhere.test" })
+
+ @recipient = "no.one@nowhere.test"
end
def html_mail(recipient)
recipients recipient
subject "html mail"
from "test@example.com"
- body "<em>Emphasize</em> <strong>this</strong>"
content_type "text/html"
+
+ render :text => "<em>Emphasize</em> <strong>this</strong>"
end
def html_mail_with_underscores(recipient)
subject "html mail with underscores"
- body %{<a href="http://google.com" target="_blank">_Google</a>}
+ render :text => %{<a href="http://google.com" target="_blank">_Google</a>}
end
def custom_template(recipient)
@@ -178,7 +190,7 @@ def custom_template(recipient)
sent_on Time.local(2004, 12, 12)
template "signed_up"
- body["recipient"] = recipient
+ @recipient = recipient
end
def custom_templating_extension(recipient)
@@ -187,15 +199,16 @@ def custom_templating_extension(recipient)
from "system@loudthinking.com"
sent_on Time.local(2004, 12, 12)
- body["recipient"] = recipient
+ @recipient = recipient
end
def various_newlines(recipient)
recipients recipient
subject "various newlines"
from "test@example.com"
- body "line #1\nline #2\rline #3\r\nline #4\r\r" +
- "line #5\n\nline#6\r\n\r\nline #7"
+
+ render :text => "line #1\nline #2\rline #3\r\nline #4\r\r" +
+ "line #5\n\nline#6\r\n\r\nline #7"
end
def various_newlines_multipart(recipient)
@@ -203,6 +216,7 @@ def various_newlines_multipart(recipient)
subject "various newlines multipart"
from "test@example.com"
content_type "multipart/alternative"
+
part :content_type => "text/plain", :body => "line #1\nline #2\rline #3\r\nline #4\r\r"
part :content_type => "text/html", :body => "<p>line #1</p>\n<p>line #2</p>\r<p>line #3</p>\r\n<p>line #4</p>\r\r"
end
@@ -212,10 +226,12 @@ def nested_multipart(recipient)
subject "nested multipart"
from "test@example.com"
content_type "multipart/mixed"
+
part :content_type => "multipart/alternative", :content_disposition => "inline", :headers => { "foo" => "bar" } do |p|
p.part :content_type => "text/plain", :body => "test text\nline #2"
p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>\nline #2"
end
+
attachment :content_type => "application/octet-stream",:filename => "test.txt", :body => "test abcdefghijklmnopqstuvwxyz"
end
@@ -224,6 +240,7 @@ def nested_multipart_with_body(recipient)
subject "nested multipart with body"
from "test@example.com"
content_type "multipart/mixed"
+
part :content_type => "multipart/alternative", :content_disposition => "inline", :body => "Nothing to see here." do |p|
p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>"
end
@@ -253,7 +270,7 @@ def headers_with_nonalpha_chars(recipient)
from "One: Two <test@example.com>"
cc "Three: Four <test@example.com>"
bcc "Five: Six <test@example.com>"
- body "testing"
+ render :text => "testing"
end
def custom_content_type_attributes
@@ -261,15 +278,15 @@ def custom_content_type_attributes
subject "custom content types"
from "some.one@somewhere.test"
content_type "text/plain; format=flowed"
- body "testing"
+ render :text => "testing"
end
def return_path
recipients "no.one@nowhere.test"
subject "return path test"
from "some.one@somewhere.test"
- body "testing"
headers "return-path" => "another@somewhere.test"
+ render :text => "testing"
end
def body_ivar(recipient)
@@ -279,7 +296,13 @@ def body_ivar(recipient)
body :body => "foo", :bar => "baz"
end
- class <<self
+ def subject_with_i18n(recipient)
+ recipients recipient
+ from "system@loudthinking.com"
+ render :text => "testing"
+ end
+
+ class << self
attr_accessor :received_body
end
@@ -375,6 +398,15 @@ def test_signed_up
assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
end
+ def test_subject_with_i18n
+ assert_nothing_raised { TestMailer.deliver_subject_with_i18n(@recipient) }
+ assert_equal "Subject with i18n", ActionMailer::Base.deliveries.first.subject
+
+ I18n.backend.store_translations('en', :actionmailer => {:test_mailer => {:subject_with_i18n => {:subject => "New Subject!"}}})
+ assert_nothing_raised { TestMailer.deliver_subject_with_i18n(@recipient) }
+ assert_equal "New Subject!", ActionMailer::Base.deliveries.last.subject
+ end
+
def test_custom_template
expected = new_mail
expected.to = @recipient
@@ -554,7 +586,7 @@ def test_perform_deliveries_flag
def test_doesnt_raise_errors_when_raise_delivery_errors_is_false
ActionMailer::Base.raise_delivery_errors = false
- TestMailer.any_instance.expects(:perform_delivery_test).raises(Exception)
+ TestMailer.delivery_method.expects(:perform_delivery).raises(Exception)
assert_nothing_raised { TestMailer.deliver_signed_up(@recipient) }
end
@@ -1024,7 +1056,7 @@ def test_attr
class MethodNamingTest < Test::Unit::TestCase
class TestMailer < ActionMailer::Base
def send
- body 'foo'
+ render :text => 'foo'
end
end
View
6 actionmailer/test/test_helper_test.rb
@@ -4,13 +4,15 @@ class TestHelperMailer < ActionMailer::Base
def test
recipients "test@example.com"
from "tester@example.com"
- body render(:inline => "Hello, <%= @world %>", :body => { :world => "Earth" })
+
+ @world = "Earth"
+ render(:inline => "Hello, <%= @world %>")
end
end
class TestHelperMailerTest < ActionMailer::TestCase
def test_setup_sets_right_action_mailer_options
- assert_equal :test, ActionMailer::Base.delivery_method
+ assert_instance_of ActionMailer::DeliveryMethod::Test, ActionMailer::Base.delivery_method
assert ActionMailer::Base.perform_deliveries
assert_equal [], ActionMailer::Base.deliveries
end
View
44 actionmailer/test/url_test.rb
@@ -1,9 +1,9 @@
require 'abstract_unit'
class TestMailer < ActionMailer::Base
-
+
default_url_options[:host] = 'www.basecamphq.com'
-
+
def signed_up_with_url(recipient)
@recipients = recipient
@subject = "[Signed up] Welcome #{recipient}"
@@ -52,25 +52,27 @@ def teardown
end
def test_signed_up_with_url
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- map.welcome 'welcome', :controller=>"foo", :action=>"bar"
- end
+ ActionController::Routing.use_controllers! ['welcome'] do
+ ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+ map.welcome 'welcome', :controller=>"foo", :action=>"bar"
+ end
- expected = new_mail
- expected.to = @recipient
- expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n<img alt=\"Somelogo\" src=\"/images/somelogo.png\" />"
- expected.from = "system@loudthinking.com"
- expected.date = Time.local(2004, 12, 12)
-
- created = nil
- assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) }
- assert_not_nil created
- assert_equal expected.encoded, created.encoded
-
- assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
- assert_not_nil ActionMailer::Base.deliveries.first
- assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
+ expected = new_mail
+ expected.to = @recipient
+ expected.subject = "[Signed up] Welcome #{@recipient}"
+ expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n<img alt=\"Somelogo\" src=\"/images/somelogo.png\" />"
+ expected.from = "system@loudthinking.com"
+ expected.date = Time.local(2004, 12, 12)
+
+ created = nil
+ assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) }
+ assert_not_nil created
+ assert_equal expected.encoded, created.encoded
+
+ assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
+ assert_not_nil ActionMailer::Base.deliveries.first
+ assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
+ end
end
end
View
15 actionpack/Gemfile
@@ -1,15 +0,0 @@
-rails_root = Pathname.new(File.dirname(__FILE__)).join("..")
-
-gem "rack", "~> 1.0.0"
-gem "rack-test", "~> 0.5.0"
-gem "activesupport", "3.0.pre", :vendored_at => rails_root.join("activesupport")
-gem "activemodel", "3.0.pre", :vendored_at => rails_root.join("activemodel")
-gem "erubis", "~> 2.6.0"
-
-only :test do
- gem "mocha"
- gem "sqlite3-ruby"
- gem "RedCloth"
-end
-
-disable_system_gems
View
22 actionpack/Rakefile
@@ -19,16 +19,6 @@ RUBY_FORGE_USER = "webster132"
desc "Default Task"
task :default => :test
-task :bundle do
- puts "Checking if the bundled testing requirements are up to date..."
- result = system "gem bundle"
- unless result
- puts "The gem bundler is not installed. Installing."
- system "gem install bundler"
- system "gem bundle"
- end
-end
-
# Run the unit tests
desc "Run all unit tests"
@@ -66,7 +56,7 @@ Rake::RDocTask.new { |rdoc|
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.options << '--charset' << 'utf-8'
rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
- if ENV['DOC_FILES']
+ if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
@@ -80,8 +70,6 @@ spec = eval(File.read('actionpack.gemspec'))
Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
- p.need_tar = true