Merge remote-tracking branch 'origin/registry-660' into registry-661

# Conflicts:
#	db/structure.sql
#	doc/repp-doc.md
This commit is contained in:
Artur Beljajev 2018-01-30 00:58:49 +02:00
commit 56e3f236bc
156 changed files with 2085 additions and 1276 deletions

View file

@ -1,7 +0,0 @@
FactoryBot.define do
factory :domain_transfer do
domain
transfer_from { FactoryBot.create(:registrar) }
transfer_to { FactoryBot.create(:registrar) }
end
end

View file

@ -1,14 +0,0 @@
require 'rails_helper'
RSpec.feature 'CSV Export' do
background do
Setting.api_ip_whitelist_enabled = false
Setting.registrar_ip_whitelist_enabled = false
sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance))
end
scenario 'exports csv' do
visit registrar_domains_url
click_link_or_button 'Download'
end
end

View file

@ -63,7 +63,7 @@ RSpec.describe Contact do
context 'with valid attributes' do
before :example do
@contact = create(:contact, auth_info: 'password')
@contact = create(:contact)
end
it 'should have one version' do
@ -87,10 +87,6 @@ RSpec.describe Contact do
@contact.code.should == old_code
end
it 'should have static password' do
@contact.auth_info.should == 'password'
end
it 'should have ok status by default' do
@contact.statuses.should == %w(ok)
end
@ -171,36 +167,22 @@ RSpec.describe Contact do
end
context 'with callbacks' do
before :example do
# Ensure callbacks are not taken out from other specs
Contact.set_callback(:create, :before, :generate_auth_info)
end
context 'after create' do
it 'should not allow to use same code' do
registrar = create(:registrar, code: 'FIXED')
create(:contact,
registrar: registrar,
code: 'FIXED:new-code',
auth_info: 'qwe321')
code: 'FIXED:new-code')
@contact = build(:contact,
registrar: registrar,
code: 'FIXED:new-code',
auth_info: 'qwe321')
code: 'FIXED:new-code')
@contact.validate
expect(@contact.errors).to have_key(:code)
end
it 'should generate a new password' do
@contact = build(:contact, code: '123asd', auth_info: nil)
@contact.auth_info.should == nil
@contact.save.should == true
@contact.auth_info.should_not be_nil
end
it 'should allow supported code format' do
@contact = build(:contact, code: 'CID:REG1:12345', registrar: create(:registrar, code: 'FIXED'))
@contact.valid?
@ -227,29 +209,6 @@ RSpec.describe Contact do
@contact.code.should =~ /FIXED:..../
end
end
context 'after update' do
before :example do
@contact = build(:contact,
registrar: create(:registrar, code: 'FIXED'),
code: '123asd',
auth_info: 'qwe321')
@contact.generate_code
@contact.save
@contact.code.should == 'FIXED:123ASD'
@auth_info = @contact.auth_info
end
it 'should not generate new code' do
@contact.update_attributes(name: 'qevciherot23')
@contact.code.should == 'FIXED:123ASD'
end
it 'should not generate new auth_info' do
@contact.update_attributes(name: 'fvrsgbqevciherot23')
@contact.auth_info.should == @auth_info
end
end
end
end
end

View file

@ -538,11 +538,6 @@ RSpec.describe Domain do
expect(domain.errors[:base]).to include('Required parameter missing; reserved>pw element required for reserved domains')
end
it 'generates auth info' do
d = create(:domain)
expect(d.auth_info).to_not be_empty
end
it 'manages statuses automatically' do
d = build(:domain)

View file

@ -1,69 +0,0 @@
require 'rails_helper'
describe DomainTransfer do
before :example do
Setting.ds_algorithm = 2
Setting.ds_data_allowed = true
Setting.ds_data_with_key_allowed = true
Setting.key_data_allowed = true
Setting.dnskeys_min_count = 0
Setting.dnskeys_max_count = 9
Setting.ns_min_count = 2
Setting.ns_max_count = 11
Setting.transfer_wait_time = 0
Setting.admin_contacts_min_count = 1
Setting.admin_contacts_max_count = 10
Setting.tech_contacts_min_count = 0
Setting.tech_contacts_max_count = 10
Setting.client_side_status_editing_enabled = true
create(:zone, origin: 'ee')
end
context 'with invalid attribute' do
before :example do
@domain_transfer = DomainTransfer.new
end
it 'should not be valid' do
@domain_transfer.valid?
@domain_transfer.errors.full_messages.should match_array([
])
end
it 'should not have any versions' do
@domain_transfer.versions.should == []
end
end
context 'with valid attributes' do
before :example do
@domain_transfer = create(:domain_transfer)
end
it 'should be valid' do
@domain_transfer.valid?
@domain_transfer.errors.full_messages.should match_array([])
end
it 'should be valid twice' do
@domain_transfer = create(:domain_transfer)
@domain_transfer.valid?
@domain_transfer.errors.full_messages.should match_array([])
end
it 'should have one version' do
with_versioning do
@domain_transfer.versions.should == []
@domain_transfer.wait_until = 1.day.since
@domain_transfer.save
@domain_transfer.errors.full_messages.should match_array([])
@domain_transfer.versions.size.should == 1
end
end
end
end

View file

@ -151,6 +151,7 @@ RSpec.describe DomainPresenter do
domain_delegatable_attributes = %i(
name
transfer_code
registrant_name
registrant_id
registrant_code

View file

@ -1,45 +0,0 @@
require 'rails_helper'
RSpec.describe Registrar::DomainListCSVPresenter do
let(:domain) { instance_spy(DomainPresenter) }
let(:csv) { CSV.parse(described_class.new(domains: [domain], view: view).to_s, converters: :all) }
describe 'header' do
subject(:header) { csv.first }
it 'is present' do
columns = []
columns[0] = 'Domain'
columns[1] = 'Registrant name'
columns[2] = 'Registrant code'
columns[3] = 'Date of expiry'
columns
expect(header).to eq(columns)
end
end
describe 'row' do
subject(:row) { csv.second }
it 'has domain name' do
expect(domain).to receive(:name).and_return('test name')
expect(row[0]).to eq('test name')
end
it 'has registrant name' do
expect(domain).to receive(:registrant_name).and_return('test registrant name')
expect(row[1]).to eq('test registrant name')
end
it 'has registrant code' do
expect(domain).to receive(:registrant_code).and_return('test registrant code')
expect(row[2]).to eq('test registrant code')
end
it 'has expire date' do
expect(domain).to receive(:expire_date).and_return('expire date')
expect(row[3]).to eq('expire date')
end
end
end

View file

@ -1,24 +0,0 @@
require 'rails_helper'
RSpec.describe Registrar::DomainsController, db: true do
describe '#index' do
before do
sign_in_to_registrar_area
end
it 'responds with success' do
csv_presenter = instance_double(Registrar::DomainListCSVPresenter, to_s: 'csv')
expect(Registrar::DomainListCSVPresenter).to receive(:new).and_return(csv_presenter)
get registrar_domains_url(format: 'csv')
expect(response.body).to eq('csv')
end
it 'returns csv' do
get registrar_domains_url(format: 'csv')
expect(response).to have_http_status(:success)
end
end
end

View file

@ -1,11 +1,12 @@
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.command_name 'spec'
SimpleCov.start 'rails'
end
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)
if ENV['TRAVIS']
require 'simplecov'
SimpleCov.start
end
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest