Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 0eae392 + b475f74 commit fa3268d3521c52f43b8d6e986d74d466300f4bfe @iaddict committed Jul 18, 2011
Showing with 3,587 additions and 3,803 deletions.
  1. +18 −13 Gemfile
  2. +1 −1 RAILS_VERSION
  3. +31 −25 README.rdoc
  4. +24 −2 Rakefile
  5. +2 −2 actionmailer/README.rdoc
  6. +2 −2 actionmailer/Rakefile
  7. +0 −1 actionmailer/actionmailer.gemspec
  8. +0 −2 actionmailer/lib/action_mailer.rb
  9. +0 −28 actionmailer/lib/action_mailer/adv_attr_accessor.rb
  10. +37 −53 actionmailer/lib/action_mailer/base.rb
  11. +1 −1 actionmailer/lib/action_mailer/delivery_methods.rb
  12. +0 −255 actionmailer/lib/action_mailer/old_api.rb
  13. +0 −37 actionmailer/lib/action_mailer/tmail_compat.rb
  14. +2 −2 actionmailer/lib/action_mailer/version.rb
  15. +1 −1 actionmailer/lib/rails/generators/mailer/templates/mailer.rb
  16. +4 −10 actionmailer/test/log_subscriber_test.rb
  17. +0 −41 actionmailer/test/old_base/adv_attr_test.rb
  18. +0 −134 actionmailer/test/old_base/mail_render_test.rb
  19. +0 −1,097 actionmailer/test/old_base/mail_service_test.rb
  20. +0 −42 actionmailer/test/old_base/tmail_compat_test.rb
  21. +67 −2 actionpack/CHANGELOG
  22. +4 −4 actionpack/README.rdoc
  23. +2 −2 actionpack/Rakefile
  24. +6 −6 actionpack/actionpack.gemspec
  25. +1 −1 actionpack/lib/abstract_controller/base.rb
  26. +1 −1 actionpack/lib/abstract_controller/helpers.rb
  27. +10 −8 actionpack/lib/abstract_controller/layouts.rb
  28. +7 −21 actionpack/lib/action_controller.rb
  29. +13 −11 actionpack/lib/action_controller/base.rb
  30. +2 −2 actionpack/lib/action_controller/caching/actions.rb
  31. +2 −3 actionpack/lib/action_controller/caching/fragments.rb
  32. +6 −5 actionpack/lib/action_controller/caching/pages.rb
  33. +1 −0 actionpack/lib/action_controller/caching/sweeping.rb
  34. +5 −4 actionpack/lib/action_controller/log_subscriber.rb
  35. +17 −5 actionpack/lib/action_controller/metal/data_streaming.rb
  36. +3 −3 actionpack/lib/action_controller/metal/force_ssl.rb
  37. +1 −1 actionpack/lib/action_controller/metal/helpers.rb
  38. +5 −5 actionpack/lib/action_controller/metal/http_authentication.rb
  39. +1 −1 actionpack/lib/action_controller/metal/instrumentation.rb
  40. +20 −20 actionpack/lib/action_controller/metal/params_wrapper.rb
  41. +1 −0 actionpack/lib/action_controller/metal/redirecting.rb
  42. +12 −10 actionpack/lib/action_controller/metal/request_forgery_protection.rb
  43. +6 −1 actionpack/lib/action_controller/metal/responder.rb
  44. +5 −39 actionpack/lib/action_controller/metal/streaming.rb
  45. +0 −1 actionpack/lib/action_controller/railtie.rb
  46. +1 −1 actionpack/lib/action_controller/record_identifier.rb
  47. +36 −15 actionpack/lib/action_controller/test_case.rb
  48. +1 −1 actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
  49. +3 −3 actionpack/lib/action_dispatch/http/headers.rb
  50. +2 −2 actionpack/lib/action_dispatch/http/mime_type.rb
  51. +12 −0 actionpack/lib/action_dispatch/http/mime_types.rb
  52. +5 −10 actionpack/lib/action_dispatch/http/request.rb
  53. +2 −24 actionpack/lib/action_dispatch/http/response.rb
  54. +11 −1 actionpack/lib/action_dispatch/http/upload.rb
  55. +1 −2 actionpack/lib/action_dispatch/middleware/callbacks.rb
  56. +23 −7 actionpack/lib/action_dispatch/middleware/cookies.rb
  57. +1 −1 actionpack/lib/action_dispatch/middleware/head.rb
  58. +2 −8 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  59. +1 −0 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
  60. +1 −1 actionpack/lib/action_dispatch/routing.rb
  61. +33 −24 actionpack/lib/action_dispatch/routing/mapper.rb
  62. +3 −1 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
  63. +0 −7 actionpack/lib/action_dispatch/routing/route.rb
  64. +1 −0 actionpack/lib/action_dispatch/routing/route_set.rb
  65. +1 −1 actionpack/lib/action_dispatch/routing/url_for.rb
  66. +6 −7 actionpack/lib/action_dispatch/testing/assertions.rb
  67. +4 −11 actionpack/lib/action_dispatch/testing/assertions/response.rb
  68. +10 −9 actionpack/lib/action_dispatch/testing/assertions/routing.rb
  69. +1 −4 actionpack/lib/action_dispatch/testing/integration.rb
  70. +3 −2 actionpack/lib/action_dispatch/testing/test_process.rb
  71. +4 −23 actionpack/lib/action_dispatch/testing/test_request.rb
  72. +2 −2 actionpack/lib/action_pack/version.rb
  73. +1 −5 actionpack/lib/action_view.rb
  74. +147 −0 actionpack/lib/action_view/asset_paths.rb
  75. +1 −1 actionpack/lib/action_view/base.rb
  76. +2 −2 actionpack/lib/action_view/buffers.rb
  77. +0 −2 actionpack/lib/action_view/helpers.rb
  78. +2 −74 actionpack/lib/action_view/helpers/asset_paths.rb
  79. +10 −16 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  80. +11 −12 actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb
  81. +3 −12 actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
  82. +2 −6 actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
  83. +6 −13 actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
  84. +3 −3 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  85. +4 −0 actionpack/lib/action_view/helpers/cache_helper.rb
  86. +2 −2 actionpack/lib/action_view/helpers/capture_helper.rb
  87. +3 −1 actionpack/lib/action_view/helpers/controller_helper.rb
  88. +7 −8 actionpack/lib/action_view/helpers/date_helper.rb
  89. +1 −1 actionpack/lib/action_view/helpers/debug_helper.rb
  90. +20 −7 actionpack/lib/action_view/helpers/form_helper.rb
  91. +58 −32 actionpack/lib/action_view/helpers/form_options_helper.rb
  92. +8 −5 actionpack/lib/action_view/helpers/form_tag_helper.rb
  93. +2 −1 actionpack/lib/action_view/helpers/javascript_helper.rb
  94. +2 −2 actionpack/lib/action_view/helpers/number_helper.rb
  95. +5 −5 actionpack/lib/action_view/helpers/sanitize_helper.rb
  96. +0 −69 actionpack/lib/action_view/helpers/sprockets_helper.rb
  97. +1 −1 actionpack/lib/action_view/helpers/tag_helper.rb
  98. +6 −4 actionpack/lib/action_view/helpers/text_helper.rb
  99. +1 −1 actionpack/lib/action_view/helpers/translation_helper.rb
  100. +21 −19 actionpack/lib/action_view/helpers/url_helper.rb
  101. +1 −1 actionpack/lib/action_view/log_subscriber.rb
  102. +1 −1 actionpack/lib/action_view/lookup_context.rb
  103. +5 −0 actionpack/lib/action_view/renderer/partial_renderer.rb
  104. +1 −1 actionpack/lib/action_view/renderer/template_renderer.rb
  105. +0 −1 actionpack/lib/action_view/template.rb
  106. +0 −1 actionpack/lib/action_view/template/error.rb
  107. +0 −49 actionpack/lib/action_view/template/handler.rb
  108. +0 −6 actionpack/lib/action_view/template/handlers.rb
  109. +1 −2 actionpack/lib/action_view/template/handlers/erb.rb
  110. +0 −6 actionpack/lib/action_view/test_case.rb
  111. +1 −1 actionpack/lib/action_view/testing/resolvers.rb
  112. +22 −0 actionpack/lib/sprockets/assets.rake
  113. +21 −0 actionpack/lib/sprockets/compressors.rb
  114. +5 −0 actionpack/lib/sprockets/helpers.rb
  115. +136 −0 actionpack/lib/sprockets/helpers/rails_helper.rb
  116. +69 −58 actionpack/lib/sprockets/railtie.rb
  117. +3 −9 actionpack/test/abstract/abstract_controller_test.rb
  118. +1 −1 actionpack/test/abstract/callbacks_test.rb
  119. +0 −12 actionpack/test/abstract/layouts_test.rb
  120. +1 −0 actionpack/test/abstract_unit.rb
  121. +31 −0 actionpack/test/activerecord/active_record_store_test.rb
  122. +26 −0 actionpack/test/activerecord/controller_runtime_test.rb
  123. +8 −0 actionpack/test/activerecord/polymorphic_routes_test.rb
  124. +0 −3 actionpack/test/controller/action_pack_assertions_test.rb
  125. +5 −2 actionpack/test/controller/caching_test.rb
  126. +1 −0 actionpack/test/controller/content_type_test.rb
  127. +0 −26 actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
  128. +5 −0 actionpack/test/controller/filters_test.rb
  129. +1 −1 actionpack/test/controller/helper_test.rb
  130. +6 −0 actionpack/test/controller/integration_test.rb
  131. +22 −3 actionpack/test/controller/log_subscriber_test.rb
  132. +28 −6 actionpack/test/controller/mime_responds_test.rb
  133. +2 −2 actionpack/test/controller/new_base/base_test.rb
  134. +1 −1 actionpack/test/controller/new_base/render_streaming_test.rb
  135. +6 −6 actionpack/test/controller/params_wrapper_test.rb
  136. +1 −6 actionpack/test/controller/render_test.rb
  137. +3 −3 actionpack/test/controller/request_forgery_protection_test.rb
  138. +19 −0 actionpack/test/controller/send_file_test.rb
  139. +19 −3 actionpack/test/controller/test_test.rb
  140. +2 −2 actionpack/test/controller/url_for_test.rb
  141. +1 −7 actionpack/test/controller/view_paths_test.rb
  142. +2 −2 actionpack/test/controller/webservice_test.rb
  143. +76 −22 actionpack/test/dispatch/cookies_test.rb
  144. +4 −4 actionpack/test/dispatch/mime_type_test.rb
  145. +0 −37 actionpack/test/dispatch/response_body_is_proc_test.rb
  146. +1 −1 actionpack/test/dispatch/session/cookie_store_test.rb
  147. +0 −1 actionpack/test/dispatch/session/test_session_test.rb
  148. +23 −6 actionpack/test/dispatch/test_request_test.rb
  149. +7 −0 actionpack/test/dispatch/uploaded_file_test.rb
  150. +1 −0 actionpack/test/fixtures/respond_with/using_resource.js.erb
  151. +1 −0 actionpack/test/fixtures/sprockets/alternate/stylesheets/style.css
  152. +1 −0 actionpack/test/fixtures/sprockets/app/javascripts/application.js
  153. 0 actionpack/test/fixtures/sprockets/app/javascripts/extra.js
  154. +1 −0 actionpack/test/fixtures/sprockets/app/stylesheets/application.css
  155. 0 actionpack/test/fixtures/sprockets/app/stylesheets/extra.css
  156. +1 −0 actionpack/test/fixtures/test/_200.html.erb
  157. +0 −3 actionpack/test/fixtures/test/deprecated_nested_layout.erb
  158. +11 −0 actionpack/test/lib/controller/fake_models.rb
  159. +31 −12 actionpack/test/template/asset_tag_helper_test.rb
  160. +9 −9 actionpack/test/template/atom_feed_helper_test.rb
  161. +10 −0 actionpack/test/template/erb_util_test.rb
  162. +23 −7 actionpack/test/template/form_helper_test.rb
  163. +61 −2 actionpack/test/template/form_options_helper_test.rb
  164. +2 −2 actionpack/test/template/form_tag_helper_test.rb
  165. +2 −2 actionpack/test/template/html-scanner/document_test.rb
  166. +9 −0 actionpack/test/template/javascript_helper_test.rb
  167. +7 −9 actionpack/test/template/number_helper_test.rb
  168. +0 −2 actionpack/test/template/record_tag_helper_test.rb
  169. +11 −2 actionpack/test/template/render_test.rb
  170. +112 −19 actionpack/test/template/sprockets_helper_test.rb
  171. +2 −2 actionpack/test/template/streaming_render_test.rb
  172. +0 −1 actionpack/test/template/template_test.rb
  173. +4 −16 actionpack/test/template/test_case_test.rb
  174. +11 −4 actionpack/test/template/text_helper_test.rb
  175. +8 −0 actionpack/test/template/translation_helper_test.rb
  176. +23 −2 actionpack/test/template/url_helper_test.rb
  177. +5 −0 activemodel/CHANGELOG
  178. +2 −2 activemodel/Rakefile
  179. +1 −2 activemodel/activemodel.gemspec
  180. +27 −6 activemodel/lib/active_model/attribute_methods.rb
  181. +1 −1 activemodel/lib/active_model/callbacks.rb
  182. +1 −1 activemodel/lib/active_model/dirty.rb
  183. +4 −4 activemodel/lib/active_model/errors.rb
  184. +38 −12 activemodel/lib/active_model/mass_assignment_security.rb
  185. +4 −4 activemodel/lib/active_model/mass_assignment_security/permission_set.rb
  186. +37 −6 activemodel/lib/active_model/mass_assignment_security/sanitizer.rb
  187. +3 −2 activemodel/lib/active_model/naming.rb
  188. +3 −3 activemodel/lib/active_model/observer_array.rb
  189. +2 −4 activemodel/lib/active_model/observing.rb
  190. +1 −1 activemodel/lib/active_model/secure_password.rb
  191. +38 −10 activemodel/lib/active_model/serialization.rb
  192. +27 −15 activemodel/lib/active_model/serializers/json.rb
  193. +44 −4 activemodel/lib/active_model/serializers/xml.rb
  194. +1 −1 activemodel/lib/active_model/validations.rb
  195. +1 −1 activemodel/lib/active_model/validations/acceptance.rb
  196. +1 −1 activemodel/lib/active_model/validations/confirmation.rb
  197. +3 −3 activemodel/lib/active_model/validations/exclusion.rb
  198. +2 −2 activemodel/lib/active_model/validations/format.rb
  199. +3 −3 activemodel/lib/active_model/validations/inclusion.rb
  200. +6 −6 activemodel/lib/active_model/validations/length.rb
  201. +2 −2 activemodel/lib/active_model/validations/numericality.rb
  202. +2 −2 activemodel/lib/active_model/version.rb
  203. +0 −1 activemodel/test/cases/attribute_methods_test.rb
  204. +9 −0 activemodel/test/cases/dirty_test.rb
  205. +0 −1 activemodel/test/cases/helper.rb
  206. +0 −8 activemodel/test/cases/mass_assignment_security/black_list_test.rb
  207. +16 −11 activemodel/test/cases/mass_assignment_security/sanitizer_test.rb
  208. +0 −9 activemodel/test/cases/mass_assignment_security/white_list_test.rb
  209. +34 −0 activemodel/test/cases/mass_assignment_security_test.rb
  210. +38 −1 activemodel/test/cases/naming_test.rb
  211. +82 −6 activemodel/test/cases/serialization_test.rb
  212. +52 −1 activemodel/test/cases/serializers/json_serialization_test.rb
  213. +50 −2 activemodel/test/cases/serializers/xml_serialization_test.rb
  214. +9 −1 activemodel/test/models/mass_assignment_specific.rb
  215. +34 −1 activerecord/CHANGELOG
  216. +10 −10 activerecord/README.rdoc
  217. +24 −28 activerecord/RUNNING_UNIT_TESTS
  218. +28 −19 activerecord/Rakefile
  219. +3 −4 activerecord/activerecord.gemspec
  220. +1 −1 activerecord/lib/active_record/aggregations.rb
  221. +63 −66 activerecord/lib/active_record/associations.rb
  222. +12 −24 activerecord/lib/active_record/associations/alias_tracker.rb
  223. +21 −10 activerecord/lib/active_record/associations/association.rb
  224. +16 −6 activerecord/lib/active_record/associations/association_scope.rb
  225. +1 −1 activerecord/lib/active_record/associations/belongs_to_association.rb
  226. +1 −1 activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
  227. +10 −16 activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
  228. +0 −13 activerecord/lib/active_record/associations/builder/singular_association.rb
  229. +79 −57 activerecord/lib/active_record/associations/collection_association.rb
  230. +7 −13 activerecord/lib/active_record/associations/collection_proxy.rb
  231. +8 −2 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  232. +8 −3 activerecord/lib/active_record/associations/has_many_association.rb
  233. +9 −4 activerecord/lib/active_record/associations/has_many_through_association.rb
  234. +2 −2 activerecord/lib/active_record/associations/has_one_association.rb
  235. +7 −3 activerecord/lib/active_record/associations/join_dependency/join_association.rb
  236. +1 −2 activerecord/lib/active_record/associations/join_helper.rb
  237. +3 −2 activerecord/lib/active_record/associations/preloader/association.rb
  238. +12 −4 activerecord/lib/active_record/associations/singular_association.rb
  239. +1 −1 activerecord/lib/active_record/associations/through_association.rb
  240. +1 −1 activerecord/lib/active_record/attribute_methods.rb
  241. +2 −2 activerecord/lib/active_record/attribute_methods/primary_key.rb
  242. +4 −3 activerecord/lib/active_record/attribute_methods/read.rb
  243. +2 −2 activerecord/lib/active_record/autosave_association.rb
  244. +109 −66 activerecord/lib/active_record/base.rb
  245. +20 −2 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  246. +4 −31 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  247. +6 −6 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  248. +10 −10 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  249. +3 −1 activerecord/lib/active_record/connection_adapters/column.rb
  250. +3 −25 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
  251. +4 −27 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  252. +88 −55 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  253. +5 −2 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  254. +1 −1 activerecord/lib/active_record/counter_cache.rb
  255. +1 −1 activerecord/lib/active_record/errors.rb
  256. +25 −70 activerecord/lib/active_record/fixtures.rb
  257. +55 −0 activerecord/lib/active_record/fixtures/file.rb
  258. +1 −1 activerecord/lib/active_record/locking/optimistic.rb
  259. +1 −1 activerecord/lib/active_record/locking/pessimistic.rb
  260. +10 −8 activerecord/lib/active_record/migration.rb
  261. +15 −13 activerecord/lib/active_record/migration/command_recorder.rb
  262. +20 −1 activerecord/lib/active_record/named_scope.rb
  263. +17 −11 activerecord/lib/active_record/nested_attributes.rb
  264. +1 −1 activerecord/lib/active_record/observer.rb
  265. +16 −5 activerecord/lib/active_record/persistence.rb
  266. +8 −0 activerecord/lib/active_record/query_cache.rb
  267. +2 −2 activerecord/lib/active_record/railtie.rb
  268. +3 −1 activerecord/lib/active_record/railties/controller_runtime.rb
  269. +21 −17 activerecord/lib/active_record/railties/databases.rake
  270. +25 −38 activerecord/lib/active_record/reflection.rb
  271. +43 −25 activerecord/lib/active_record/relation.rb
  272. +5 −4 activerecord/lib/active_record/relation/batches.rb
  273. +19 −9 activerecord/lib/active_record/relation/calculations.rb
  274. +7 −6 activerecord/lib/active_record/relation/finder_methods.rb
  275. +23 −15 activerecord/lib/active_record/relation/query_methods.rb
  276. +1 −1 activerecord/lib/active_record/relation/spawn_methods.rb
  277. +1 −1 activerecord/lib/active_record/result.rb
  278. +1 −1 activerecord/lib/active_record/schema_dumper.rb
  279. +1 −43 activerecord/lib/active_record/serialization.rb
  280. +1 −43 activerecord/lib/active_record/serializers/xml_serializer.rb
  281. +28 −18 activerecord/lib/active_record/session_store.rb
  282. +11 −8 activerecord/lib/active_record/test_case.rb
  283. +1 −1 activerecord/lib/active_record/transactions.rb
  284. +1 −1 activerecord/lib/active_record/validations.rb
  285. +2 −2 activerecord/lib/active_record/validations/associated.rb
  286. +2 −2 activerecord/lib/active_record/validations/uniqueness.rb
  287. +2 −2 activerecord/lib/active_record/version.rb
  288. +1 −1 activerecord/lib/rails/generators/active_record/model/templates/migration.rb
  289. +1 −5 activerecord/lib/rails/generators/active_record/session_migration/templates/migration.rb
  290. +1 −0 activerecord/test/.gitignore
  291. +21 −2 activerecord/test/cases/adapter_test.rb
  292. +1 −1 activerecord/test/cases/adapters/firebird/migration_test.rb
  293. +0 −1 activerecord/test/cases/adapters/mysql/quoting_test.rb
  294. +2 −2 activerecord/test/cases/adapters/mysql2/reserved_word_test.rb
  295. +69 −0 activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
  296. +95 −3 activerecord/test/cases/adapters/postgresql/schema_test.rb
  297. +30 −0 activerecord/test/cases/adapters/postgresql/timestamp_test.rb
  298. +49 −0 activerecord/test/cases/adapters/postgresql/view_test.rb
  299. +43 −0 activerecord/test/cases/associations/belongs_to_associations_test.rb
  300. +3 −7 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
Sorry, we could not display the entire diff because too many files (676) changed.
View
31 Gemfile
@@ -1,17 +1,20 @@
-source 'http://rubygems.org'
+source "http://rubygems.org"
gemspec
if ENV['AREL']
gem "arel", :path => ENV['AREL']
else
- gem "arel", '~> 2.1.0'
+ gem "arel", '~> 2.1.3'
end
+gem "jquery-rails"
gem "coffee-script"
gem "sass"
-gem "uglifier", :git => "git://github.com/lautis/uglifier.git"
-gem "rack", :git => "git://github.com/rack/rack.git"
+
+# This needs to be with require false to avoid
+# it being automatically loaded by sprockets
+gem "uglifier", ">= 1.0.0", :require => false
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
@@ -20,6 +23,7 @@ group :doc do
gem "rdoc", "~> 3.4"
gem "horo", "= 1.0.3"
gem "RedCloth", "~> 4.2" if RUBY_VERSION < "1.9.3"
+ gem "w3c_validators"
end
# AS
@@ -33,27 +37,28 @@ end
platforms :mri_19 do
# TODO: Remove the conditional when ruby-debug19 supports Ruby >= 1.9.3
- gem "ruby-debug19", :require => 'ruby-debug' if RUBY_VERSION < "1.9.3"
+ gem "ruby-debug19", :require => "ruby-debug" if RUBY_VERSION < "1.9.3"
end
platforms :ruby do
if ENV["RB_FSEVENT"]
- gem 'rb-fsevent'
+ gem "rb-fsevent"
end
- gem 'json'
- gem 'yajl-ruby'
- gem "nokogiri", ">= 1.4.4"
+ gem "json"
+ gem "yajl-ruby"
+ gem "nokogiri", ">= 1.4.5"
group :test do
- gem 'ruby-prof'
+ gem "ruby-prof" if RUBY_VERSION < "1.9.3"
+
end
# AR
gem "sqlite3", "~> 1.3.3"
group :db do
gem "pg", ">= 0.11.0"
gem "mysql", ">= 2.8.1"
- gem "mysql2", ">= 0.3.0"
+ gem "mysql2", ">= 0.3.6"
end
end
@@ -76,10 +81,10 @@ end
# gems that are necessary for ActiveRecord tests with Oracle database
if ENV['ORACLE_ENHANCED_PATH'] || ENV['ORACLE_ENHANCED']
platforms :ruby do
- gem 'ruby-oci8', ">= 2.0.4"
+ gem "ruby-oci8", ">= 2.0.4"
end
if ENV['ORACLE_ENHANCED_PATH']
- gem 'activerecord-oracle_enhanced-adapter', :path => ENV['ORACLE_ENHANCED_PATH']
+ gem "activerecord-oracle_enhanced-adapter", :path => ENV['ORACLE_ENHANCED_PATH']
else
gem "activerecord-oracle_enhanced-adapter", :git => "git://github.com/rsim/oracle-enhanced.git"
end
View
2 RAILS_VERSION
@@ -1 +1 @@
-3.1.0.beta1
+3.2.0.beta
View
56 README.rdoc
@@ -1,30 +1,35 @@
== Welcome to Rails
Rails is a web-application framework that includes everything needed to create
-database-backed web applications according to the Model-View-Control pattern.
-
-This pattern splits the view (also called the presentation) into "dumb"
-templates that are primarily responsible for inserting pre-built data in between
-HTML tags. The model contains the "smart" domain objects (such as Account,
-Product, Person, Post) that holds all the business logic and knows how to
-persist themselves to a database. The controller handles the incoming requests
-(such as Save New Account, Update Product, Show Post) by manipulating the model
-and directing data to the view.
-
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in its
-{README}[link:files/activerecord/README_rdoc.html].
-
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in its
-{README}[link:files/actionpack/README_rdoc.html].
-
+database-backed web applications according to the {Model-View-Controller (MVC)}[http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller] pattern.
+
+Understanding the MVC pattern is key to understanding Rails. MVC divides your application
+into three layers, each with a specific responsibility.
+
+The View layer is composed of "templates" that are responsible for providing
+appropriate representations of your application's resources. Templates
+can come in a variety of formats, but most view templates are HTML with embedded Ruby
+code (.erb files).
+
+The Model layer represents your domain model (such as Account, Product, Person, Post)
+and encapsulates the business logic that is specific to your application. In Rails,
+database-backed model classes are derived from ActiveRecord::Base. ActiveRecord allows
+you to present the data from database rows as objects and embellish these data objects
+with business logic methods. Although most Rails models are backed by a database, models
+can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as
+provided by the ActiveModel module. You can read more about Active Record in its
+{README}[link:blob/master/activerecord/README.rdoc].
+
+The Controller layer is responsible for handling incoming HTTP requests and providing a
+suitable response. Usually this means returning HTML, but Rails controllers can also
+generate XML, JSON, PDFs, mobile-specific views, and more. Controllers manipulate models
+and render view templates in order to generate the appropriate HTTP response.
+
+In Rails, the Controller and View layers are handled together by Action Pack.
+These two layers are bundled in a single package due to their heavy interdependence.
+This is unlike the relationship between the Active Record and Action Pack which are
+independent. Each of these packages can be used independently outside of Rails. You
+can read more about Action Pack in its {README}[link:blob/master/actionpack/README.rdoc].
== Getting Started
@@ -60,9 +65,10 @@ Rails. You can read more about Action Pack in its
== Contributing
We encourage you to contribute to Ruby on Rails! Please check out the {Contributing to Rails
-guide}[http://edgeguides.rubyonrails.org/contributing_to_rails.html] for guidelines about how
+guide}[http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html] for guidelines about how
to proceed. {Join us}[http://contributors.rubyonrails.org]!
== License
Ruby on Rails is released under the MIT license.
+
View
26 Rakefile
@@ -51,9 +51,31 @@ desc "Generate documentation for the Rails framework"
RDoc::Task.new do |rdoc|
RDOC_MAIN = 'RDOC_MAIN.rdoc'
+ # This is a hack.
+ #
+ # Backslashes are needed to prevent RDoc from autolinking "Rails" to the
+ # documentation of the Rails module. On the other hand, as of this
+ # writing README.rdoc is displayed in the front page of the project in
+ # GitHub, where backslashes are shown and look weird.
+ #
+ # The temporary solution is to have a README.rdoc without backslashes for
+ # GitHub, and gsub it to generate the main page of the API.
+ #
+ # Also, relative links in GitHub have to point to blobs, whereas in the API
+ # they need to point to files.
+ #
+ # The idea for the future is to have totally different files, since the
+ # API is no longer a generic entry point to Rails and deserves a
+ # dedicated main page specifically thought as an API entry point.
rdoc.before_running_rdoc do
rdoc_main = File.read('README.rdoc')
- rdoc_main.gsub!(/\b(?=Rails)\b/) { '\\' }
+
+ # The ^(?=\S) assertion prevents code blocks from being processed,
+ # since no autolinking happens there and RDoc displays the backslash
+ # otherwise.
+ rdoc_main.gsub!(/^(?=\S).*?\b(?=Rails)\b/) { "#$&\\" }
+ rdoc_main.gsub!(%r{link:blob/master/(\w+)/README\.rdoc}, "link:files/\\1/README_rdoc.html")
+
File.open(RDOC_MAIN, 'w') do |f|
f.write(rdoc_main)
end
@@ -72,7 +94,7 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include('railties/MIT-LICENSE')
rdoc.rdoc_files.include('railties/README.rdoc')
rdoc.rdoc_files.include('railties/lib/**/*.rb')
- rdoc.rdoc_files.exclude('railties/lib/rails/generators/**/templates/*')
+ rdoc.rdoc_files.exclude('railties/lib/rails/generators/**/templates/**/*.rb')
rdoc.rdoc_files.include('activerecord/README.rdoc')
rdoc.rdoc_files.include('activerecord/CHANGELOG')
View
4 actionmailer/README.rdoc
@@ -102,7 +102,7 @@ Example:
)
if email.has_attachments?
- for attachment in email.attachments
+ email.attachments.each do |attachment|
page.attachments.create({
:file => attachment, :description => email.subject
})
@@ -153,7 +153,7 @@ Action Mailer is released under the MIT license.
API documentation is at
-* http://api.rubyonrails.com
+* http://api.rubyonrails.org
Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
View
4 actionmailer/Rakefile
@@ -1,7 +1,7 @@
#!/usr/bin/env rake
require 'rake/testtask'
require 'rake/packagetask'
-require 'rake/gempackagetask'
+require 'rubygems/package_task'
desc "Default Task"
task :default => [ :test ]
@@ -24,7 +24,7 @@ end
spec = eval(File.read('actionmailer.gemspec'))
-Rake::GemPackageTask.new(spec) do |p|
+Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
View
1 actionmailer/actionmailer.gemspec
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
s.author = 'David Heinemeier Hansson'
s.email = 'david@loudthinking.com'
s.homepage = 'http://www.rubyonrails.org'
- s.rubyforge_project = 'actionmailer'
s.files = Dir['CHANGELOG', 'README.rdoc', 'MIT-LICENSE', 'lib/**/*']
s.require_path = 'lib'
View
2 actionmailer/lib/action_mailer.rb
@@ -40,12 +40,10 @@
module ActionMailer
extend ::ActiveSupport::Autoload
- autoload :AdvAttrAccessor
autoload :Collector
autoload :Base
autoload :DeliveryMethods
autoload :MailHelper
- autoload :OldApi
autoload :TestCase
autoload :TestHelper
end
View
28 actionmailer/lib/action_mailer/adv_attr_accessor.rb
@@ -1,28 +0,0 @@
-module ActionMailer
- module AdvAttrAccessor #:nodoc:
- def adv_attr_accessor(name, deprecation=nil)
- ivar = "@#{name}"
- deprecation ||= "Please pass :#{name} as hash key to mail() instead"
-
- class_eval <<-ACCESSORS, __FILE__, __LINE__ + 1
- def #{name}=(value)
- ActiveSupport::Deprecation.warn "#{name}= is deprecated. #{deprecation}"
- #{ivar} = value
- end
-
- def #{name}(*args)
- raise ArgumentError, "expected 0 or 1 parameters" unless args.length <= 1
- if args.empty?
- ActiveSupport::Deprecation.warn "#{name}() is deprecated and will be removed in future versions."
- #{ivar} if instance_variable_names.include?(#{ivar.inspect})
- else
- ActiveSupport::Deprecation.warn "#{name}(value) is deprecated. #{deprecation}"
- #{ivar} = args.first
- end
- end
- ACCESSORS
-
- self.protected_instance_variables << ivar if self.respond_to?(:protected_instance_variables)
- end
- end
-end
View
90 actionmailer/lib/action_mailer/base.rb
@@ -1,5 +1,4 @@
require 'mail'
-require 'action_mailer/tmail_compat'
require 'action_mailer/collector'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
@@ -23,16 +22,16 @@ module ActionMailer #:nodoc:
#
# Examples:
#
- # class Notifier < ActionMailer::Base
- # default :from => 'no-reply@example.com',
+ # class Notifier < ActionMailer::Base
+ # default :from => 'no-reply@example.com',
# :return_path => 'system@example.com'
#
- # def welcome(recipient)
- # @account = recipient
- # mail(:to => recipient.email_address_with_name,
- # :bcc => ["bcc@example.com", "Order Watcher <watcher@example.com>"])
- # end
- # end
+ # def welcome(recipient)
+ # @account = recipient
+ # mail(:to => recipient.email_address_with_name,
+ # :bcc => ["bcc@example.com", "Order Watcher <watcher@example.com>"])
+ # end
+ # end
#
# Within the mailer method, you have access to the following methods:
#
@@ -58,7 +57,7 @@ module ActionMailer #:nodoc:
# will accept (any valid Email header including optional fields).
#
# The mail method, if not passed a block, will inspect your views and send all the views with
- # the same name as the method, so the above action would send the +welcome.text.plain.erb+ view
+ # the same name as the method, so the above action would send the +welcome.text.erb+ view
# file as well as the +welcome.text.html.erb+ view file in a +multipart/alternative+ email.
#
# If you want to explicitly render only certain templates, pass a block:
@@ -89,7 +88,7 @@ module ActionMailer #:nodoc:
#
# To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same
# name as the method in your mailer model. For example, in the mailer defined above, the template at
- # <tt>app/views/notifier/signup_notification.text.plain.erb</tt> would be used to generate the email.
+ # <tt>app/views/notifier/welcome.text.erb</tt> would be used to generate the email.
#
# Variables defined in the model are accessible as instance variables in the view.
#
@@ -123,21 +122,19 @@ module ActionMailer #:nodoc:
#
# <%= users_url(:host => "example.com") %>
#
- # You want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't
- # make sense to generate relative URLs in email messages.
+ # You should use the <tt>named_route_url</tt> style (which generates absolute URLs) and avoid using the
+ # <tt>named_route_path</tt> style (which generates relative URLs), since clients reading the mail will
+ # have no concept of a current URL from which to determine a relative path.
#
# It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt>
# option as a configuration option in <tt>config/application.rb</tt>:
#
# config.action_mailer.default_url_options = { :host => "example.com" }
#
- # Setting <tt>ActionMailer::Base.default_url_options</tt> directly is now deprecated, use the configuration
- # option mentioned above to set the default host.
- #
- # If you do decide to set a default <tt>:host</tt> for your mailers you want to use the
- # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. This will ensure that absolute URLs are
- # generated because the <tt>url_for</tt> view helper will, by default, generate relative URLs when a
- # <tt>:host</tt> option isn't explicitly provided.
+ # When you decide to set a default <tt>:host</tt> for your mailers, then you need to make sure to use the
+ # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. Since the <tt>url_for</tt> view helper
+ # will generate relative URLs by default when a <tt>:host</tt> option isn't explicitly provided, passing
+ # <tt>:only_path => false</tt> will ensure that absolute URLs are generated.
#
# = Sending mail
#
@@ -152,12 +149,12 @@ module ActionMailer #:nodoc:
#
# = Multipart Emails
#
- # Multipart messages can also be used implicitly because Action Mailer will automatically
- # detect and use multipart templates, where each template is named after the name of the action, followed
- # by the content type. Each such detected template will be added as separate part to the message.
+ # Multipart messages can also be used implicitly because Action Mailer will automatically detect and use
+ # multipart templates, where each template is named after the name of the action, followed by the content
+ # type. Each such detected template will be added as a separate part to the message.
#
# For example, if the following templates exist:
- # * signup_notification.text.plain.erb
+ # * signup_notification.text.erb
# * signup_notification.text.html.erb
# * signup_notification.text.xml.builder
# * signup_notification.text.yaml.erb
@@ -182,7 +179,7 @@ module ActionMailer #:nodoc:
# end
# end
#
- # Which will (if it had both a <tt>welcome.text.plain.erb</tt> and <tt>welcome.text.html.erb</tt>
+ # Which will (if it had both a <tt>welcome.text.erb</tt> and <tt>welcome.text.html.erb</tt>
# template in the view directory), send a complete <tt>multipart/mixed</tt> email with two parts,
# the first part being a <tt>multipart/alternative</tt> with the text and HTML email parts inside,
# and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book
@@ -216,15 +213,15 @@ module ActionMailer #:nodoc:
#
# = Observing and Intercepting Mails
#
- # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to
- # register objects that are called during the mail delivery life cycle.
+ # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to
+ # register classes that are called during the mail delivery life cycle.
#
- # An observer object must implement the <tt>:delivered_email(message)</tt> method which will be
+ # An observer class must implement the <tt>:delivered_email(message)</tt> method which will be
# called once for every email sent after the email has been sent.
#
- # An interceptor object must implement the <tt>:delivering_email(message)</tt> method which will be
+ # An interceptor class must implement the <tt>:delivering_email(message)</tt> method which will be
# called before the email is sent, allowing you to make modifications to the email before it hits
- # the delivery agents. Your object should make any needed modifications directly to the passed
+ # the delivery agents. Your class should make any needed modifications directly to the passed
# in Mail::Message instance.
#
# = Default Hash
@@ -297,9 +294,9 @@ module ActionMailer #:nodoc:
# information and a cryptographic Message Digest 5 algorithm to hash important information)
# * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server
# and starts to use it.
- # * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
- # really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
- # of an OpenSSL verify constant ('none', 'peer', 'client_once','fail_if_no_peer_cert') or directly the
+ # * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
+ # really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
+ # of an OpenSSL verify constant ('none', 'peer', 'client_once','fail_if_no_peer_cert') or directly the
# constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER,...).
#
# * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
@@ -315,29 +312,16 @@ module ActionMailer #:nodoc:
#
# * <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>. Or you may provide a custom delivery method
- # object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to
+ # object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to
# implement for a custom delivery agent.
#
# * <tt>perform_deliveries</tt> - Determines whether emails are actually sent from Action Mailer when you
- # call <tt>.deliver</tt> on an mail message or on an Action Mailer method. This is on by default but can
+ # call <tt>.deliver</tt> on an mail message or on an Action Mailer method. This is on by default but can
# be turned off to aid in functional testing.
#
# * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with
# <tt>delivery_method :test</tt>. Most useful for unit and functional testing.
#
- # * <tt>default_charset</tt> - This is now deprecated, use the +default+ method above to
- # set the default +:charset+.
- #
- # * <tt>default_content_type</tt> - This is now deprecated, use the +default+ method above
- # to set the default +:content_type+.
- #
- # * <tt>default_mime_version</tt> - This is now deprecated, use the +default+ method above
- # to set the default +:mime_version+.
- #
- # * <tt>default_implicit_parts_order</tt> - This is now deprecated, use the +default+ method above
- # to set the default +:parts_order+. Parts Order is used when a message is built implicitly
- # (i.e. multiple parts are assembled from templates which specify the content type in their
- # filenames) this variable controls how the parts are ordered.
class Base < AbstractController::Base
include DeliveryMethods
abstract!
@@ -352,7 +336,6 @@ class Base < AbstractController::Base
self.protected_instance_variables = %w(@_action_has_layout)
helper ActionMailer::MailHelper
- include ActionMailer::OldApi
private_class_method :new #:nodoc:
@@ -383,8 +366,8 @@ def register_observer(observer)
Mail.register_observer(delivery_observer)
end
- # Register an Inteceptor which will be called before mail is sent.
- # Either a class or a string can be passed in as the Observer. If a string is passed in
+ # Register an Interceptor which will be called before mail is sent.
+ # Either a class or a string can be passed in as the Interceptor. If a string is passed in
# it will be <tt>constantize</tt>d.
def register_interceptor(interceptor)
delivery_interceptor = (interceptor.is_a?(String) ? interceptor.constantize : interceptor)
@@ -567,8 +550,8 @@ def attachments
# method.
#
# When a <tt>:return_path</tt> is specified as header, that value will be used as the 'envelope from'
- # address for the Mail message. Setting this is useful when you want delivery notifications
- # sent to a different address than the one in <tt>:from</tt>. Mail will actually use the
+ # address for the Mail message. Setting this is useful when you want delivery notifications
+ # sent to a different address than the one in <tt>:from</tt>. Mail will actually use the
# <tt>:return_path</tt> in preference to the <tt>:sender</tt> in preference to the <tt>:from</tt>
# field for the 'envelope from' value.
#
@@ -750,3 +733,4 @@ def insert_part(container, response, charset) #:nodoc:
ActiveSupport.run_load_hooks(:action_mailer, self)
end
end
+
View
2 actionmailer/lib/action_mailer/delivery_methods.rb
@@ -1,7 +1,7 @@
require 'tmpdir'
module ActionMailer
- # This modules handles everything related to the delivery, from registering new
+ # This module handles everything related to mail delivery, from registering new
# delivery methods to configuring the mail object to be sent.
module DeliveryMethods
extend ActiveSupport::Concern
View
255 actionmailer/lib/action_mailer/old_api.rb
@@ -1,255 +0,0 @@
-require 'active_support/concern'
-require 'active_support/core_ext/object/try'
-require 'active_support/core_ext/object/blank'
-
-module ActionMailer
- module OldApi #:nodoc:
- extend ActiveSupport::Concern
-
- included do
- extend ActionMailer::AdvAttrAccessor
- self.protected_instance_variables.concat %w(@parts @mail_was_called @headers)
-
- # Specify the BCC addresses for the message
- adv_attr_accessor :bcc
-
- # Specify the CC addresses for the message.
- adv_attr_accessor :cc
-
- # Specify the charset to use for the message. This defaults to the
- # +default_charset+ specified for ActionMailer::Base.
- adv_attr_accessor :charset
-
- # Specify the content type for the message. This defaults to <tt>text/plain</tt>
- # in most cases, but can be automatically set in some situations.
- adv_attr_accessor :content_type
-
- # Specify the from address for the message.
- adv_attr_accessor :from
-
- # Specify the address (if different than the "from" address) to direct
- # replies to this message.
- adv_attr_accessor :reply_to
-
- # Specify the order in which parts should be sorted, based on content-type.
- # This defaults to the value for the +default_implicit_parts_order+.
- adv_attr_accessor :implicit_parts_order
-
- # Defaults to "1.0", but may be explicitly given if needed.
- adv_attr_accessor :mime_version
-
- # The recipient addresses for the message, either as a string (for a single
- # address) or an array (for multiple addresses).
- adv_attr_accessor :recipients, "Please pass :to as hash key to mail() instead"
-
- # The date on which the message was sent. If not set (the default), the
- # header will be set by the delivery agent.
- adv_attr_accessor :sent_on, "Please pass :date as hash key to mail() instead"
-
- # Specify the subject of the message.
- adv_attr_accessor :subject
-
- # Specify the template name to use for current message. This is the "base"
- # template name, without the extension or directory, and may be used to
- # have multiple mailer methods share the same template.
- adv_attr_accessor :template, "Please pass :template_name or :template_path as hash key to mail() instead"
-
- # 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
-
- def process(method_name, *args)
- initialize_defaults(method_name)
- super
- unless @mail_was_called
- create_parts
- create_mail
- end
- @_message
- end
-
- # Add a part to a multipart message, with the given content-type. The
- # part itself is yielded to the block so that other properties (charset,
- # body, headers, etc.) can be set on it.
- def part(params)
- ActiveSupport::Deprecation.warn "part() is deprecated and will be removed in future versions. " <<
- "Please pass a block to mail() instead."
- params = {:content_type => params} if String === params
-
- if custom_headers = params.delete(:headers)
- params.merge!(custom_headers)
- end
-
- part = Mail::Part.new(params)
-
- yield part if block_given?
- @parts << part
- end
-
- # Add an attachment to a multipart message. This is simply a part with the
- # content-disposition set to "attachment".
- def attachment(params, &block)
- ActiveSupport::Deprecation.warn "attachment() is deprecated and will be removed in future versions. " <<
- "Please use the attachments[] API instead."
- params = { :content_type => params } if String === params
-
- params[:content] ||= params.delete(:data) || params.delete(:body)
-
- if params[:filename]
- params = normalize_file_hash(params)
- else
- params = normalize_nonfile_hash(params)
- end
-
- part(params, &block)
- end
-
- protected
-
- def normalize_nonfile_hash(params)
- content_disposition = "attachment;"
-
- mime_type = params.delete(:mime_type)
-
- if content_type = params.delete(:content_type)
- content_type = "#{mime_type || content_type};"
- end
-
- params[:body] = params.delete(:data) if params[:data]
-
- { :content_type => content_type,
- :content_disposition => content_disposition }.merge(params)
- end
-
- def normalize_file_hash(params)
- filename = File.basename(params.delete(:filename))
- content_disposition = "attachment; filename=\"#{File.basename(filename)}\""
-
- mime_type = params.delete(:mime_type)
-
- if (content_type = params.delete(:content_type)) && (content_type !~ /filename=/)
- content_type = "#{mime_type || content_type}; filename=\"#{filename}\""
- end
-
- params[:body] = params.delete(:data) if params[:data]
-
- { :content_type => content_type,
- :content_disposition => content_disposition }.merge(params)
- end
-
- def create_mail
- m = @_message
-
- set_fields!({:subject => @subject, :to => @recipients, :from => @from,
- :bcc => @bcc, :cc => @cc, :reply_to => @reply_to}, @charset)
-
- m.mime_version = @mime_version if @mime_version
- m.date = @sent_on.to_time rescue @sent_on if @sent_on
-
- @headers.each { |k, v| m[k] = v }
-
- real_content_type, ctype_attrs = parse_content_type
- main_type, sub_type = split_content_type(real_content_type)
-
- if @parts.size == 1 && @parts.first.parts.empty?
- m.content_type([main_type, sub_type, ctype_attrs])
- m.body = @parts.first.body.encoded
- else
- @parts.each do |p|
- m.add_part(p)
- end
-
- m.body.set_sort_order(@implicit_parts_order)
- m.body.sort_parts!
-
- if real_content_type =~ /multipart/
- ctype_attrs.delete "charset"
- m.content_type([main_type, sub_type, ctype_attrs])
- end
- end
-
- wrap_delivery_behavior!
- m.content_transfer_encoding = '8bit' unless m.body.only_us_ascii?
-
- @_message
- end
-
- # 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 ||= self.class.default[:charset].try(:dup)
- @content_type ||= self.class.default[:content_type].try(:dup)
- @implicit_parts_order ||= self.class.default[:parts_order].try(:dup)
- @mime_version ||= self.class.default[:mime_version].try(:dup)
-
- @cc, @bcc, @reply_to, @subject, @from, @recipients = nil, nil, nil, nil, nil, nil
-
- @mailer_name ||= self.class.mailer_name.dup
- @template ||= method_name
- @mail_was_called = false
-
- @parts ||= []
- @headers ||= {}
- @sent_on ||= Time.now
- @body ||= {}
- end
-
- def create_parts
- if String === @body
- @parts.unshift create_inline_part(@body)
- elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ }
- lookup_context.find_all(@template, [@mailer_name]).each do |template|
- self.formats = template.formats
- @parts << create_inline_part(render(:template => template), template.mime_type)
- end
-
- if @parts.size > 1
- @content_type = "multipart/alternative" if @content_type !~ /^multipart/
- end
-
- # If this is a multipart e-mail add the mime_version if it is not
- # already set.
- @mime_version ||= "1.0" unless @parts.empty?
- end
- end
-
- def create_inline_part(body, mime_type=nil)
- ct = mime_type || "text/plain"
- main_type, sub_type = split_content_type(ct.to_s)
-
- Mail::Part.new(
- :content_type => [main_type, sub_type, {:charset => charset}],
- :content_disposition => "inline",
- :body => body
- )
- end
-
- def set_fields!(headers, charset) #:nodoc:
- m = @_message
- m.charset = charset
- m.subject ||= headers.delete(:subject) if headers[:subject]
- m.to ||= headers.delete(:to) if headers[:to]
- m.from ||= headers.delete(:from) if headers[:from]
- m.cc ||= headers.delete(:cc) if headers[:cc]
- m.bcc ||= headers.delete(:bcc) if headers[:bcc]
- m.reply_to ||= headers.delete(:reply_to) if headers[:reply_to]
- end
-
- def split_content_type(ct)
- ct.to_s.split("/")
- end
-
- def parse_content_type
- if @content_type.blank?
- [ nil, {} ]
- else
- ctype, *attrs = @content_type.split(/;\s*/)
- attrs = Hash[attrs.map { |attr| attr.split(/=/, 2) }]
- [ctype, {"charset" => @charset}.merge!(attrs)]
- end
- end
- end
-end
View
37 actionmailer/lib/action_mailer/tmail_compat.rb
@@ -1,37 +0,0 @@
-module Mail
- class Message
-
- def set_content_type(*args)
- message = 'Message#set_content_type is deprecated, please just call ' <<
- 'Message#content_type with the same arguments'
- ActiveSupport::Deprecation.warn(message, caller[0,2])
- content_type(*args)
- end
-
- alias :old_transfer_encoding :transfer_encoding
- def transfer_encoding(value = nil)
- if value
- message = 'Message#transfer_encoding is deprecated, ' <<
- 'please call Message#content_transfer_encoding with the same arguments'
- ActiveSupport::Deprecation.warn(message, caller[0,2])
- content_transfer_encoding(value)
- else
- old_transfer_encoding
- end
- end
-
- def transfer_encoding=(value)
- message = 'Message#transfer_encoding= is deprecated, ' <<
- 'please call Message#content_transfer_encoding= with the same arguments'
- ActiveSupport::Deprecation.warn(message, caller[0,2])
- self.content_transfer_encoding = value
- end
-
- def original_filename
- message = 'Message#original_filename is deprecated, please call Message#filename'
- ActiveSupport::Deprecation.warn(message, caller[0,2])
- filename
- end
-
- end
-end
View
4 actionmailer/lib/action_mailer/version.rb
@@ -1,9 +1,9 @@
module ActionMailer
module VERSION #:nodoc:
MAJOR = 3
- MINOR = 1
+ MINOR = 2
TINY = 0
- PRE = "beta1"
+ PRE = "beta"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
2 actionmailer/lib/rails/generators/mailer/templates/mailer.rb
@@ -1,7 +1,7 @@
<% module_namespacing do -%>
class <%= class_name %> < ActionMailer::Base
default <%= key_value :from, '"from@example.com"' %>
-<% for action in actions -%>
+<% actions.each do |action| -%>
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
View
14 actionmailer/test/log_subscriber_test.rb
@@ -1,4 +1,5 @@
require "abstract_unit"
+require 'mailers/base_mailer'
require "active_support/log_subscriber/test_helper"
require "action_mailer/log_subscriber"
@@ -11,13 +12,6 @@ def setup
end
class TestMailer < ActionMailer::Base
- def basic
- recipients "somewhere@example.com"
- subject "basic"
- from "basic@example.com"
- body "Hello world"
- end
-
def receive(mail)
# Do nothing
end
@@ -28,12 +22,12 @@ def set_logger(logger)
end
def test_deliver_is_notified
- TestMailer.basic.deliver
+ BaseMailer.welcome.deliver
wait
assert_equal(1, @logger.logged(:info).size)
- assert_match(/Sent mail to somewhere@example.com/, @logger.logged(:info).first)
+ assert_match(/Sent mail to system@test.lindsaar.net/, @logger.logged(:info).first)
assert_equal(1, @logger.logged(:debug).size)
- assert_match(/Hello world/, @logger.logged(:debug).first)
+ assert_match(/Welcome/, @logger.logged(:debug).first)
end
def test_receive_is_notified
View
41 actionmailer/test/old_base/adv_attr_test.rb
@@ -1,41 +0,0 @@
-require 'abstract_unit'
-require 'action_mailer/adv_attr_accessor'
-
-class AdvAttrTest < ActiveSupport::TestCase
- class Person
- cattr_reader :protected_instance_variables
- @@protected_instance_variables = []
-
- extend ActionMailer::AdvAttrAccessor
- adv_attr_accessor :name
- end
-
- def setup
- ActiveSupport::Deprecation.silenced = true
- @person = Person.new
- end
-
- def teardown
- ActiveSupport::Deprecation.silenced = false
- end
-
- def test_adv_attr
- assert_nil @person.name
- @person.name 'Bob'
- assert_equal 'Bob', @person.name
- end
-
- def test_adv_attr_writer
- assert_nil @person.name
- @person.name = 'Bob'
- assert_equal 'Bob', @person.name
- end
-
- def test_raise_an_error_with_multiple_args
- assert_raise(ArgumentError) { @person.name('x', 'y') }
- end
-
- def test_ivar_is_added_to_protected_instnace_variables
- assert Person.protected_instance_variables.include?('@name')
- end
-end
View
134 actionmailer/test/old_base/mail_render_test.rb
@@ -1,134 +0,0 @@
-require 'abstract_unit'
-
-class RenderMailer < ActionMailer::Base
- def inline_template
- recipients 'test@localhost'
- subject "using helpers"
- from "tester@example.com"
-
- @world = "Earth"
- body render(:inline => "Hello, <%= @world %>")
- end
-
- def file_template
- recipients 'test@localhost'
- subject "using helpers"
- from "tester@example.com"
-
- @recipient = 'test@localhost'
- body render(:file => "templates/signed_up")
- end
-
- def no_instance_variable
- recipients 'test@localhost'
- subject "No Instance Variable"
- from "tester@example.com"
-
- silence_warnings do
- body render(:inline => "Look, subject.nil? is <%= @subject.nil? %>!")
- end
- end
-
- def multipart_alternative
- recipients 'test@localhost'
- subject 'multipart/alternative'
- from 'tester@example.com'
-
- build_multipart_message(:foo => "bar")
- end
-
- private
- def build_multipart_message(assigns = {})
- content_type "multipart/alternative"
-
- part "text/plain" do |p|
- p.body = build_body_part('plain', assigns, :layout => false)
- end
-
- part "text/html" do |p|
- p.body = build_body_part('html', assigns)
- end
- end
-
- def build_body_part(content_type, assigns, options = {})
- ActiveSupport::Deprecation.silence do
- render "#{template}.#{content_type}", :body => assigns
- end
- end
-end
-
-class FirstMailer < ActionMailer::Base
- def share
- recipients 'test@localhost'
- subject "using helpers"
- from "tester@example.com"
- end
-end
-
-class SecondMailer < ActionMailer::Base
- def share
- recipients 'test@localhost'
- subject "using helpers"
- from "tester@example.com"
- end
-end
-
-# CHANGED: Those tests were changed because body returns an object now
-# Instead of mail.body.strip, we should mail.body.to_s.strip
-class RenderHelperTest < Test::Unit::TestCase
- def setup
- set_delivery_method :test
- ActionMailer::Base.perform_deliveries = true
- ActionMailer::Base.deliveries.clear
- ActiveSupport::Deprecation.silenced = true
-
- @recipient = 'test@localhost'
- end
-
- def teardown
- ActiveSupport::Deprecation.silenced = false
- restore_delivery_method
- end
-
- def test_inline_template
- mail = RenderMailer.inline_template
- assert_equal "Hello, Earth", mail.body.to_s.strip
- end
-
- def test_file_template
- mail = RenderMailer.file_template
- assert_equal "Hello there,\n\nMr. test@localhost", mail.body.to_s.strip
- end
-
- def test_no_instance_variable
- mail = RenderMailer.no_instance_variable.deliver
- assert_equal "Look, subject.nil? is true!", mail.body.to_s.strip
- end
-end
-
-class FirstSecondHelperTest < Test::Unit::TestCase
- def setup
- set_delivery_method :test
- ActiveSupport::Deprecation.silenced = true
- ActionMailer::Base.perform_deliveries = true
- ActionMailer::Base.deliveries.clear
-
- @recipient = 'test@localhost'
- end
-
- def teardown
- ActiveSupport::Deprecation.silenced = false
- restore_delivery_method
- end
-
- def test_ordering
- mail = FirstMailer.share
- assert_equal "first mail", mail.body.to_s.strip
- mail = SecondMailer.share
- assert_equal "second mail", mail.body.to_s.strip
- mail = FirstMailer.share
- assert_equal "first mail", mail.body.to_s.strip
- mail = SecondMailer.share
- assert_equal "second mail", mail.body.to_s.strip
- end
-end
View
1,097 actionmailer/test/old_base/mail_service_test.rb
@@ -1,1097 +0,0 @@
-# encoding: utf-8
-require 'abstract_unit'
-
-class FunkyPathMailer < ActionMailer::Base
- self.view_paths = "#{File.dirname(__FILE__)}/../fixtures/path.with.dots"
-
- def multipart_with_template_path_with_dots(recipient)
- recipients recipient
- subject "This path has dots"
- from "Chad Fowler <chad@chadfowler.com>"
- attachment :content_type => "text/plain",
- :data => "dots dots dots..."
- end
-end
-
-class TestMailer < ActionMailer::Base
- def signed_up(recipient)
- recipients recipient
- subject "[Signed up] Welcome #{recipient}"
- from "system@loudthinking.com"
-
- @recipient = recipient
- end
-
- def cancelled_account(recipient)
- recipients recipient
- subject "[Cancelled] Goodbye #{recipient}"
- from "system@loudthinking.com"
- sent_on Time.local(2004, 12, 12)
- body "Goodbye, Mr. #{recipient}"
- end
-
- def from_with_name
- from "System <system@loudthinking.com>"
- recipients "root@loudthinking.com"
- body "Nothing to see here."
- end
-
- def from_without_name
- from "system@loudthinking.com"
- recipients "root@loudthinking.com"
- body "Nothing to see here."
- end
-
- def cc_bcc(recipient)
- recipients recipient
- subject "testing bcc/cc"
- from "system@loudthinking.com"
- sent_on Time.local(2004, 12, 12)
- cc "nobody@loudthinking.com"
- bcc "root@loudthinking.com"
-
- body "Nothing to see here."
- end
-
- def different_reply_to(recipient)
- recipients recipient
- subject "testing reply_to"
- from "system@loudthinking.com"
- sent_on Time.local(2008, 5, 23)
- reply_to "atraver@gmail.com"
-
- body "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"
- charset "iso-8859-1"
-
- body "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."
- 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>"
- charset "iso-8859-1"
-
- body "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>"
- charset "UTF-8"
-
- body "åœö blah"
- end
-
- def multipart_with_mime_version(recipient)
- recipients recipient
- subject "multipart with mime_version"
- from "test@example.com"
- sent_on Time.local(2004, 12, 12)
- mime_version "1.1"
- content_type "multipart/alternative"
-
- part "text/plain" do |p|
- p.body = render(:text => "blah")
- end
-
- part "text/html" do |p|
- p.body = render(:inline => "<%= content_tag(:b, 'blah') %>")
- end
- end
-
- def multipart_with_utf8_subject(recipient)
- recipients recipient
- subject "Foo áëô îü"
- from "test@example.com"
- charset "UTF-8"
-
- part "text/plain" do |p|
- p.body = "blah"
- end
-
- part "text/html" do |p|
- p.body = "<b>blah</b>"
- end
- end
-
- def explicitly_multipart_example(recipient, ct=nil)
- recipients recipient
- subject "multipart example"
- from "test@example.com"
- sent_on Time.local(2004, 12, 12)
- content_type ct if ct
-
- part "text/html" do |p|
- p.charset = "iso-8859-1"
- p.body = "blah"
- end
-
- attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "foo.jpg"),
- :data => "123456789"
-
- body "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)
-
- @charset = cs if cs
- @recipient = recipient
- @implicit_parts_order = order if order
- end
-
- def implicitly_multipart_with_utf8
- recipients "no.one@nowhere.test"
- subject "Foo áëô îü"
- from "some.one@somewhere.test"
- template "implicitly_multipart_example"
-
- @recipient = "no.one@nowhere.test"
- end
-
- def html_mail(recipient)
- recipients recipient
- subject "html mail"
- from "test@example.com"
- content_type "text/html"
-
- body "<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>}
- end
-
- def custom_template(recipient)
- recipients recipient
- subject "[Signed up] Welcome #{recipient}"
- from "system@loudthinking.com"
- sent_on Time.local(2004, 12, 12)
- template "signed_up"
-
- @recipient = recipient
- end
-
- def custom_templating_extension(recipient)
- recipients recipient
- subject "[Signed up] Welcome #{recipient}"
- from "system@loudthinking.com"
- sent_on Time.local(2004, 12, 12)
-
- @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"
- end
-
- def various_newlines_multipart(recipient)
- recipients 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
-
- def nested_multipart(recipient)
- recipients recipient
- subject "nested multipart"
- from "test@example.com"
- content_type "multipart/mixed"
-
- part :content_type => "multipart/alternative", :content_disposition => "inline", "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", :data => "test abcdefghijklmnopqstuvwxyz"
- end
-
- def nested_multipart_with_body(recipient)
- recipients 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
- end
-
- def attachment_with_custom_header(recipient)
- recipients recipient
- subject "custom header in attachment"
- from "test@example.com"
- content_type "multipart/related"
- part :content_type => "text/html", :body => 'yo'
- attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "test.jpg"), :data => "i am not a real picture", 'Content-ID' => '<test@test.com>'
- end
-
- def unnamed_attachment(recipient)
- recipients recipient
- subject "nested multipart"
- from "test@example.com"
- content_type "multipart/mixed"
- part :content_type => "text/plain", :body => "hullo"
- attachment :content_type => "application/octet-stream", :data => "test abcdefghijklmnopqstuvwxyz"
- end
-
- def headers_with_nonalpha_chars(recipient)
- recipients recipient
- subject "nonalpha chars"
- from "One: Two <test@example.com>"
- cc "Three: Four <test@example.com>"
- bcc "Five: Six <test@example.com>"
- body "testing"
- end
-
- def custom_content_type_attributes
- recipients "no.one@nowhere.test"
- subject "custom content types"
- from "some.one@somewhere.test"
- content_type "text/plain; format=flowed"
- body "testing"
- end
-
- def return_path
- recipients "no.one@nowhere.test"
- subject "return path test"
- from "some.one@somewhere.test"
- headers["return-path"] = "another@somewhere.test"
- body "testing"
- end
-
- def subject_with_i18n(recipient)
- recipients recipient
- from "system@loudthinking.com"
- body "testing"
- end
-
- class << self
- attr_accessor :received_body
- end
-
- def receive(mail)
- self.class.received_body = mail.body
- end
-end
-
-class ActionMailerTest < Test::Unit::TestCase
-
- def encode( text, charset="UTF-8" )
- Mail::Encodings.q_value_encode( text, charset )
- end
-
- def new_mail( charset="UTF-8" )
- mail = Mail.new
- mail.charset = charset
- mail.mime_version = "1.0"
- mail
- end
-
- def setup
- set_delivery_method :test
- ActionMailer::Base.perform_deliveries = true
- ActionMailer::Base.raise_delivery_errors = true
- ActionMailer::Base.deliveries.clear
- ActiveSupport::Deprecation.silenced = true
-
- @recipient = 'test@localhost'
-
- TestMailer.delivery_method = :test
- end
-
- def teardown
- ActiveSupport::Deprecation.silenced = false
- restore_delivery_method
- end
-
- def test_nested_parts
- created = nil
- assert_nothing_raised { created = TestMailer.nested_multipart(@recipient)}
- assert_equal 2, created.parts.size
- assert_equal 2, created.parts.first.parts.size
-
- assert_equal "multipart/mixed", created.mime_type
- assert_equal "multipart/alternative", created.parts[0].mime_type
- assert_equal "bar", created.parts[0].header['foo'].to_s
- assert_not_nil created.parts[0].charset
- assert_equal "text/plain", created.parts[0].parts[0].mime_type
- assert_equal "text/html", created.parts[0].parts[1].mime_type
- assert_equal "application/octet-stream", created.parts[1].mime_type
-
- end
-
- def test_nested_parts_with_body
- created = nil
- TestMailer.nested_multipart_with_body(@recipient)
- assert_nothing_raised { created = TestMailer.nested_multipart_with_body(@recipient)}
-
- assert_equal 1,created.parts.size
- assert_equal 2,created.parts.first.parts.size
-
- assert_equal "multipart/mixed", created.mime_type
- assert_equal "multipart/alternative", created.parts.first.mime_type
- assert_equal "text/plain", created.parts.first.parts.first.mime_type
- assert_equal "Nothing to see here.", created.parts.first.parts.first.body.to_s
- assert_equal "text/html", created.parts.first.parts.second.mime_type
- assert_equal "<b>test</b> HTML<br/>", created.parts.first.parts.second.body.to_s
- end
-
- def test_attachment_with_custom_header
- created = nil
- assert_nothing_raised { created = TestMailer.attachment_with_custom_header(@recipient) }
- assert created.parts.any? { |p| p.header['content-id'].to_s == "<test@test.com>" }
- end
-
- def test_signed_up
- TestMailer.delivery_method = :test
-
- Time.stubs(:now => Time.now)
-
- expected = new_mail
- expected.to = @recipient
- expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there,\n\nMr. #{@recipient}"
- expected.from = "system@loudthinking.com"
- expected.date = Time.now
-
- created = nil
- assert_nothing_raised { created = TestMailer.signed_up(@recipient) }
- assert_not_nil created
-
- expected.message_id = '<123@456>'
- created.message_id = '<123@456>'
-
- assert_equal expected.encoded, created.encoded
-
- assert_nothing_raised { TestMailer.signed_up(@recipient).deliver }
-
- delivered = ActionMailer::Base.deliveries.first
- assert_not_nil delivered
-
- expected.message_id = '<123@456>'
- delivered.message_id = '<123@456>'
-
- assert_equal expected.encoded, delivered.encoded
- end
-
- def test_custom_template
- expected = new_mail
- expected.to = @recipient
- expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there,\n\nMr. #{@recipient}"
- expected.from = "system@loudthinking.com"
- expected.date = Time.local(2004, 12, 12)
-
- created = nil
- assert_nothing_raised { created = TestMailer.custom_template(@recipient) }
- assert_not_nil created
- expected.message_id = '<123@456>'
- created.message_id = '<123@456>'
- assert_equal expected.encoded, created.encoded
- end
-
- def test_custom_templating_extension
- assert ActionView::Template.template_handler_extensions.include?("haml"), "haml extension was not registered"
-
- # N.b., custom_templating_extension.text.plain.haml is expected to be in fixtures/test_mailer directory
- expected = new_mail
- expected.to = @recipient
- expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there, \n\nMr. #{@recipient}"
- expected.from = "system@loudthinking.com"
- expected.date = Time.local(2004, 12, 12)
-
- # Now that the template is registered, there should be one part. The text/plain part.
- created = nil
- assert_nothing_raised { created = TestMailer.custom_templating_extension(@recipient) }
- assert_not_nil created
- assert_equal 2, created.parts.length
- assert_equal 'text/plain', created.parts[0].mime_type
- assert_equal 'text/html', created.parts[1].mime_type
- end
-
- def test_cancelled_account
- expected = new_mail
- expected.to = @recipient
- expected.subject = "[Cancelled] Goodbye #{@recipient}"
- expected.body = "Goodbye, Mr. #{@recipient}"
- expected.from = "system@loudthinking.com"
- expected.date = Time.local(2004, 12, 12)
-
- created = nil
- assert_nothing_raised { created = TestMailer.cancelled_account(@recipient) }
- assert_not_nil created
- expected.message_id = '<123@456>'
- created.message_id = '<123@456>'
- assert_equal expected.encoded, created.encoded
-
- assert_nothing_raised { TestMailer.cancelled_account(@recipient).deliver }
- assert_not_nil ActionMailer::Base.deliveries.first
- delivered = ActionMailer::Base.deliveries.first
- expected.message_id = '<123@456>'
- delivered.message_id = '<123@456>'
-
- assert_equal expected.encoded, delivered.encoded
- end
-
- def test_cc_bcc
- expected = new_mail
- expected.to = @recipient
- expected.subject = "testing bcc/cc"
- expected.body = "Nothing to see here."
- expected.from = "system@loudthinking.com"
- expected.cc = "nobody@loudthinking.com"
- expected.bcc = "root@loudthinking.com"
- expected.date = Time.local 2004, 12, 12
-
- created = nil
- assert_nothing_raised do
- created = TestMailer.cc_bcc @recipient
- end
- assert_not_nil created
- expected.message_id = '<123@456>'
- created.message_id = '<123@456>'
- assert_equal expected.encoded, created.encoded
-
- assert_nothing_raised do
- TestMailer.cc_bcc(@recipient).deliver
- end
-
- assert_not_nil ActionMailer::Base.deliveries.first
- delivered = ActionMailer::Base.deliveries.first