Refactor domain expiration mailer

#186
This commit is contained in:
Artur Beljajev 2016-11-17 00:04:13 +02:00
parent 97426e001b
commit fa47eb3ab6
13 changed files with 129 additions and 43 deletions

View file

@ -31,33 +31,4 @@ RSpec.describe DomainMailer do
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
describe '#expiration' do
let(:domain) { instance_spy(Domain, name: 'test.com') }
let(:domain_presenter) { instance_spy(DomainPresenter) }
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
subject(:message) { described_class.expiration(domain: domain) }
before :example do
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
end
it 'has sender' do
expect(message.from).to eq(['noreply@internet.ee'])
end
it 'has recipient' do
expect(domain).to receive(:primary_contact_emails).and_return(['recipient@test.com'])
expect(message.to).to match_array(['recipient@test.com'])
end
it 'has valid subject' do
expect(message.subject).to eq('The test.com domain has expired')
end
it 'sends message' do
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
end