mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
wip
This commit is contained in:
parent
885c61ece3
commit
6f9a736115
3 changed files with 37 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue