Skip to content

Commit

Permalink
remove using default from address from custom mailer_parent class
Browse files Browse the repository at this point in the history
  • Loading branch information
smartinez87 committed Jun 29, 2020
1 parent 4c71326 commit b33bc06
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
2 changes: 0 additions & 2 deletions lib/exception_notifier/email_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def exception_notification(env, exception, options = {}, default_options = {})
@exception = exception

env_options = env['exception_notifier.options'] || {}
options[:sender_address] ||= self.class.default[:from] unless self.class.default[:from].nil?
@options = default_options.merge(env_options).merge(options)

@kontroller = env['action_controller.instance'] || MissingController.new
Expand All @@ -62,7 +61,6 @@ def background_exception_notification(exception, options = {}, default_options =
load_custom_views

@exception = exception
options[:sender_address] ||= self.class.default[:from] unless self.class.default[:from].nil?
@options = default_options.merge(options).symbolize_keys
@backtrace = exception.backtrace || []
@timestamp = Time.current
Expand Down
22 changes: 0 additions & 22 deletions test/exception_notifier/email_notifier_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,25 +353,3 @@ def index; end
assert_equal '[ERROR] (ZeroDivisionError) "divided by 0"', mail.subject
end
end

class EmailNotifierWithCustomParentClassTest < ActiveSupport::TestCase
class ApplicationMailer < ActionMailer::Base
default from: 'infrastructure@example.com'
end

setup do
@exception = ZeroDivisionError.new('divided by 0')
@exception.set_backtrace(["#{__FILE__}:#{__LINE__}"])
end

test 'uses default from configured parent class' do
email_notifier = ExceptionNotifier::EmailNotifier.new(
mailer_parent: 'EmailNotifierWithCustomParentClassTest::ApplicationMailer',
exception_recipients: %w[dummyexceptions@example.com]
)
mail = email_notifier.call(@exception)

assert email_notifier.__send__(:mailer) < ApplicationMailer
assert_equal ['infrastructure@example.com'], mail.from
end
end

0 comments on commit b33bc06

Please sign in to comment.