Permalink
Browse files

Merge branch 'master' of git@github.com:rails/rails

  • Loading branch information...
2 parents 0aef9d1 + a3b7fa7 commit 22e830f883af0b56de81186c184751b6398d0141 @technoweenie technoweenie committed Sep 20, 2008
Showing with 10,347 additions and 5,055 deletions.
  1. +5 −0 actionmailer/CHANGELOG
  2. +39 −8 actionmailer/lib/action_mailer/base.rb
  3. +2 −2 actionmailer/lib/action_mailer/helpers.rb
  4. +1 −0 actionmailer/test/fixtures/auto_layout_mailer/hello.html.erb
  5. +1 −0 actionmailer/test/fixtures/explicit_layout_mailer/logout.html.erb
  6. +1 −0 actionmailer/test/fixtures/explicit_layout_mailer/signup.html.erb
  7. +1 −0 actionmailer/test/fixtures/layouts/auto_layout_mailer.html.erb
  8. +1 −0 actionmailer/test/fixtures/layouts/spam.html.erb
  9. +10 −0 actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb~
  10. +78 −0 actionmailer/test/mail_layout_test.rb
  11. +52 −0 actionmailer/test/mail_service_test.rb
  12. +46 −0 actionpack/CHANGELOG
  13. +8 −6 actionpack/Rakefile
  14. +2 −0 actionpack/lib/action_controller.rb
  15. +14 −14 actionpack/lib/action_controller/assertions/routing_assertions.rb
  16. +33 −53 actionpack/lib/action_controller/assertions/selector_assertions.rb
  17. +38 −68 actionpack/lib/action_controller/base.rb
  18. +37 −24 actionpack/lib/action_controller/benchmarking.rb
  19. +4 −4 actionpack/lib/action_controller/caching/actions.rb
  20. +3 −3 actionpack/lib/action_controller/caching/sweeping.rb
  21. +5 −4 actionpack/lib/action_controller/cgi_process.rb
  22. +4 −1 actionpack/lib/action_controller/components.rb
  23. +4 −4 actionpack/lib/action_controller/filters.rb
  24. +2 −2 actionpack/lib/action_controller/helpers.rb
  25. +1 −1 actionpack/lib/action_controller/http_authentication.rb
  26. +4 −4 actionpack/lib/action_controller/integration.rb
  27. +27 −53 actionpack/lib/action_controller/layout.rb
  28. +2 −0 actionpack/lib/action_controller/mime_type.rb
  29. +3 −3 actionpack/lib/action_controller/polymorphic_routes.rb
  30. +2 −1 actionpack/lib/action_controller/rack_process.rb
  31. +42 −35 actionpack/lib/action_controller/request.rb
  32. +1 −4 actionpack/lib/action_controller/rescue.rb
  33. +102 −48 actionpack/lib/action_controller/resources.rb
  34. +1 −1 actionpack/lib/action_controller/response.rb
  35. +7 −5 actionpack/lib/action_controller/routing/builder.rb
  36. +3 −2 actionpack/lib/action_controller/routing/optimisations.rb
  37. +22 −0 actionpack/lib/action_controller/routing/recognition_optimisation.rb
  38. +1 −1 actionpack/lib/action_controller/routing/route.rb
  39. +5 −5 actionpack/lib/action_controller/routing/route_set.rb
  40. +3 −3 actionpack/lib/action_controller/routing/segments.rb
  41. +2 −1 actionpack/lib/action_controller/session/cookie_store.rb
  42. +6 −2 actionpack/lib/action_controller/session_management.rb
  43. +13 −6 actionpack/lib/action_controller/test_process.rb
  44. +13 −0 actionpack/lib/action_controller/translation.rb
  45. +2 −2 actionpack/lib/action_controller/verification.rb
  46. +1 −3 actionpack/lib/action_view.rb
  47. +113 −79 actionpack/lib/action_view/base.rb
  48. +0 −1 actionpack/lib/action_view/helpers.rb
  49. +6 −6 actionpack/lib/action_view/helpers/active_record_helper.rb
  50. +18 −16 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  51. +3 −3 actionpack/lib/action_view/helpers/benchmark_helper.rb
  52. +0 −92 actionpack/lib/action_view/helpers/form_country_helper.rb
  53. +0 −3 actionpack/lib/action_view/helpers/form_options_helper.rb
  54. +19 −12 actionpack/lib/action_view/helpers/form_tag_helper.rb
  55. +12 −22 actionpack/lib/action_view/helpers/prototype_helper.rb
  56. +3 −3 actionpack/lib/action_view/helpers/record_tag_helper.rb
  57. +10 −1 actionpack/lib/action_view/helpers/sanitize_helper.rb
  58. +1 −1 actionpack/lib/action_view/helpers/scriptaculous_helper.rb
  59. +51 −5 actionpack/lib/action_view/helpers/text_helper.rb
  60. +1 −1 actionpack/lib/action_view/partials.rb
  61. +12 −15 actionpack/lib/action_view/renderable.rb
  62. +19 −7 actionpack/lib/action_view/renderable_partial.rb
  63. +2 −0 actionpack/lib/action_view/template.rb
  64. +1 −1 actionpack/lib/action_view/template_handlers/builder.rb
  65. +1 −1 actionpack/lib/action_view/test_case.rb
  66. +49 −0 actionpack/test/controller/assert_select_test.rb
  67. +4 −4 actionpack/test/controller/base_test.rb
  68. +41 −25 actionpack/test/controller/components_test.rb
  69. +2 −2 actionpack/test/controller/filter_params_test.rb
  70. +13 −13 actionpack/test/controller/filters_test.rb
  71. +1 −1 actionpack/test/controller/integration_test.rb
  72. +0 −49 actionpack/test/controller/layout_test.rb
  73. +0 −981 actionpack/test/controller/new_render_test.rb
  74. +871 −27 actionpack/test/controller/render_test.rb
  75. +3 −0 actionpack/test/controller/request_test.rb
  76. +122 −25 actionpack/test/controller/resources_test.rb
  77. +59 −0 actionpack/test/controller/routing_test.rb
  78. +52 −1 actionpack/test/controller/session/cookie_store_test.rb
  79. +5 −0 actionpack/test/controller/test_test.rb
  80. +26 −0 actionpack/test/controller/translation_test.rb
  81. +0 −1,549 actionpack/test/template/form_country_helper_test.rb
  82. +9 −2 actionpack/test/template/form_tag_helper_test.rb
  83. +15 −0 actionpack/test/template/prototype_helper_test.rb
  84. +8 −0 actionpack/test/template/record_tag_helper_test.rb
  85. +34 −0 actionpack/test/template/text_helper_test.rb
  86. +3 −3 activemodel/lib/active_model/state_machine/event.rb
  87. +1 −1 activemodel/lib/active_model/validations.rb
  88. +1 −1 activemodel/lib/active_model/validations/exclusion.rb
  89. +1 −1 activemodel/lib/active_model/validations/inclusion.rb
  90. +4 −4 activemodel/lib/active_model/validations/uniqueness.rb
  91. +16 −18 activerecord/CHANGELOG
  92. +2 −4 activerecord/lib/active_record.rb
  93. +108 −36 activerecord/lib/active_record/aggregations.rb
  94. +8 −5 activerecord/lib/active_record/association_preload.rb
  95. +93 −79 activerecord/lib/active_record/associations.rb
  96. +66 −13 activerecord/lib/active_record/associations/association_collection.rb
  97. +49 −12 activerecord/lib/active_record/associations/association_proxy.rb
  98. +2 −2 activerecord/lib/active_record/associations/belongs_to_association.rb
  99. +10 −0 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  100. +17 −17 activerecord/lib/active_record/associations/has_many_association.rb
  101. +5 −14 activerecord/lib/active_record/associations/has_many_through_association.rb
  102. +12 −4 activerecord/lib/active_record/associations/has_one_association.rb
  103. +4 −0 activerecord/lib/active_record/associations/has_one_through_association.rb
  104. +4 −4 activerecord/lib/active_record/attribute_methods.rb
  105. +99 −62 activerecord/lib/active_record/base.rb
  106. +19 −6 activerecord/lib/active_record/calculations.rb
  107. +8 −2 activerecord/lib/active_record/callbacks.rb
  108. +278 −0 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  109. +42 −215 activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
  110. +4 −0 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  111. +29 −14 activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  112. +40 −2 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  113. +20 −11 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  114. +22 −1 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  115. +40 −1 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  116. +23 −2 activerecord/lib/active_record/dirty.rb
  117. +2 −1 activerecord/lib/active_record/dynamic_finder_match.rb
  118. +1 −1 activerecord/lib/active_record/fixtures.rb
  119. +26 −0 activerecord/lib/active_record/i18n_interpolation_deprecation.rb
  120. +25 −4 activerecord/lib/active_record/locale/en-US.yml
  121. +19 −15 activerecord/lib/active_record/named_scope.rb
  122. +35 −0 activerecord/lib/active_record/reflection.rb
  123. +1 −1 activerecord/lib/active_record/schema_dumper.rb
  124. +15 −0 activerecord/lib/active_record/test_case.rb
  125. +1 −1 activerecord/lib/active_record/transactions.rb
  126. +62 −48 activerecord/lib/active_record/validations.rb
  127. +39 −0 activerecord/test/cases/aggregations_test.rb
  128. +13 −0 activerecord/test/cases/associations/belongs_to_associations_test.rb
  129. +44 −9 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  130. +36 −7 activerecord/test/cases/associations/has_many_associations_test.rb
  131. +24 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  132. +9 −0 activerecord/test/cases/associations/has_one_through_associations_test.rb
  133. +18 −106 activerecord/test/cases/associations_test.rb
  134. +9 −0 activerecord/test/cases/attribute_methods_test.rb
  135. +34 −5 activerecord/test/cases/base_test.rb
  136. +1 −1 activerecord/test/cases/connection_test_mysql.rb
  137. +31 −0 activerecord/test/cases/defaults_test.rb
  138. +49 −0 activerecord/test/cases/dirty_test.rb
  139. +52 −6 activerecord/test/cases/finder_test.rb
  140. +14 −0 activerecord/test/cases/helper.rb
  141. +7 −12 activerecord/test/cases/i18n_test.rb
  142. +1 −1 activerecord/test/cases/inheritance_test.rb
  143. +2 −7 activerecord/test/cases/locking_test.rb
  144. +79 −2 activerecord/test/cases/method_scoping_test.rb
  145. +5 −1 activerecord/test/cases/migration_test.rb
  146. +19 −0 activerecord/test/cases/named_scope_test.rb
  147. +87 −0 activerecord/test/cases/pooled_connections_test.rb
  148. +2 −2 activerecord/test/cases/reflection_test.rb
  149. +25 −0 activerecord/test/cases/sanitize_test.rb
  150. +2 −2 activerecord/test/cases/schema_authorization_test_postgresql.rb
  151. +0 −48 activerecord/test/cases/threaded_connections_test.rb
  152. +2 −10 activerecord/test/cases/transactions_test.rb
  153. +64 −1 activerecord/test/cases/validations_i18n_test.rb
  154. +48 −29 activerecord/test/cases/validations_test.rb
  155. +10 −1 activerecord/test/fixtures/customers.yml
  156. +2 −1 activerecord/test/models/author.rb
  157. +3 −0 activerecord/test/models/category.rb
  158. +2 −0 activerecord/test/models/company.rb
  159. +19 −1 activerecord/test/models/customer.rb
  160. +1 −0 activerecord/test/models/parrot.rb
  161. +0 −6 activerecord/test/models/post.rb
  162. +57 −46 activeresource/lib/active_resource/base.rb
  163. +18 −7 activeresource/lib/active_resource/connection.rb
  164. +12 −11 activeresource/lib/active_resource/custom_methods.rb
  165. +6 −6 activeresource/lib/active_resource/formats/json_format.rb
  166. +9 −9 activeresource/lib/active_resource/formats/xml_format.rb
  167. +1 −1 activeresource/lib/active_resource/http_mock.rb
  168. +15 −29 activeresource/lib/active_resource/validations.rb
  169. +8 −8 activeresource/test/authorization_test.rb
  170. +1 −2 activeresource/test/base/custom_methods_test.rb
  171. +2 −2 activeresource/test/base/load_test.rb
  172. +5 −5 activeresource/test/base_test.rb
  173. +11 −3 activeresource/test/connection_test.rb
  174. +23 −11 activeresource/test/format_test.rb
  175. +12 −0 activesupport/CHANGELOG
  176. +3 −4 activesupport/lib/active_support.rb
  177. +1 −1 activesupport/lib/active_support/buffered_logger.rb
  178. +1 −1 activesupport/lib/active_support/cache.rb
  179. +1 −1 activesupport/lib/active_support/cache/file_store.rb
  180. +11 −39 activesupport/lib/active_support/cache/memory_store.rb
  181. +46 −0 activesupport/lib/active_support/cache/synchronized_memory_store.rb
  182. +1 −1 activesupport/lib/active_support/callbacks.rb
  183. +0 −127 activesupport/lib/active_support/clean_logger.rb
  184. +6 −6 activesupport/lib/active_support/core_ext/array/grouping.rb
  185. +18 −22 activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb
  186. +5 −5 activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
  187. +21 −8 activesupport/lib/active_support/core_ext/date/behavior.rb
  188. +24 −9 activesupport/lib/active_support/core_ext/date/calculations.rb
  189. +19 −5 activesupport/lib/active_support/core_ext/date_time/calculations.rb
  190. +21 −1 activesupport/lib/active_support/core_ext/enumerable.rb
  191. +1 −1 activesupport/lib/active_support/core_ext/file/atomic.rb
  192. +1 −1 activesupport/lib/active_support/core_ext/hash/conversions.rb
  193. +1 −1 activesupport/lib/active_support/core_ext/hash/except.rb
  194. +128 −1 activesupport/lib/active_support/core_ext/logger.rb
  195. +11 −1 activesupport/lib/active_support/core_ext/module.rb
  196. +71 −67 activesupport/lib/active_support/core_ext/module/aliasing.rb
  197. +79 −75 activesupport/lib/active_support/core_ext/module/introspection.rb
  198. +5 −5 activesupport/lib/active_support/core_ext/module/model_naming.rb
  199. +39 −0 activesupport/lib/active_support/core_ext/module/synchronization.rb
  200. +0 −5 activesupport/lib/active_support/core_ext/object/misc.rb
  201. +2 −2 activesupport/lib/active_support/core_ext/range/blockless_step.rb
  202. +36 −0 activesupport/lib/active_support/core_ext/rexml.rb
  203. +2 −0 activesupport/lib/active_support/core_ext/string.rb
  204. +13 −0 activesupport/lib/active_support/core_ext/string/behavior.rb
  205. +19 −0 activesupport/lib/active_support/core_ext/string/inflections.rb
  206. +22 −1 activesupport/lib/active_support/core_ext/time.rb
  207. +26 −11 activesupport/lib/active_support/core_ext/time/calculations.rb
  208. +1 −1 activesupport/lib/active_support/core_ext/time/zones.rb
  209. +17 −1 activesupport/lib/active_support/deprecation.rb
  210. +19 −0 activesupport/lib/active_support/inflector.rb
  211. +1 −1 activesupport/lib/active_support/memoizable.rb
  212. +5 −0 activesupport/lib/active_support/multibyte/chars.rb
  213. +1 −1 activesupport/lib/active_support/option_merger.rb
  214. +197 −0 activesupport/lib/active_support/secure_random.rb
  215. +10 −0 activesupport/lib/active_support/string_inquirer.rb
  216. +7 −1 activesupport/lib/active_support/test_case.rb
  217. +5 −1 activesupport/lib/active_support/testing/core_ext/test/unit/assertions.rb
  218. +54 −42 activesupport/lib/active_support/time_with_zone.rb
  219. +1 −1 activesupport/lib/active_support/values/time_zone.rb
  220. +16 −21 activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb
  221. +36 −29 activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
  222. +30 −0 activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Colombo.rb
  223. +2 −1 activesupport/test/buffered_logger_test.rb
  224. +23 −0 activesupport/test/core_ext/date_ext_test.rb
  225. +75 −0 activesupport/test/core_ext/date_time_ext_test.rb
  226. +5 −0 activesupport/test/core_ext/enumerable_test.rb
  227. +39 −4 activesupport/test/core_ext/hash_ext_test.rb
  228. +85 −0 activesupport/test/core_ext/module/synchronization_test.rb
  229. +0 −5 activesupport/test/core_ext/object_and_class_ext_test.rb
  230. +6 −0 activesupport/test/core_ext/string_ext_test.rb
  231. +113 −4 activesupport/test/core_ext/time_ext_test.rb
  232. +64 −10 activesupport/test/core_ext/time_with_zone_test.rb
  233. +9 −9 activesupport/test/dependencies_test.rb
  234. +6 −0 activesupport/test/inflector_test.rb
  235. +8 −0 activesupport/test/inflector_test_cases.rb
  236. +4 −0 activesupport/test/multibyte_chars_test.rb
  237. +15 −0 activesupport/test/secure_random_test.rb
  238. +2 −0 railties/CHANGELOG
  239. +37 −8 railties/Rakefile
  240. +1,657 −0 railties/doc/guides/activerecord/association_basics.txt
  241. +604 −0 railties/doc/guides/debugging/debugging_rails_applications.txt
  242. +270 −0 railties/doc/guides/forms/form_helpers.txt
  243. +348 −0 railties/doc/guides/getting_started_with_rails/getting_started_with_rails.txt
  244. +53 −0 railties/doc/guides/index.txt
  245. +85 −0 railties/doc/guides/migrations/anatomy_of_a_migration.txt
  246. +109 −0 railties/doc/guides/migrations/creating_a_migration.txt
  247. +7 −0 railties/doc/guides/migrations/foreign_keys.txt
  248. +21 −0 railties/doc/guides/migrations/migrations.txt
  249. +111 −0 railties/doc/guides/migrations/rakeing_around.txt
  250. +47 −0 railties/doc/guides/migrations/scheming.txt
  251. +46 −0 railties/doc/guides/migrations/using_models_in_migrations.txt
  252. +159 −0 railties/doc/guides/migrations/writing_a_migration.txt
  253. +838 −0 railties/doc/guides/routing/routing_outside_in.txt
  254. +3 −2 railties/environments/environment.rb
  255. +13 −0 railties/lib/commands/console.rb
  256. +1 −1 railties/lib/commands/dbconsole.rb
  257. +9 −9 railties/lib/commands/plugin.rb
  258. +2 −2 railties/lib/commands/process/spawner.rb
  259. +1 −2 railties/lib/initializer.rb
  260. +1 −2 railties/lib/rails_generator/generators/applications/app/app_generator.rb
  261. +0 −1 railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
  262. +5 −147 railties/lib/rails_generator/secret_key_generator.rb
  263. +28 −8 railties/lib/tasks/databases.rake
  264. +2 −2 railties/lib/tasks/documentation.rake
  265. +3 −4 railties/lib/tasks/misc.rake
  266. +2 −8 railties/test/secret_key_generation_test.rb
  267. +5 −2 release.rb
View
@@ -1,3 +1,8 @@
+* Add layout functionality to mailers [Pratik]
+
+ Mailer layouts behaves just like controller layouts, except layout names need to
+ have '_mailer' postfix for them to be automatically picked up.
+
*2.1.0 (May 31st, 2008)*
* Fixed that a return-path header would be ignored #7572 [joost]
@@ -246,7 +246,10 @@ module ActionMailer #:nodoc:
# +implicit_parts_order+.
class Base
include AdvAttrAccessor, PartContainer
- include ActionController::UrlWriter if Object.const_defined?(:ActionController)
+ if Object.const_defined?(:ActionController)
+ include ActionController::UrlWriter
+ include ActionController::Layout
+ end
private_class_method :new #:nodoc:
@@ -362,6 +365,7 @@ def mailer_name=(value)
# The mail object instance referenced by this mailer.
attr_reader :mail
+ attr_reader :template_name, :default_template_name, :action_name
class << self
attr_writer :mailer_name
@@ -374,11 +378,16 @@ def mailer_name
alias_method :controller_name, :mailer_name
alias_method :controller_path, :mailer_name
- def method_missing(method_symbol, *parameters)#:nodoc:
- case method_symbol.id2name
- when /^create_([_a-z]\w*)/ then new($1, *parameters).mail
- when /^deliver_([_a-z]\w*)/ then new($1, *parameters).deliver!
- when "new" then nil
+ def respond_to?(method_symbol, include_private = false) #:nodoc:
+ matches_dynamic_method?(method_symbol) || super
+ end
+
+ def method_missing(method_symbol, *parameters) #:nodoc:
+ match = matches_dynamic_method?(method_symbol)
+ case match[1]
+ when 'create' then new(match[2], *parameters).mail
+ when 'deliver' then new(match[2], *parameters).deliver!
+ when 'new' then nil
else super
end
end
@@ -424,6 +433,12 @@ def template_root
def template_root=(root)
self.view_paths = ActionView::Base.process_view_paths(root)
end
+
+ private
+ def matches_dynamic_method?(method_name) #:nodoc:
+ method_name = method_name.to_s
+ /(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
+ end
end
# Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
@@ -451,7 +466,7 @@ def create!(method_name, *parameters) #:nodoc:
template = template_root["#{mailer_name}/#{File.basename(path)}"]
# Skip unless template has a multipart format
- next unless template.multipart?
+ next unless template && template.multipart?
@parts << Part.new(
:content_type => template.content_type,
@@ -519,6 +534,7 @@ def initialize_defaults(method_name)
@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 ||= []
@headers ||= {}
@@ -535,7 +551,22 @@ def render(opts)
if opts[:file] && (opts[:file] !~ /\// && !opts[:file].respond_to?(:render))
opts[:file] = "#{mailer_name}/#{opts[:file]}"
end
- initialize_template_class(body).render(opts)
+
+ begin
+ old_template, @template = @template, initialize_template_class(body)
+ layout = respond_to?(:pick_layout, true) ? pick_layout(opts) : false
+ @template.render(opts.merge(:layout => layout))
+ ensure
+ @template = old_template
+ end
+ end
+
+ def default_template_format
+ :html
+ end
+
+ def candidate_for_layout?(options)
+ !@template.send(:_exempt_from_layout?, default_template_name)
end
def template_root
@@ -72,7 +72,7 @@ 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)
+ controller.__send__(%(#{method}), *args, &block)
end
end_eval
end
@@ -92,7 +92,7 @@ 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.master_helper_module.__send__(:include, master_helper_module)
child.helper child.name.to_s.underscore
rescue MissingSourceFile => e
raise unless e.is_missing?("helpers/#{child.name.to_s.underscore}_helper")
@@ -0,0 +1 @@
+You logged out
@@ -0,0 +1 @@
+We do not spam
@@ -0,0 +1 @@
+Hello from layout <%= yield %>
@@ -0,0 +1 @@
+Spammer layout <%= yield %>
@@ -0,0 +1,10 @@
+<html>
+ <body>
+ HTML formatted message to <strong><%= @recipient %></strong>.
+ </body>
+</html>
+<html>
+ <body>
+ HTML formatted message to <strong><%= @recipient %></strong>.
+ </body>
+</html>
@@ -0,0 +1,78 @@
+require 'abstract_unit'
+
+class AutoLayoutMailer < ActionMailer::Base
+ def hello(recipient)
+ recipients recipient
+ subject "You have a mail"
+ from "tester@example.com"
+ end
+
+ def spam(recipient)
+ recipients recipient
+ subject "You have a mail"
+ from "tester@example.com"
+ body render(:inline => "Hello, <%= @world %>", :layout => 'spam', :body => { :world => "Earth" })
+ 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" })
+ end
+end
+
+class ExplicitLayoutMailer < ActionMailer::Base
+ layout 'spam', :except => [:logout]
+
+ def signup(recipient)
+ recipients recipient
+ subject "You have a mail"
+ from "tester@example.com"
+ end
+
+ def logout(recipient)
+ recipients recipient
+ subject "You have a mail"
+ from "tester@example.com"
+ end
+end
+
+class LayoutMailerTest < Test::Unit::TestCase
+ def setup
+ set_delivery_method :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries = []
+
+ @recipient = 'test@localhost'
+ end
+
+ def teardown
+ restore_delivery_method
+ end
+
+ def test_should_pickup_default_layout
+ mail = AutoLayoutMailer.create_hello(@recipient)
+ assert_equal "Hello from layout Inside", mail.body.strip
+ end
+
+ def test_should_pickup_layout_given_to_render
+ mail = AutoLayoutMailer.create_spam(@recipient)
+ assert_equal "Spammer layout Hello, Earth", mail.body.strip
+ end
+
+ def test_should_respect_layout_false
+ mail = AutoLayoutMailer.create_nolayout(@recipient)
+ assert_equal "Hello, Earth", mail.body.strip
+ end
+
+ def test_explicit_class_layout
+ mail = ExplicitLayoutMailer.create_signup(@recipient)
+ assert_equal "Spammer layout We do not spam", mail.body.strip
+ end
+
+ def test_explicit_layout_exceptions
+ mail = ExplicitLayoutMailer.create_logout(@recipient)
+ assert_equal "You logged out", mail.body.strip
+ end
+end
@@ -968,3 +968,55 @@ def test_send_method
end
end
end
+
+class RespondToTest < Test::Unit::TestCase
+ class RespondToMailer < ActionMailer::Base; end
+
+ def setup
+ set_delivery_method :test
+ end
+
+ def teardown
+ restore_delivery_method
+ end
+
+ def test_should_respond_to_new
+ assert RespondToMailer.respond_to?(:new)
+ end
+
+ def test_should_respond_to_create_with_template_suffix
+ assert RespondToMailer.respond_to?(:create_any_old_template)
+ end
+
+ def test_should_respond_to_deliver_with_template_suffix
+ assert RespondToMailer.respond_to?(:deliver_any_old_template)
+ end
+
+ def test_should_not_respond_to_new_with_template_suffix
+ assert !RespondToMailer.respond_to?(:new_any_old_template)
+ end
+
+ def test_should_not_respond_to_create_with_template_suffix_unless_it_is_separated_by_an_underscore
+ assert !RespondToMailer.respond_to?(:createany_old_template)
+ end
+
+ def test_should_not_respond_to_deliver_with_template_suffix_unless_it_is_separated_by_an_underscore
+ assert !RespondToMailer.respond_to?(:deliverany_old_template)
+ end
+
+ def test_should_not_respond_to_create_with_template_suffix_if_it_begins_with_a_uppercase_letter
+ assert !RespondToMailer.respond_to?(:create_Any_old_template)
+ end
+
+ def test_should_not_respond_to_deliver_with_template_suffix_if_it_begins_with_a_uppercase_letter
+ assert !RespondToMailer.respond_to?(:deliver_Any_old_template)
+ end
+
+ def test_should_not_respond_to_create_with_template_suffix_if_it_begins_with_a_digit
+ assert !RespondToMailer.respond_to?(:create_1_template)
+ end
+
+ def test_should_not_respond_to_deliver_with_template_suffix_if_it_begins_with_a_digit
+ assert !RespondToMailer.respond_to?(:deliver_1_template)
+ end
+end
View
@@ -1,5 +1,51 @@
*Edge*
+* Set HttpOnly for the cookie session store's cookie. #1046
+
+* Added FormTagHelper#image_submit_tag confirm option #784 [Alastair Brunton]
+
+* Fixed FormTagHelper#submit_tag with :disable_with option wouldn't submit the button's value when was clicked #633 [Jose Fernandez]
+
+* Stopped logging template compiles as it only clogs up the log [DHH]
+
+* Changed the X-Runtime header to report in milliseconds [DHH]
+
+* Changed BenchmarkHelper#benchmark to report in milliseconds [DHH]
+
+* Changed logging format to be millisecond based and skip misleading stats [DHH]. Went from:
+
+ Completed in 0.10000 (4 reqs/sec) | Rendering: 0.04000 (40%) | DB: 0.00400 (4%) | 200 OK [http://example.com]
+
+ ...to:
+
+ Completed in 100ms (View: 40, DB: 4) | 200 OK [http://example.com]
+
+* Add support for shallow nesting of routes. #838 [S. Brent Faulkner]
+
+ Example :
+
+ map.resources :users, :shallow => true do |user|
+ user.resources :posts
+ end
+
+ - GET /users/1/posts (maps to PostsController#index action as usual)
+ named route "user_posts" is added as usual.
+
+ - GET /posts/2 (maps to PostsController#show action as if it were not nested)
+ Additionally, named route "post" is added too.
+
+* Added button_to_remote helper. #3641 [Donald Piret, Tarmo Tänav]
+
+* Deprecate render_component. Please use render_component plugin from http://github.com/rails/render_component/tree/master [Pratik]
+
+* Routes may be restricted to lists of HTTP methods instead of a single method or :any. #407 [Brennan Dunn, Gaius Centus Novus]
+ map.resource :posts, :collection => { :search => [:get, :post] }
+ map.session 'session', :requirements => { :method => [:get, :post, :delete] }
+
+* Deprecated implicit local assignments when rendering partials [Josh Peek]
+
+* Introduce current_cycle helper method to return the current value without bumping the cycle. #417 [Ken Collins]
+
* Allow polymorphic_url helper to take url options. #880 [Tarmo Tänav]
* Switched integration test runner to use Rack processor instead of CGI [Josh Peek]
View
@@ -25,14 +25,16 @@ task :default => [ :test ]
desc "Run all unit tests"
task :test => [:test_action_pack, :test_active_record_integration]
-Rake::TestTask.new(:test_action_pack) { |t|
+Rake::TestTask.new(:test_action_pack) do |t|
t.libs << "test"
-# make sure we include the tests in alphabetical order as on some systems
-# this will not happen automatically and the tests (as a whole) will error
- t.test_files=Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
-# t.pattern = 'test/*/*_test.rb'
+
+ # make sure we include the tests in alphabetical order as on some systems
+ # this will not happen automatically and the tests (as a whole) will error
+ t.test_files = Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
+
t.verbose = true
-}
+ #t.warning = true
+end
desc 'ActiveRecord Integration Tests'
Rake::TestTask.new(:test_active_record_integration) do |t|
@@ -54,6 +54,7 @@
require 'action_controller/record_identifier'
require 'action_controller/request_forgery_protection'
require 'action_controller/headers'
+require 'action_controller/translation'
require 'action_view'
@@ -74,4 +75,5 @@
include ActionController::Components
include ActionController::RecordIdentifier
include ActionController::RequestForgeryProtection
+ include ActionController::Translation
end
Oops, something went wrong.

0 comments on commit 22e830f

Please sign in to comment.