1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Generate mailer layouts even if no action is given.

This commit is contained in:
Guo Xiang Tan 2014-11-25 09:21:37 +08:00
parent 35628a44b2
commit 7a47690a13
2 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -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