mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
Merge branch 'master' into registry-270
This commit is contained in:
commit
bbf2e427fa
13 changed files with 146 additions and 65 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
38
spec/views/registrar/contacts/_form.haml_spec.rb
Normal file
38
spec/views/registrar/contacts/_form.haml_spec.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'registrar/contacts/_form' do
|
||||
let(:contact) { instance_spy(Depp::Contact) }
|
||||
|
||||
before :example do
|
||||
allow(view).to receive(:f).and_return(ActionView::Helpers::FormBuilder.new(:contact, contact, view, {}))
|
||||
assign(:contact, contact)
|
||||
|
||||
stub_template 'registrar/shared/_error_messages' => ''
|
||||
stub_template 'registrar/contacts/form_partials/_general' => ''
|
||||
stub_template 'registrar/contacts/form_partials/_address' => 'address info'
|
||||
stub_template 'registrar/contacts/form_partials/_code' => ''
|
||||
stub_template 'registrar/contacts/form_partials/_legal_document' => ''
|
||||
end
|
||||
|
||||
context 'when address processing is enabled' do
|
||||
before do
|
||||
allow(view).to receive(:address_processing?).and_return(true)
|
||||
end
|
||||
|
||||
it 'has address' do
|
||||
render
|
||||
expect(rendered).to have_text('address info')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when address processing is disabled' do
|
||||
before do
|
||||
allow(view).to receive(:address_processing?).and_return(false)
|
||||
end
|
||||
|
||||
it 'has no address' do
|
||||
render
|
||||
expect(rendered).to_not have_text('address info')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
module RequiredAddressFieldsHelper
|
||||
def define_field_examples(attr_name)
|
||||
describe "#{attr_name} field" do
|
||||
let(:field) { page.find("[name='depp_contact[#{attr_name}]']") }
|
||||
|
||||
context 'when address processing is enabled' do
|
||||
before do
|
||||
allow(view).to receive(:address_processing?).and_return(true)
|
||||
end
|
||||
|
||||
it 'is required' do
|
||||
render
|
||||
expect(field[:required]).to eq('required')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when address processing is disabled' do
|
||||
before do
|
||||
allow(view).to receive(:address_processing?).and_return(false)
|
||||
end
|
||||
|
||||
it 'is optional' do
|
||||
render
|
||||
expect(field[:required]).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.describe 'registrar/contacts/form_partials/_address' do
|
||||
extend RequiredAddressFieldsHelper
|
||||
let(:contact) { instance_spy(Depp::Contact) }
|
||||
|
||||
before do
|
||||
allow(view).to receive(:f).and_return(ActionView::Helpers::FormBuilder.new(:depp_contact, contact, view, {}))
|
||||
end
|
||||
|
||||
required_address_attributes = %i(
|
||||
street
|
||||
city
|
||||
zip
|
||||
country_code
|
||||
)
|
||||
|
||||
required_address_attributes.each do |attr_name|
|
||||
define_field_examples(attr_name)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue