mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Merge branch 'convert-specs-to-tests' into remove-delegations
This commit is contained in:
commit
ac1a1b058c
2 changed files with 18 additions and 44 deletions
|
@ -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
|
|
18
test/jobs/registrant_change_notice_email_job_test.rb
Normal file
18
test/jobs/registrant_change_notice_email_job_test.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue