diff options
author | Guo Xiang Tan <tgx_world@hotmail.com> | 2014-11-25 09:21:37 +0800 |
---|---|---|
committer | Guo Xiang Tan <tgx_world@hotmail.com> | 2014-11-25 09:21:37 +0800 |
commit | 7a47690a13f403278036f38b69465167466f6b5f (patch) | |
tree | 508512a1cedb1b2f352dd50a59b0dbad2224deee | |
parent | 35628a44b2b8ccf6d1931222447c5ab27b19c7e7 (diff) | |
download | rails-7a47690a13f403278036f38b69465167466f6b5f.tar.gz rails-7a47690a13f403278036f38b69465167466f6b5f.tar.bz2 rails-7a47690a13f403278036f38b69465167466f6b5f.zip |
Generate mailer layouts even if no action is given.
-rw-r--r-- | railties/lib/rails/generators/erb/mailer/mailer_generator.rb | 8 | ||||
-rw-r--r-- | railties/test/generators/mailer_generator_test.rb | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index e2f142fd02..f9b3658ae7 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -9,7 +9,10 @@ module Erb # :nodoc: view_base_path = File.join("app/views", class_path, file_name) empty_directory view_base_path - layout_base_path = "app/views/layouts" + formats.each do |format| + layout_path = File.join("app/views/layouts", filename_with_extensions("mailer", format)) + template filename_with_extensions(:layout, format), layout_path + end actions.each do |action| @action = action @@ -17,9 +20,6 @@ module Erb # :nodoc: formats.each do |format| @path = File.join(view_base_path, filename_with_extensions(action, format)) template filename_with_extensions(:view, format), @path - - layout_path = File.join(layout_base_path, filename_with_extensions("mailer", format)) - template filename_with_extensions(:layout, format), layout_path end end end diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index 20fffd25de..bab15ce172 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -113,6 +113,8 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_invokes_default_template_engine_even_with_no_action run_generator ["notifier"] assert_file "app/views/notifier" + assert_file "app/views/layouts/mailer.text.erb" + assert_file "app/views/layouts/mailer.html.erb" end def test_logs_if_the_template_engine_cannot_be_found |