Merge pull request #17797 from y-yagi/donot_delete_mailer_layouts

Don't remove mailer layouts files
This commit is contained in:
Rafael Mendonça França 2014-12-04 18:29:50 -02:00
commit da13b9aedc
3 changed files with 23 additions and 4 deletions

@ -8,7 +8,9 @@ class MailerGenerator < NamedBase
def create_mailer_file
template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}.rb")
template "application_mailer.rb", 'app/mailers/application_mailer.rb'
if self.behavior == :invoke
template "application_mailer.rb", 'app/mailers/application_mailer.rb'
end
end
hook_for :template_engine, :test_framework

@ -9,9 +9,11 @@ def copy_view_files
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|

@ -152,4 +152,19 @@ def test_actions_are_turned_into_methods
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