mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
generate application_mailer.rb if it is missing
This commit is contained in:
parent
d448918027
commit
0b3ae023d2
3 changed files with 14 additions and 0 deletions
|
@ -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 a new issue