-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
an enhanced MailDeliveryJob that propagates smtp_settings #2070
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class EnhancedMailDeliveryJob < ActionMailer::MailDeliveryJob | ||
# makes sure any changes to the smtp and host settings are picked up without having to restart delayed job | ||
before_perform do | ||
# make sure the SMTP,site_base_host configuration is in sync with current SEEK settings | ||
Seek::Config.smtp_propagate | ||
Seek::Config.site_base_host_propagate | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'test_helper' | ||
require 'minitest/mock' | ||
|
||
class EnhancedMailDeliveryJobTest < ActiveSupport::TestCase | ||
test 'perform' do | ||
with_config_value(:email_enabled, true) do | ||
|
||
assert_enqueued_jobs(1, only: EnhancedMailDeliveryJob, queue: QueueNames::MAILERS) do | ||
Mailer.test_email('fred@email.com').deliver_later | ||
end | ||
|
||
smtp_propagate_called = false | ||
site_base_host_propagate_called = false | ||
|
||
Seek::Config.stub :smtp_propagate, ->{smtp_propagate_called = true} do | ||
Seek::Config.stub :site_base_host_propagate, ->{site_base_host_propagate_called = true} do | ||
assert_emails 1 do | ||
assert_performed_jobs(1, only: EnhancedMailDeliveryJob) do | ||
Mailer.test_email('fred@email.com').deliver_later | ||
end | ||
end | ||
end | ||
end | ||
|
||
assert smtp_propagate_called | ||
assert site_base_host_propagate_called | ||
end | ||
end | ||
end |