1
0
Fork 0
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:
Sen-Zhang 2016-03-11 16:43:37 -08:00
parent d448918027
commit 0b3ae023d2
3 changed files with 14 additions and 0 deletions

View file

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

View file

@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout :mailer
end

View file

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