Fix domain mailer email sending for registrants without address

#330
This commit is contained in:
Artur Beljajev 2017-01-05 19:18:19 +02:00
parent 9a152b8289
commit eb95299c82
7 changed files with 78 additions and 8 deletions

View file

@ -21,5 +21,19 @@ FactoryGirl.define do
ident_type 'org'
ident '12345678' # valid reg no for .ee
end
factory :contact_with_address do
street 'test'
city 'test'
zip 12345
country_code 'EE'
end
factory :contact_without_address do
street nil
city nil
zip nil
country_code nil
end
end
end

View file

@ -4,5 +4,7 @@ FactoryGirl.define do
factory :registrant_private_entity, class: Registrant, parent: :contact_private_entity
factory :registrant_legal_entity, class: Registrant, parent: :contact_legal_entity
factory :registrant_with_address, class: Registrant, parent: :contact_with_address
factory :registrant_without_address, class: Registrant, parent: :contact_without_address
end
end

View file

@ -1,5 +1,59 @@
require 'rails_helper'
RSpec.describe DomainMailer do
describe '#registrant_updated_notification_for_new_registrant', db: true do
subject(:message) { described_class.registrant_updated_notification_for_new_registrant(55, 55, 55, true) }
context 'when contact address processing is enabled' do
before :example do
allow(Contact).to receive(:address_processing?).and_return(true)
create(:domain, id: 55)
create(:registrant_with_address, id: 55)
end
it 'sends message' do
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
context 'when contact address processing is disabled' do
before :example do
allow(Contact).to receive(:address_processing?).and_return(false)
create(:domain, id: 55)
create(:registrant_without_address, id: 55)
end
it 'sends message' do
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
end
describe '#registrant_updated_notification_for_old_registrant', db: true do
subject(:message) { described_class.registrant_updated_notification_for_old_registrant(55, 55, 55, true) }
context 'when contact address processing is enabled' do
before :example do
allow(Contact).to receive(:address_processing?).and_return(true)
create(:domain, id: 55)
create(:registrant_with_address, id: 55)
end
it 'sends message' do
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
context 'when contact address processing is disabled' do
before :example do
allow(Contact).to receive(:address_processing?).and_return(false)
create(:domain, id: 55)
create(:registrant_without_address, id: 55)
end
it 'sends message' do
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
end
end