Refactor domain mailer views

#180
This commit is contained in:
Artur Beljajev 2016-11-14 01:35:47 +02:00
parent a6de3761c5
commit 2c3dbc6e32
31 changed files with 361 additions and 153 deletions

View file

@ -891,4 +891,52 @@ RSpec.describe Domain, db: false do
expect(described_class.delete_candidates.ids).to eq([1])
end
end
describe '#pending_update!', db: false do
let(:domain) { described_class.new }
let(:current_registrant) { FactoryGirl.build_stubbed(:registrant) }
let(:new_registrant) { FactoryGirl.build_stubbed(:registrant) }
let(:message) { instance_double(Mail::Message) }
before :example do
expect(Registrant).to receive(:find).and_return(current_registrant)
expect(domain).to receive_messages(
reload: true,
pending_update?: false,
registrant_verification_asked?: true,
registrar: 'registrar',
registrant: new_registrant,
manage_automatic_statuses: true
)
end
it 'sends confirm and notice emails' do
allow(RegistrantChangeMailer).to receive(:notice).and_return(message)
expect(RegistrantChangeMailer).to receive(:confirm)
.with(
domain: domain,
registrar: 'registrar',
current_registrant: current_registrant,
new_registrant: new_registrant)
.and_return(message)
expect(RegistrantChangeMailer).to receive(:notice)
.with(
domain: domain,
registrar: 'registrar',
current_registrant: current_registrant,
new_registrant: new_registrant)
.and_return(message)
expect(message).to receive(:deliver).exactly(2).times
domain.pending_update!
end
end
describe '#new_registrant_email' do
let(:domain) { described_class.new(pending_json: { new_registrant_email: 'test@test.com' }) }
it 'returns new registrant\'s email' do
expect(domain.new_registrant_email).to eq('test@test.com')
end
end
end