mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
parent
39d7c6ad1d
commit
ad0220088a
30 changed files with 697 additions and 59 deletions
40
spec/jobs/domain_expiration_email_job_spec.rb
Normal file
40
spec/jobs/domain_expiration_email_job_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainExpirationEmailJob do
|
||||
it 'queues the job' do
|
||||
expect { described_class.perform_later }.to have_enqueued_job(described_class)
|
||||
end
|
||||
|
||||
describe '#perform' do
|
||||
let(:domain) { instance_double(Domain) }
|
||||
|
||||
before :example do
|
||||
expect(Domain).to receive(:find).and_return(domain)
|
||||
end
|
||||
|
||||
context 'when domain is expired' do
|
||||
let(:message) { instance_double(ActionMailer::MessageDelivery) }
|
||||
|
||||
before :example do
|
||||
allow(domain).to receive(:registered?).and_return(false)
|
||||
end
|
||||
|
||||
it 'sends email notification' do
|
||||
expect(DomainMailer).to receive(:expiration).with(domain: domain).and_return(message)
|
||||
expect(message).to receive(:deliver!)
|
||||
described_class.perform_now(domain_id: 1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when domain is registered' do
|
||||
before :example do
|
||||
allow(domain).to receive(:registered?).and_return(true)
|
||||
end
|
||||
|
||||
it 'does not send email notification' do
|
||||
expect(DomainMailer).to_not receive(:expiration)
|
||||
described_class.perform_now(domain_id: 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue