Skip to content

Commit

Permalink
Merge pull request #338 from internetee/registry-330
Browse files Browse the repository at this point in the history
Registry 330
  • Loading branch information
vohmar authored Jan 9, 2017
2 parents 8201ec3 + 01c6804 commit 7314a7e
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/mailers/domain_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def registrant_updated_notification_for_new_registrant(domain_id, old_registrant

@old_registrant = Registrant.find(old_registrant_id)
@new_registrant = Registrant.find(new_registrant_id)
@address_processing = Contact.address_processing?

return if whitelist_blocked?(@new_registrant.email)
mail(to: format(@new_registrant.email),
Expand All @@ -23,6 +24,7 @@ def registrant_updated_notification_for_old_registrant(domain_id, old_registrant

@old_registrant = Registrant.find(old_registrant_id)
@new_registrant = Registrant.find(new_registrant_id)
@address_processing = Contact.address_processing?

return if whitelist_blocked?(@old_registrant.email)
mail(to: format(@old_registrant.email),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ Nimi: <%= @new_registrant.name %><br>
Äriregistrikood: <%= @new_registrant.ident %><br>
<% end %>
Epost: <%= @new_registrant.email %><br>
<% if @address_processing -%>
Tänav: <%= @new_registrant.street %><br>
Linn: <%= @new_registrant.city %><br>
Riik: <%= @new_registrant.country.name %>
<% end -%>
<br><br>
Lugupidamisega<br>
Eesti Interneti Sihtasutus
Expand All @@ -31,9 +33,11 @@ Name: <%= @new_registrant.name %><br>
Business Registry code: <%= @new_registrant.ident %><br>
<% end %>
E-mail: <%= @new_registrant.email %><br>
<% if @address_processing -%>
Street: <%= @new_registrant.street %><br>
City: <%= @new_registrant.city %><br>
Country: <%= @new_registrant.country.name %>
<% end -%>
<br><br>
Best Regards,<br>
Estonian Internet Foundation
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ Nimi: <%= @new_registrant.name %>
Äriregistrikood: <%= @new_registrant.ident %>
<% end %>
Epost: <%= @new_registrant.email %>
<% if @address_processing -%>
Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
Riik: <%= @new_registrant.country.name %>
<% end -%>

Lugupidamisega
Eesti Interneti Sihtasutus
Expand All @@ -33,9 +35,11 @@ Name: <%= @new_registrant.name %>
Business Registry code: <%= @new_registrant.ident %>
<% end %>
E-mail: <%= @new_registrant.email %>
<% if @address_processing -%>
Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
Country: <%= @new_registrant.country.name %>
<% end -%>

Best Regards,
Estonian Internet Foundation
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ Isikukood: <%= @new_registrant.ident %><br>
Äriregistrikood: <%= @new_registrant.ident %><br>
<% end %>
Epost: <%= @new_registrant.email %><br>
<% if @address_processing -%>
Tänav: <%= @new_registrant.street %><br>
Linn: <%= @new_registrant.city %><br>
Riik: <%= @new_registrant.country.name %>
<% end -%>
<br><br>
Lugupidamisega<br>
Eesti Interneti Sihtasutus
Expand All @@ -31,9 +33,11 @@ Personal code: <%= @new_registrant.ident %><br>
Business Registry code: <%= @new_registrant.ident %><br>
<% end %>
E-mail: <%= @new_registrant.email %><br>
<% if @address_processing -%>
Street: <%= @new_registrant.street %><br>
City: <%= @new_registrant.city %><br>
Country: <%= @new_registrant.country.name %>
<% end -%>
<br><br>
Best Regards,<br>
Estonian Internet Foundation
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ Isikukood: <%= @new_registrant.ident %>
Äriregistrikood: <%= @new_registrant.ident %>
<% end %>
Epost: <%= @new_registrant.email %>
<% if @address_processing -%>
Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
Riik: <%= @new_registrant.country.name %>
<% end -%>

Lugupidamisega
Eesti Interneti Sihtasutus
Expand All @@ -33,9 +35,11 @@ Personal code: <%= @new_registrant.ident %>
Business Registry code: <%= @new_registrant.ident %>
<% end %>
E-mail: <%= @new_registrant.email %>
<% if @address_processing -%>
Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
Country: <%= @new_registrant.country.name %>
<% end -%>

Best Regards,
Estonian Internet Foundation
14 changes: 14 additions & 0 deletions spec/factories/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,19 @@
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
2 changes: 2 additions & 0 deletions spec/factories/registrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

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
4 changes: 4 additions & 0 deletions spec/factory_lint_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require_relative 'rails_helper'

RSpec.describe 'FactoryGirl', db: true do
before :example do
allow(Contact).to receive(:address_processing?).and_return(false)
end

it 'lints factories' do
FactoryGirl.lint
end
Expand Down
54 changes: 54 additions & 0 deletions spec/mailers/domain_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7314a7e

Please sign in to comment.