diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2014-11-27 14:36:10 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2014-11-27 14:36:10 +0900 |
commit | f9411b464dd477131540d32bed1fa8f18ef5ee4c (patch) | |
tree | 440fbda93e043a9ff652b487b1ae47a7c8b3bccf /railties | |
parent | 37b1de18841adac1fb4940069389da628a835649 (diff) | |
download | rails-f9411b464dd477131540d32bed1fa8f18ef5ee4c.tar.gz rails-f9411b464dd477131540d32bed1fa8f18ef5ee4c.tar.bz2 rails-f9411b464dd477131540d32bed1fa8f18ef5ee4c.zip |
Don't remove mailer layouts files
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/erb/mailer/mailer_generator.rb | 8 | ||||
-rw-r--r-- | railties/test/generators/mailer_generator_test.rb | 15 |
2 files changed, 20 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index f9b3658ae7..7d27321610 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -9,9 +9,11 @@ module Erb # :nodoc: view_base_path = File.join("app/views", class_path, file_name) empty_directory view_base_path - formats.each do |format| - layout_path = File.join("app/views/layouts", filename_with_extensions("mailer", format)) - template filename_with_extensions(:layout, format), layout_path + if self.behavior == :invoke + 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 end actions.each do |action| diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index bab15ce172..3d1cf87dae 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -152,4 +152,19 @@ class MailerGeneratorTest < Rails::Generators::TestCase end end end + + def test_mailer_on_revoke + run_generator + run_generator ["notifier"], behavior: :revoke + + assert_no_file "app/mailers/notifier.rb" + assert_no_file "app/views/notifier/foo.text.erb" + assert_no_file "app/views/notifier/bar.text.erb" + assert_no_file "app/views/notifier/foo.html.erb" + assert_no_file "app/views/notifier/bar.html.erb" + + assert_file "app/mailers/application_mailer.rb" + assert_file "app/views/layouts/mailer.text.erb" + assert_file "app/views/layouts/mailer.html.erb" + end end |