Permalink
Browse files

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

  • Loading branch information...
FooBarWidget committed Sep 4, 2008
2 parents 08704c4 + d7bd01f commit c480c1db1f302ab28a255c5423326e51d27ec5ed
Showing with 7,625 additions and 4,583 deletions.
  1. +1 −0 .gitignore
  2. +5 −0 actionmailer/CHANGELOG
  3. +6 −6 actionmailer/lib/action_mailer.rb
  4. +38 −7 actionmailer/lib/action_mailer/base.rb
  5. +2 −2 actionmailer/lib/action_mailer/helpers.rb
  6. +1 −0 actionmailer/test/fixtures/auto_layout_mailer/hello.html.erb
  7. +1 −0 actionmailer/test/fixtures/explicit_layout_mailer/logout.html.erb
  8. +1 −0 actionmailer/test/fixtures/explicit_layout_mailer/signup.html.erb
  9. +1 −0 actionmailer/test/fixtures/layouts/auto_layout_mailer.html.erb
  10. +1 −0 actionmailer/test/fixtures/layouts/spam.html.erb
  11. +78 −0 actionmailer/test/mail_layout_test.rb
  12. +3 −9 actionmailer/test/mail_render_test.rb
  13. +52 −0 actionmailer/test/mail_service_test.rb
  14. +32 −0 actionpack/CHANGELOG
  15. +6 −9 actionpack/lib/action_controller.rb
  16. +33 −53 actionpack/lib/action_controller/assertions/selector_assertions.rb
  17. +41 −95 actionpack/lib/action_controller/base.rb
  18. +2 −2 actionpack/lib/action_controller/caching/actions.rb
  19. +3 −3 actionpack/lib/action_controller/caching/sweeping.rb
  20. +3 −3 actionpack/lib/action_controller/cgi_process.rb
  21. +4 −1 actionpack/lib/action_controller/components.rb
  22. +3 −3 actionpack/lib/action_controller/dispatcher.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. +37 −49 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. +14 −8 actionpack/lib/action_controller/polymorphic_routes.rb
  30. +66 −36 actionpack/lib/action_controller/rack_process.rb
  31. +6 −4 actionpack/lib/action_controller/request.rb
  32. +1 −4 actionpack/lib/action_controller/rescue.rb
  33. +74 −20 actionpack/lib/action_controller/resources.rb
  34. +44 −11 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. +1 −1 actionpack/lib/action_controller/routing/route.rb
  38. +3 −3 actionpack/lib/action_controller/routing/route_set.rb
  39. +3 −3 actionpack/lib/action_controller/routing/segments.rb
  40. +2 −2 actionpack/lib/action_controller/session_management.rb
  41. +2 −2 actionpack/lib/action_controller/templates/rescues/diagnostics.erb
  42. +2 −2 actionpack/lib/action_controller/templates/rescues/template_error.erb
  43. +30 −23 actionpack/lib/action_controller/test_process.rb
  44. +2 −2 actionpack/lib/action_controller/verification.rb
  45. +13 −7 actionpack/lib/action_view.rb
  46. +111 −131 actionpack/lib/action_view/base.rb
  47. +39 −0 actionpack/lib/action_view/helpers.rb
  48. +10 −10 actionpack/lib/action_view/helpers/active_record_helper.rb
  49. +7 −3 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  50. +13 −11 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  51. +10 −4 actionpack/lib/action_view/helpers/prototype_helper.rb
  52. +3 −3 actionpack/lib/action_view/helpers/record_tag_helper.rb
  53. +64 −32 actionpack/lib/action_view/helpers/sanitize_helper.rb
  54. +51 −5 actionpack/lib/action_view/helpers/text_helper.rb
  55. +2 −0 actionpack/lib/action_view/helpers/translation_helper.rb
  56. +0 −53 actionpack/lib/action_view/locale/en-US.rb
  57. +91 −0 actionpack/lib/action_view/locale/en-US.yml
  58. +91 −46 actionpack/lib/action_view/partials.rb
  59. +26 −2 actionpack/lib/action_view/paths.rb
  60. +13 −6 actionpack/lib/action_view/renderable.rb
  61. +13 −3 actionpack/lib/action_view/renderable_partial.rb
  62. +2 −0 actionpack/lib/action_view/template.rb
  63. +1 −1 actionpack/lib/action_view/template_error.rb
  64. +1 −1 actionpack/lib/action_view/template_handlers/builder.rb
  65. +2 −4 actionpack/lib/action_view/test_case.rb
  66. +10 −0 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  67. +49 −0 actionpack/test/controller/assert_select_test.rb
  68. +4 −4 actionpack/test/controller/base_test.rb
  69. +41 −25 actionpack/test/controller/components_test.rb
  70. +20 −0 actionpack/test/controller/content_type_test.rb
  71. +2 −2 actionpack/test/controller/filter_params_test.rb
  72. +13 −13 actionpack/test/controller/filters_test.rb
  73. +85 −7 actionpack/test/controller/integration_test.rb
  74. +8 −58 actionpack/test/controller/layout_test.rb
  75. +0 −972 actionpack/test/controller/new_render_test.rb
  76. +20 −2 actionpack/test/controller/polymorphic_routes_test.rb
  77. +25 −14 actionpack/test/controller/rack_test.rb
  78. +872 −28 actionpack/test/controller/render_test.rb
  79. +13 −14 actionpack/test/controller/request_test.rb
  80. +122 −25 actionpack/test/controller/resources_test.rb
  81. +29 −0 actionpack/test/controller/routing_test.rb
  82. +5 −0 actionpack/test/controller/test_test.rb
  83. +3 −0 actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb
  84. +1 −0 actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb
  85. +14 −14 actionpack/test/template/active_record_helper_i18n_test.rb
  86. +32 −5 actionpack/test/template/atom_feed_helper_test.rb
  87. +22 −0 actionpack/test/template/date_helper_i18n_test.rb
  88. +15 −0 actionpack/test/template/prototype_helper_test.rb
  89. +8 −0 actionpack/test/template/record_tag_helper_test.rb
  90. +12 −0 actionpack/test/template/render_test.rb
  91. +3 −3 actionpack/test/template/sanitize_helper_test.rb
  92. +34 −0 actionpack/test/template/text_helper_test.rb
  93. +1 −0 actionpack/test/template/url_helper_test.rb
  94. +3 −3 activemodel/lib/active_model/state_machine/event.rb
  95. +1 −1 activemodel/lib/active_model/validations.rb
  96. +1 −1 activemodel/lib/active_model/validations/exclusion.rb
  97. +1 −1 activemodel/lib/active_model/validations/inclusion.rb
  98. +2 −2 activemodel/lib/active_model/validations/uniqueness.rb
  99. +8 −0 activerecord/CHANGELOG
  100. +8 −14 activerecord/lib/active_record.rb
  101. +2 −6 activerecord/lib/active_record/association_preload.rb
  102. +52 −47 activerecord/lib/active_record/associations.rb
  103. +29 −0 activerecord/lib/active_record/associations/association_collection.rb
  104. +3 −15 activerecord/lib/active_record/associations/association_proxy.rb
  105. +11 −3 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  106. +5 −19 activerecord/lib/active_record/associations/has_many_association.rb
  107. +1 −11 activerecord/lib/active_record/associations/has_many_through_association.rb
  108. +2 −2 activerecord/lib/active_record/associations/has_one_association.rb
  109. +4 −0 activerecord/lib/active_record/associations/has_one_through_association.rb
  110. +3 −3 activerecord/lib/active_record/attribute_methods.rb
  111. +137 −120 activerecord/lib/active_record/base.rb
  112. +16 −3 activerecord/lib/active_record/calculations.rb
  113. +9 −10 activerecord/lib/active_record/callbacks.rb
  114. +281 −0 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  115. +32 −210 activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
  116. +29 −14 activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  117. +9 −4 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  118. +2 −6 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  119. +24 −2 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  120. +14 −0 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  121. +12 −7 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  122. +4 −1 activerecord/lib/active_record/dirty.rb
  123. +40 −0 activerecord/lib/active_record/dynamic_finder_match.rb
  124. +1 −1 activerecord/lib/active_record/fixtures.rb
  125. +0 −25 activerecord/lib/active_record/locale/en-US.rb
  126. +33 −0 activerecord/lib/active_record/locale/en-US.yml
  127. +36 −11 activerecord/lib/active_record/migration.rb
  128. +8 −4 activerecord/lib/active_record/named_scope.rb
  129. +1 −1 activerecord/lib/active_record/reflection.rb
  130. +1 −1 activerecord/lib/active_record/test_case.rb
  131. +14 −2 activerecord/lib/active_record/transactions.rb
  132. +76 −64 activerecord/lib/active_record/validations.rb
  133. +12 −0 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  134. +30 −12 activerecord/test/cases/associations/eager_load_nested_include_test.rb
  135. +16 −3 activerecord/test/cases/associations/eager_test.rb
  136. +41 −13 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  137. +41 −7 activerecord/test/cases/associations/has_many_associations_test.rb
  138. +24 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  139. +10 −0 activerecord/test/cases/associations/has_one_associations_test.rb
  140. +44 −5 activerecord/test/cases/associations/has_one_through_associations_test.rb
  141. +7 −0 activerecord/test/cases/associations/join_model_test.rb
  142. +2 −2 activerecord/test/cases/associations_test.rb
  143. +11 −3 activerecord/test/cases/base_test.rb
  144. +4 −4 activerecord/test/cases/column_definition_test.rb
  145. +1 −1 activerecord/test/cases/defaults_test.rb
  146. +36 −0 activerecord/test/cases/dirty_test.rb
  147. +56 −0 activerecord/test/cases/finder_test.rb
  148. +1 −0 activerecord/test/cases/helper.rb
  149. +41 −0 activerecord/test/cases/i18n_test.rb
  150. +0 −7 activerecord/test/cases/locking_test.rb
  151. +79 −2 activerecord/test/cases/method_scoping_test.rb
  152. +51 −6 activerecord/test/cases/migration_test.rb
  153. +33 −0 activerecord/test/cases/named_scope_test.rb
  154. +87 −0 activerecord/test/cases/pooled_connections_test.rb
  155. +3 −2 activerecord/test/cases/query_cache_test.rb
  156. +4 −0 activerecord/test/cases/reflection_test.rb
  157. +0 −48 activerecord/test/cases/threaded_connections_test.rb
  158. +60 −13 activerecord/test/cases/transactions_test.rb
  159. +417 −149 activerecord/test/cases/validations_i18n_test.rb
  160. +16 −4 activerecord/test/cases/validations_test.rb
  161. +1 −3 activerecord/test/connections/native_mysql/connection.rb
  162. +10 −0 activerecord/test/migrations/broken/100_migration_that_raises_exception.rb
  163. +3 −0 activerecord/test/models/author.rb
  164. +2 −0 activerecord/test/models/developer.rb
  165. +1 −1 activerecord/test/models/project.rb
  166. +2 −2 activerecord/test/schema/mysql_specific_schema.rb
  167. +1 −1 activerecord/test/schema/schema.rb
  168. +4 −0 activeresource/CHANGELOG
  169. +7 −10 activeresource/lib/active_resource.rb
  170. +97 −70 activeresource/lib/active_resource/base.rb
  171. +27 −16 activeresource/lib/active_resource/connection.rb
  172. +12 −11 activeresource/lib/active_resource/custom_methods.rb
  173. +6 −6 activeresource/lib/active_resource/formats/json_format.rb
  174. +9 −9 activeresource/lib/active_resource/formats/xml_format.rb
  175. +1 −1 activeresource/lib/active_resource/http_mock.rb
  176. +8 −8 activeresource/test/authorization_test.rb
  177. +1 −2 activeresource/test/base/custom_methods_test.rb
  178. +2 −2 activeresource/test/base/load_test.rb
  179. +66 −51 activeresource/test/base_test.rb
  180. +1 −1 activeresource/test/connection_test.rb
  181. +23 −11 activeresource/test/format_test.rb
  182. +2 −0 activesupport/CHANGELOG
  183. +3 −7 activesupport/lib/active_support.rb
  184. +12 −7 activesupport/lib/active_support/buffered_logger.rb
  185. +2 −2 activesupport/lib/active_support/cache/file_store.rb
  186. +24 −12 activesupport/lib/active_support/cache/memory_store.rb
  187. +13 −8 activesupport/lib/active_support/callbacks.rb
  188. +0 −127 activesupport/lib/active_support/clean_logger.rb
  189. +5 −5 activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
  190. +29 −0 activesupport/lib/active_support/core_ext/date/behavior.rb
  191. +6 −0 activesupport/lib/active_support/core_ext/duplicable.rb
  192. +21 −1 activesupport/lib/active_support/core_ext/enumerable.rb
  193. +4 −4 activesupport/lib/active_support/core_ext/kernel/debugger.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. +36 −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. +35 −0 activesupport/lib/active_support/core_ext/rexml.rb
  203. +22 −1 activesupport/lib/active_support/core_ext/time.rb
  204. +1 −1 activesupport/lib/active_support/core_ext/time/zones.rb
  205. +7 −3 activesupport/lib/active_support/dependencies.rb
  206. +21 −1 activesupport/lib/active_support/deprecation.rb
  207. +46 −25 activesupport/lib/active_support/inflector.rb
  208. +0 −28 activesupport/lib/active_support/locale/en-US.rb
  209. +31 −0 activesupport/lib/active_support/locale/en-US.yml
  210. +1 −1 activesupport/lib/active_support/option_merger.rb
  211. +197 −0 activesupport/lib/active_support/secure_random.rb
  212. +5 −1 activesupport/lib/active_support/testing/core_ext/test/unit/assertions.rb
  213. +68 −13 activesupport/lib/active_support/testing/performance.rb
  214. +1 −1 activesupport/lib/active_support/time_with_zone.rb
  215. +0 −31 activesupport/lib/active_support/typed_array.rb
  216. +1 −1 activesupport/lib/active_support/vendor.rb
  217. +0 −20 activesupport/lib/active_support/vendor/i18n-0.0.1/MIT-LICENSE
  218. +0 −18 activesupport/lib/active_support/vendor/i18n-0.0.1/README.textile
  219. +0 −24 activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.gemspec
  220. +10 −12 activesupport/lib/active_support/vendor/i18n-0.0.1/{lib → }/i18n.rb
  221. +192 −0 activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
  222. +8 −0 activesupport/lib/active_support/vendor/i18n-0.0.1/{lib → }/i18n/exceptions.rb
  223. +0 −154 activesupport/lib/active_support/vendor/i18n-0.0.1/lib/i18n/backend/simple.rb
  224. +0 −4 activesupport/lib/active_support/vendor/i18n-0.0.1/test/all.rb
  225. +0 −100 activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_exceptions_test.rb
  226. +0 −141 activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_test.rb
  227. +0 −376 activesupport/lib/active_support/vendor/i18n-0.0.1/test/simple_backend_test.rb
  228. +26 −4 activesupport/test/buffered_logger_test.rb
  229. +30 −0 activesupport/test/caching_test.rb
  230. +4 −4 activesupport/test/callbacks_test.rb
  231. +12 −4 activesupport/test/core_ext/date_ext_test.rb
  232. +1 −1 activesupport/test/core_ext/duplicable_test.rb
  233. +5 −0 activesupport/test/core_ext/enumerable_test.rb
  234. +25 −4 activesupport/test/core_ext/hash_ext_test.rb
  235. +85 −0 activesupport/test/core_ext/module/synchronization_test.rb
  236. +0 −5 activesupport/test/core_ext/object_and_class_ext_test.rb
  237. +4 −0 activesupport/test/core_ext/string_ext_test.rb
  238. +34 −0 activesupport/test/core_ext/time_ext_test.rb
  239. +9 −9 activesupport/test/dependencies_test.rb
  240. +11 −0 activesupport/test/inflector_test.rb
  241. +15 −0 activesupport/test/secure_random_test.rb
  242. +0 −51 activesupport/test/typed_array_test.rb
  243. +116 −0 ci/ci_build.rb
  244. +120 −0 ci/ci_setup_notes.txt
  245. +5 −0 ci/cruise_config.rb
  246. +17 −0 ci/geminstaller.yml
  247. +13 −0 ci/site.css
  248. +72 −0 ci/site_config.rb
  249. +763 −0 railties/doc/guides/routing/routing_outside_in.txt
  250. +1 −1 railties/environments/environment.rb
  251. +4 −1 railties/html/500.html
  252. +1 −1 railties/lib/commands/dbconsole.rb
  253. +1 −3 railties/lib/fcgi_handler.rb
  254. +13 −8 railties/lib/initializer.rb
  255. +1 −0 railties/lib/rails/rack.rb
  256. +28 −0 railties/lib/rails/rack/logger.rb
  257. +4 −0 railties/lib/rails_generator/generated_attribute.rb
  258. +1 −3 railties/lib/rails_generator/generators/applications/app/app_generator.rb
  259. +3 −0 railties/lib/rails_generator/generators/components/model/templates/model.rb
  260. +5 −147 railties/lib/rails_generator/secret_key_generator.rb
  261. +3 −2 railties/lib/tasks/documentation.rake
  262. +5 −0 railties/lib/tasks/framework.rake
  263. +3 −4 railties/lib/tasks/misc.rake
  264. +43 −0 railties/test/error_page_test.rb
  265. +3 −0 railties/test/fixtures/eager/zoo.rb
  266. +2 −0 railties/test/fixtures/eager/zoo/reptile_house.rb
  267. +16 −0 railties/test/generators/rails_model_generator_test.rb
  268. +18 −0 railties/test/initializer_test.rb
  269. +2 −8 railties/test/secret_key_generation_test.rb
View
@@ -12,4 +12,5 @@ actionpack/pkg
actionmailer/pkg
activesupport/pkg
railties/pkg
+railties/test/500.html
*.rbc
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]
@@ -21,13 +21,13 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-unless defined?(ActionController)
- begin
- $:.unshift "#{File.dirname(__FILE__)}/../../actionpack/lib"
+begin
+ require 'action_controller'
+rescue LoadError
+ actionpack_path = "#{File.dirname(__FILE__)}/../../actionpack/lib"
+ if File.directory?(actionpack_path)
+ $:.unshift actionpack_path
require 'action_controller'
- rescue LoadError
- require 'rubygems'
- gem 'actionpack', '>= 1.12.5'
end
end
@@ -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
@@ -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,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
@@ -20,13 +20,13 @@ def rxml_template(recipient)
subject "rendering rxml template"
from "tester@example.com"
end
-
+
def included_subtemplate(recipient)
recipients recipient
subject "Including another template in the one being rendered"
from "tester@example.com"
end
-
+
def included_old_subtemplate(recipient)
recipients recipient
subject "Including another template in the one being rendered"
@@ -83,17 +83,11 @@ def test_rxml_template
mail = RenderMailer.deliver_rxml_template(@recipient)
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip
end
-
+
def test_included_subtemplate
mail = RenderMailer.deliver_included_subtemplate(@recipient)
assert_equal "Hey Ho, let's go!", mail.body.strip
end
-
- def test_deprecated_old_subtemplate
- assert_raises ActionView::ActionViewError do
- RenderMailer.deliver_included_old_subtemplate(@recipient)
- end
- end
end
class FirstSecondHelperTest < Test::Unit::TestCase
@@ -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,37 @@
*Edge*
+* 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]
+
+* Made AbstractRequest.if_modified_sense return nil if the header could not be parsed [Jamis Buck]
+
* Added back ActionController::Base.allow_concurrency flag [Josh Peek]
* AbstractRequest.relative_url_root is no longer automatically configured by a HTTP header. It can now be set in your configuration environment with config.action_controller.relative_url_root [Josh Peek]
@@ -21,16 +21,13 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-$:.unshift(File.dirname(__FILE__)) unless
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
-
-unless defined?(ActiveSupport)
- begin
- $:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
+begin
+ require 'active_support'
+rescue LoadError
+ activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
+ if File.directory?(activesupport_path)
+ $:.unshift activesupport_path
require 'active_support'
- rescue LoadError
- require 'rubygems'
- gem 'activesupport'
end
end
Oops, something went wrong.

0 comments on commit c480c1d

Please sign in to comment.