2023-01-11 09:44:39 +01:00
|
|
|
RSpec.describe DeviseUserMailer, type: :mailer do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:token) { SecureRandom.hex }
|
|
|
|
describe '.confirmation_instructions' do
|
2023-10-18 07:10:26 +02:00
|
|
|
subject { described_class.confirmation_instructions(user, token, opts = {}) }
|
|
|
|
|
2023-01-11 09:44:39 +01:00
|
|
|
context 'without SafeMailer configured' do
|
|
|
|
it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) }
|
|
|
|
end
|
2023-10-18 07:10:26 +02:00
|
|
|
|
2023-01-11 09:44:39 +01:00
|
|
|
context 'with SafeMailer configured' do
|
|
|
|
let(:forced_delivery_method) { :kikoo }
|
|
|
|
before { allow(SafeMailer).to receive(:forced_delivery_method).and_return(forced_delivery_method) }
|
|
|
|
it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(forced_delivery_method.to_s) }
|
|
|
|
end
|
2023-10-18 07:10:26 +02:00
|
|
|
|
|
|
|
context 'when perform_later is called' do
|
|
|
|
it 'enqueues email in default queue for high priority delivery' do
|
|
|
|
expect { subject.deliver_later }.to have_enqueued_job.on_queue(Rails.application.config.action_mailer.deliver_later_queue_name)
|
|
|
|
end
|
|
|
|
end
|
2023-01-11 09:44:39 +01:00
|
|
|
end
|
|
|
|
end
|