mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
parent
eada1a66dd
commit
8a831ee92c
30 changed files with 205 additions and 201 deletions
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainExpirationEmailJob do
|
||||
RSpec.describe DomainExpireEmailJob do
|
||||
describe '#run' do
|
||||
let(:domain) { instance_double(Domain) }
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DeleteDomainMailer do
|
||||
describe '#pending' do
|
||||
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
||||
let(:old_registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
|
||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
||||
subject(:message) { described_class.pending(domain: domain, old_registrant: old_registrant) }
|
||||
|
||||
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 old registrant email as a recipient' do
|
||||
expect(message.to).to match_array(['registrant@test.com'])
|
||||
end
|
||||
|
||||
it 'has subject' do
|
||||
subject = 'Kinnitustaotlus domeeni test.com kustutamiseks .ee registrist' \
|
||||
' / Application for approval for deletion of test.com'
|
||||
|
||||
expect(message.subject).to eq(subject)
|
||||
end
|
||||
|
||||
it 'has confirmation url' do
|
||||
allow(domain).to receive(:id).and_return(1)
|
||||
expect(domain).to receive(:registrant_verification_token).and_return('test')
|
||||
url = registrant_domain_delete_confirm_url(domain, token: 'test')
|
||||
expect(message.body.parts.first.decoded).to include(url)
|
||||
end
|
||||
|
||||
it 'sends message' do
|
||||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
82
spec/mailers/domain_delete_mailer_spec.rb
Normal file
82
spec/mailers/domain_delete_mailer_spec.rb
Normal file
|
@ -0,0 +1,82 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainDeleteMailer do
|
||||
describe '#confirm' do
|
||||
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
||||
let(:registrar) { instance_spy(Registrar) }
|
||||
let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
|
||||
|
||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
||||
|
||||
subject(:message) { described_class.confirm(domain: domain,
|
||||
registrar: registrar,
|
||||
registrant: registrant)
|
||||
}
|
||||
|
||||
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 registrant\'s email as a recipient' do
|
||||
expect(message.to).to match_array(['registrant@test.com'])
|
||||
end
|
||||
|
||||
it 'has subject' do
|
||||
subject = 'Kinnitustaotlus domeeni test.com kustutamiseks .ee registrist' \
|
||||
' / Application for approval for deletion of test.com'
|
||||
|
||||
expect(message.subject).to eq(subject)
|
||||
end
|
||||
|
||||
it 'has confirm url' do
|
||||
allow(domain).to receive(:id).and_return(1)
|
||||
expect(domain).to receive(:registrant_verification_token).and_return('test')
|
||||
url = registrant_domain_delete_confirm_url(domain, token: 'test')
|
||||
expect(message.body.parts.first.decoded).to include(url)
|
||||
end
|
||||
|
||||
it 'sends message' do
|
||||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#forced' do
|
||||
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
||||
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
|
||||
subject(:message) { described_class.forced(domain: domain,
|
||||
registrar: 'registrar',
|
||||
registrant: 'registrant')
|
||||
}
|
||||
|
||||
before :example do
|
||||
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
||||
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
|
||||
expect(RegistrantPresenter).to receive(:new).and_return(registrant_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('Kustutusmenetluse teade')
|
||||
end
|
||||
|
||||
it 'sends message' do
|
||||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,34 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainMailer do
|
||||
describe '#force_delete' do
|
||||
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
||||
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
|
||||
subject(:message) { described_class.force_delete(domain: domain) }
|
||||
|
||||
before :example do
|
||||
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
||||
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
|
||||
expect(RegistrantPresenter).to receive(:new).and_return(registrant_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('Kustutusmenetluse teade')
|
||||
end
|
||||
|
||||
it 'sends message' do
|
||||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -805,26 +805,6 @@ RSpec.describe Domain, db: false do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#pending_delete!' do
|
||||
let(:domain) { described_class.new }
|
||||
let(:old_registrant) { instance_double(Registrant) }
|
||||
let(:message) { instance_double(Mail::Message) }
|
||||
|
||||
before :example do
|
||||
expect(Registrant).to receive(:find).and_return(old_registrant)
|
||||
allow(domain).to receive(:registrant_verification_asked?).and_return(true)
|
||||
allow(domain).to receive(:save)
|
||||
end
|
||||
|
||||
it 'sends notification email' do
|
||||
expect(DeleteDomainMailer).to receive(:pending)
|
||||
.with(domain: domain, old_registrant: old_registrant)
|
||||
.and_return(message)
|
||||
expect(message).to receive(:deliver)
|
||||
domain.pending_delete!
|
||||
end
|
||||
end
|
||||
|
||||
describe '#set_graceful_expired' do
|
||||
let(:domain) { described_class.new }
|
||||
|
||||
|
@ -877,46 +857,6 @@ RSpec.describe Domain, db: false do
|
|||
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' }) }
|
||||
|
||||
|
@ -924,4 +864,12 @@ RSpec.describe Domain, db: false do
|
|||
expect(domain.new_registrant_email).to eq('test@test.com')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#new_registrant_id' do
|
||||
let(:domain) { described_class.new(pending_json: { new_registrant_id: 1 }) }
|
||||
|
||||
it 'returns new registrant\'s id' do
|
||||
expect(domain.new_registrant_id).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'pending_shared'
|
||||
require_relative 'confirm_shared'
|
||||
|
||||
RSpec.describe 'mailers/delete_domain_mailer/pending.html.erb' do
|
||||
RSpec.describe 'mailers/domain_delete_mailer/confirm.html.erb' do
|
||||
before :example do
|
||||
stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
|
||||
stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'
|
||||
end
|
||||
|
||||
include_examples 'delete domain mailer pending'
|
||||
include_examples 'domain delete mailer confirm'
|
||||
end
|
|
@ -1,11 +1,11 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'pending_shared'
|
||||
require_relative 'confirm_shared'
|
||||
|
||||
RSpec.describe 'mailers/delete_domain_mailer/pending.text.erb' do
|
||||
RSpec.describe 'mailers/domain_delete_mailer/confirm.text.erb' do
|
||||
before :example do
|
||||
stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
|
||||
stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'
|
||||
end
|
||||
|
||||
include_examples 'delete domain mailer pending'
|
||||
include_examples 'domain delete mailer confirm'
|
||||
end
|
|
@ -1,13 +1,13 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.shared_examples 'delete domain mailer pending' do
|
||||
RSpec.shared_examples 'domain delete mailer confirm' do
|
||||
let(:domain) { instance_spy(DomainPresenter) }
|
||||
let(:lang_count) { 2 }
|
||||
|
||||
before :example do
|
||||
assign(:domain, domain)
|
||||
assign(:registrar, nil)
|
||||
assign(:verification_url, 'test verification url')
|
||||
assign(:confirm_url, 'test confirm url')
|
||||
end
|
||||
|
||||
it 'has registrar info in estonian' do
|
||||
|
@ -27,9 +27,9 @@ RSpec.shared_examples 'delete domain mailer pending' do
|
|||
expect(rendered).to have_text('test domain name', count: mention_count)
|
||||
end
|
||||
|
||||
it 'has verification url' do
|
||||
it 'has confirm url' do
|
||||
mention_count = 1 * lang_count
|
||||
render
|
||||
expect(rendered).to have_text('test verification url', count: mention_count)
|
||||
expect(rendered).to have_text('test confirm url', count: mention_count)
|
||||
end
|
||||
end
|
|
@ -1,12 +1,12 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'force_delete_shared'
|
||||
require_relative 'forced_shared'
|
||||
|
||||
RSpec.describe 'mailers/domain_mailer/force_delete.html.erb' do
|
||||
RSpec.describe 'mailers/domain_delete_mailer/forced.html.erb' do
|
||||
before :example do
|
||||
stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
|
||||
stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'
|
||||
stub_template 'mailers/shared/registrar/_registrar.ru.html' => 'test registrar russian'
|
||||
end
|
||||
|
||||
include_examples 'domain mailer force delete'
|
||||
include_examples 'domain delete mailer forced'
|
||||
end
|
|
@ -1,12 +1,12 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'force_delete_shared'
|
||||
require_relative 'forced_shared'
|
||||
|
||||
RSpec.describe 'mailers/domain_mailer/force_delete.text.erb' do
|
||||
RSpec.describe 'mailers/domain_delete_mailer/forced.text.erb' do
|
||||
before :example do
|
||||
stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
|
||||
stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'
|
||||
stub_template 'mailers/shared/registrar/_registrar.ru.text' => 'test registrar russian'
|
||||
end
|
||||
|
||||
include_examples 'domain mailer force delete'
|
||||
include_examples 'domain delete mailer forced'
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.shared_examples 'domain mailer force delete' do
|
||||
RSpec.shared_examples 'domain delete mailer forced' do
|
||||
let(:domain) { instance_spy(DomainPresenter) }
|
||||
let(:registrar) { instance_spy(RegistrarPresenter) }
|
||||
let(:registrant) { instance_spy(RegistrantPresenter) }
|
Loading…
Add table
Add a link
Reference in a new issue