mirror of https://github.com/rails/rails
generate application_mailer.rb if it is missing
This commit is contained in:
parent
d448918027
commit
0b3ae023d2
|
@ -9,6 +9,10 @@ module Rails
|
|||
|
||||
def create_mailer_file
|
||||
template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}_mailer.rb")
|
||||
|
||||
unless File.exist?('app/mailers/application_mailer.rb')
|
||||
template 'application_mailer.rb', 'app/mailers/application_mailer.rb'
|
||||
end
|
||||
end
|
||||
|
||||
hook_for :template_engine, :test_framework
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'from@example.com'
|
||||
layout :mailer
|
||||
end
|
|
@ -12,6 +12,12 @@ class MailerGeneratorTest < Rails::Generators::TestCase
|
|||
assert_no_match(/default from: "from@example.com"/, mailer)
|
||||
assert_no_match(/layout :mailer_notifier/, mailer)
|
||||
end
|
||||
|
||||
assert_file 'app/mailers/application_mailer.rb' do |mailer|
|
||||
assert_match(/class ApplicationMailer < ActionMailer::Base/, mailer)
|
||||
assert_match(/default from: 'from@example.com'/, mailer)
|
||||
assert_match(/layout :mailer/, mailer)
|
||||
end
|
||||
end
|
||||
|
||||
def test_mailer_with_i18n_helper
|
||||
|
|
Loading…
Reference in New Issue