diff --git a/spec/jobs/registrant_change_notice_email_job_spec.rb b/spec/jobs/registrant_change_notice_email_job_spec.rb deleted file mode 100644 index 1eb1d6d94..000000000 --- a/spec/jobs/registrant_change_notice_email_job_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'rails_helper' - -RSpec.describe RegistrantChangeNoticeEmailJob do - describe '#run' do - let(:domain) { instance_double(Domain, - id: 1, - name: 'test.com', - registrant_email: 'registrant@test.com', - registrar: 'registrar', - registrant: 'registrant') - } - let(:new_registrant) { instance_double(Registrant, email: 'new-registrant@test.com') } - let(:message) { instance_double(ActionMailer::MessageDelivery) } - - before :example do - expect(Domain).to receive(:find).and_return(domain) - expect(Registrant).to receive(:find).and_return(new_registrant) - end - - after :example do - domain_id = 1 - new_registrant_id = 1 - described_class.enqueue(domain_id, new_registrant_id) - end - - it 'creates log record' do - log_message = 'Send RegistrantChangeMailer#notice email for domain test.com (#1) to new-registrant@test.com' - - allow(RegistrantChangeMailer).to receive(:notice).and_return(message) - allow(message).to receive(:deliver_now) - - expect(Rails.logger).to receive(:info).with(log_message) - end - - it 'sends email' do - expect(RegistrantChangeMailer).to receive(:notice).with(domain: domain, - registrar: 'registrar', - current_registrant: 'registrant', - new_registrant: new_registrant) - .and_return(message) - expect(message).to receive(:deliver_now) - end - end -end diff --git a/test/jobs/registrant_change_notice_email_job_test.rb b/test/jobs/registrant_change_notice_email_job_test.rb new file mode 100644 index 000000000..8213ea3b9 --- /dev/null +++ b/test/jobs/registrant_change_notice_email_job_test.rb @@ -0,0 +1,18 @@ +require 'test_helper' + +class RegistrantChangeNoticeEmailJobTest < ActiveSupport::TestCase + include ActionMailer::TestHelper + + setup do + ActionMailer::Base.deliveries.clear + end + + def test_delivers_email + domain_id = domains(:shop).id + new_registrant_id = contacts(:william).id + + RegistrantChangeNoticeEmailJob.enqueue(domain_id, new_registrant_id) + + assert_emails 1 + end +end \ No newline at end of file