1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
This commit is contained in:
Marcos Ferreira 2019-10-29 14:11:26 -03:00
parent 885c61ece3
commit 6f9a736115
No known key found for this signature in database
GPG key ID: 55332D1086F6114C
3 changed files with 37 additions and 1 deletions

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
if defined?(ActionMailer)
if Object.const_defined?(Devise.parent_mailer)
class Devise::Mailer < Devise.parent_mailer.constantize
include Devise::Mailers::Helpers

View file

@ -102,10 +102,13 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
test 'renders a scoped if scoped_views is set in the mailer class' do
begin
# Devise.send(:remove_const, :Mailer) if defined?(Devise::Mailer)
# load "#{Devise::Engine.root}/app/mailers/devise/mailer.rb"
Devise::Mailer.scoped_views = true
assert_equal user.email, mail.body.decoded
ensure
Devise::Mailer.send :remove_instance_variable, :@scoped_views
# Devise.send(:remove_const, :Mailer) if defined?(Devise::Mailer)
end
end

View file

@ -4,6 +4,8 @@ require "test_helper"
class MailerTest < ActionMailer::TestCase
test "pass given block to #mail call" do
# Devise.send(:remove_const, :Mailer) if defined?(Devise::Mailer)
# load "#{Devise::Engine.root}/app/mailers/devise/mailer.rb"
class TestMailer < Devise::Mailer
def confirmation_instructions(record, token, opts = {})
@token = token
@ -17,4 +19,35 @@ class MailerTest < ActionMailer::TestCase
assert mail.content_transfer_encoding, "7bit"
end
# test 'correctly uses ActionMailer::Base as default parent_mailer' do
# Devise.send(:remove_const, :Mailer) if defined?(Devise::Mailer)
# load "#{Devise::Engine.root}/app/mailers/devise/mailer.rb"
# assert Devise::Mailer.superclass == ActionMailer::Base
# end
# test 'correctly inherits from Devise.parent_mailer' do
# class ::TestParentMailer; end
# swap Devise, parent_mailer: 'TestParentMailer' do
# Devise.send(:remove_const, :Mailer) if defined?(Devise::Mailer)
# load "#{Devise::Engine.root}/app/mailers/devise/mailer.rb"
# assert Devise::Mailer.superclass == TestParentMailer
# end
# end
# test 'do not define Devise::Mailer when Devise.parent_mailer class is not defined' do
# swap Devise, parent_mailer: 'NotDefinedParentMailer' do
# Devise.send(:remove_const, :Mailer) if defined?(Devise::Mailer)
# load "#{Devise::Engine.root}/app/mailers/devise/mailer.rb"
# refute defined?(Devise::Mailer)
# end
# end
# test 'defines Devise::Mailer when Devise.parent_mailer class is defined' do
# swap Devise, parent_mailer: 'DefinedParentMailer' do
# Devise.send(:remove_const, :Mailer) if defined?(Devise::Mailer)
# load "#{Devise::Engine.root}/app/mailers/devise/mailer.rb"
# assert defined?(Devise::Mailer)
# end
# end
end