Fix inheriting mailer templates from Devise::Mailer

Previously inheriting from Devise::Mailer would not render default views
from devise when the inheriting mailer didn't have the view. Now it'll
correctly pick the default one from Devise::Mailer.
This commit is contained in:
Carlos Antonio da Silva 2013-01-29 00:08:26 -02:00
parent 72be1f1289
commit 83ad67bd51
5 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,8 @@
== master
* bug fix
* Fix inheriting mailer templates from `Devise::Mailer`
== 2.2.3
* bug fix

View File

@ -64,7 +64,7 @@ module Devise
end
def template_paths
template_path = [self.class.mailer_name]
template_path = _prefixes.dup
template_path.unshift "#{@devise_mapping.scoped_path}/mailer" if self.class.scoped_views?
template_path
end

View File

@ -46,6 +46,11 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
assert_equal ['custom@example.com'], mail.from
end
test 'custom mailer renders parent mailer template' do
Devise.mailer = 'Users::Mailer'
assert_not_blank mail.body.encoded
end
test 'setup reply to as copy from sender' do
assert_equal ['test@example.com'], mail.reply_to
end
@ -56,7 +61,6 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
assert_equal ['custom_reply_to@example.com'], mail.reply_to
end
test 'setup subject from I18n' do
store_translations :en, :devise => { :mailer => { :confirmation_instructions => { :subject => 'Account Confirmation' } } } do
assert_equal 'Account Confirmation', mail.subject

View File

@ -1,7 +1,6 @@
require 'test_helper'
class ResetPasswordInstructionsTest < ActionMailer::TestCase
def setup
setup_mailer
Devise.mailer = 'Devise::Mailer'
@ -49,6 +48,11 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
assert_equal ['custom@example.com'], mail.from
end
test 'custom mailer renders parent mailer template' do
Devise.mailer = 'Users::Mailer'
assert_not_blank mail.body.encoded
end
test 'setup reply to as copy from sender' do
assert_equal ['test@example.com'], mail.reply_to
end

View File

@ -49,6 +49,11 @@ class UnlockInstructionsTest < ActionMailer::TestCase
assert_equal ['custom@example.com'], mail.from
end
test 'custom mailer renders parent mailer template' do
Devise.mailer = 'Users::Mailer'
assert_not_blank mail.body.encoded
end
test 'setup reply to as copy from sender' do
assert_equal ['test@example.com'], mail.reply_to
end