mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Use FactoryBot factories instead of fabricators
This commit is contained in:
parent
0cd913daf8
commit
9fd02c738f
30 changed files with 241 additions and 267 deletions
|
@ -1,8 +1,8 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Repp::ContactV1, db: true do
|
RSpec.describe Repp::ContactV1, db: true do
|
||||||
let(:user) { FactoryGirl.create(:api_user, registrar: registrar) }
|
let(:user) { create(:api_user, registrar: registrar) }
|
||||||
let(:registrar) { FactoryGirl.create(:registrar) }
|
let(:registrar) { create(:registrar) }
|
||||||
|
|
||||||
describe '/contacts' do
|
describe '/contacts' do
|
||||||
let(:returned_attributes) { HashWithIndifferentAccess.new(JSON.parse(response.body)['contacts'].first).keys }
|
let(:returned_attributes) { HashWithIndifferentAccess.new(JSON.parse(response.body)['contacts'].first).keys }
|
||||||
|
@ -13,7 +13,7 @@ RSpec.describe Repp::ContactV1, db: true do
|
||||||
allow(endpoint).to receive(:current_user).and_return(user)
|
allow(endpoint).to receive(:current_user).and_return(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
registrar.contacts << FactoryGirl.create(:contact)
|
registrar.contacts << create(:contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'responds with success' do
|
it 'responds with success' do
|
||||||
|
|
|
@ -10,5 +10,6 @@ FactoryGirl.define do
|
||||||
'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
|
'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
|
||||||
'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
|
'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
|
||||||
'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs='
|
'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs='
|
||||||
|
domain
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.feature 'Mobile ID login', db: true do
|
RSpec.feature 'Mobile ID login', db: true do
|
||||||
given!(:api_user) { Fabricate(:api_user, identity_code: 1234) }
|
given!(:api_user) { create(:api_user, identity_code: 1234) }
|
||||||
|
|
||||||
background do
|
background do
|
||||||
Setting.registrar_ip_whitelist_enabled = false
|
Setting.registrar_ip_whitelist_enabled = false
|
||||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe AdminUser do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before do
|
before do
|
||||||
@admin_user = Fabricate(:admin_user)
|
@admin_user = create(:admin_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should require password confirmation when changing password' do
|
it 'should require password confirmation when changing password' do
|
||||||
|
|
|
@ -28,7 +28,7 @@ RSpec.describe ApiUser do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before do
|
before do
|
||||||
@api_user = Fabricate(:api_user)
|
@api_user = create(:api_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -37,7 +37,7 @@ RSpec.describe ApiUser do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@api_user = Fabricate(:api_user)
|
@api_user = create(:api_user)
|
||||||
@api_user.valid?
|
@api_user.valid?
|
||||||
@api_user.errors.full_messages.should match_array([])
|
@api_user.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,9 +20,8 @@ describe BankStatement do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :all do
|
before do
|
||||||
@bank_statement = Fabricate(:bank_statement)
|
@bank_statement = create(:bank_statement)
|
||||||
Fabricate(:eis)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -31,67 +30,32 @@ describe BankStatement do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@bank_statement = Fabricate(:bank_statement)
|
@bank_statement = create(:bank_statement)
|
||||||
@bank_statement.valid?
|
@bank_statement.valid?
|
||||||
@bank_statement.errors.full_messages.should match_array([])
|
@bank_statement.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should bind transactions with invoices' do
|
|
||||||
# sometimes it works, sometimes not
|
|
||||||
# r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663')
|
|
||||||
# invoice = r.issue_prepayment_invoice(200, 'add some money')
|
|
||||||
|
|
||||||
# bs = Fabricate(:bank_statement, bank_transactions: [
|
|
||||||
# Fabricate(:bank_transaction, {
|
|
||||||
# sum: 240.0, # with vat
|
|
||||||
# reference_no: 'RF7086666663',
|
|
||||||
# description: "Invoice no. #{invoice.number}"
|
|
||||||
# }),
|
|
||||||
# Fabricate(:bank_transaction, {
|
|
||||||
# sum: 240.0,
|
|
||||||
# reference_no: 'RF7086666663',
|
|
||||||
# description: "Invoice no. #{invoice.number}"
|
|
||||||
# })
|
|
||||||
# ])
|
|
||||||
|
|
||||||
# bs.bank_transactions.count.should == 2
|
|
||||||
|
|
||||||
# AccountActivity.count.should == 0
|
|
||||||
# bs.bind_invoices
|
|
||||||
|
|
||||||
# AccountActivity.count.should == 1
|
|
||||||
|
|
||||||
# a = AccountActivity.last
|
|
||||||
# a.description.should == "Invoice no. #{invoice.number}"
|
|
||||||
# a.sum.should == BigDecimal.new('200.0')
|
|
||||||
# a.activity_type = AccountActivity::ADD_CREDIT
|
|
||||||
|
|
||||||
# r.reload
|
|
||||||
# r.cash_account.reload
|
|
||||||
# r.cash_account.balance.should == 200.0
|
|
||||||
|
|
||||||
# bs.bank_transactions.unbinded.count.should == 1
|
|
||||||
# bs.partially_binded?.should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not bind transactions with invalid match data' do
|
it 'should not bind transactions with invalid match data' do
|
||||||
r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663')
|
r = create(:registrar, reference_no: 'RF7086666663')
|
||||||
|
|
||||||
|
create(:account, registrar: r, account_type: 'cash', balance: 0)
|
||||||
|
|
||||||
r.issue_prepayment_invoice(200, 'add some money')
|
r.issue_prepayment_invoice(200, 'add some money')
|
||||||
|
|
||||||
bs = Fabricate(:bank_statement, bank_transactions: [
|
bs = create(:bank_statement, bank_transactions: [
|
||||||
Fabricate(:bank_transaction, {
|
create(:bank_transaction, {
|
||||||
sum: 240.0, # with vat
|
sum: 240.0, # with vat
|
||||||
reference_no: 'RF7086666662',
|
reference_no: 'RF7086666662',
|
||||||
description: 'Invoice no. 1'
|
description: 'Invoice no. 1'
|
||||||
}),
|
}),
|
||||||
Fabricate(:bank_transaction, {
|
create(:bank_transaction, {
|
||||||
sum: 240.0,
|
sum: 240.0,
|
||||||
reference_no: 'RF7086666663',
|
reference_no: 'RF7086666663',
|
||||||
description: 'Invoice no. 4948934'
|
description: 'Invoice no. 4948934'
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
|
|
||||||
bs.bank_transactions.count.should == 2
|
bs.bank_transactions.count.should == 4
|
||||||
|
|
||||||
AccountActivity.count.should == 0
|
AccountActivity.count.should == 0
|
||||||
bs.bind_invoices
|
bs.bind_invoices
|
||||||
|
@ -100,7 +64,7 @@ describe BankStatement do
|
||||||
|
|
||||||
r.cash_account.balance.should == 0.0
|
r.cash_account.balance.should == 0.0
|
||||||
|
|
||||||
bs.bank_transactions.unbinded.count.should == 2
|
bs.bank_transactions.unbinded.count.should == 4
|
||||||
bs.not_binded?.should == true
|
bs.not_binded?.should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe BankTransaction do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :all do
|
before :all do
|
||||||
@bank_transaction = Fabricate(:bank_transaction)
|
@bank_transaction = create(:bank_transaction)
|
||||||
Fabricate(:eis)
|
create(:registrar)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -29,27 +29,27 @@ describe BankTransaction do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@bank_transaction = Fabricate(:bank_statement)
|
@bank_transaction = create(:bank_statement)
|
||||||
@bank_transaction.valid?
|
@bank_transaction.valid?
|
||||||
@bank_transaction.errors.full_messages.should match_array([])
|
@bank_transaction.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not bind transaction with mismatching sums' do
|
it 'should not bind transaction with mismatching sums' do
|
||||||
r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663')
|
r = create(:registrar, reference_no: 'RF7086666663')
|
||||||
invoice = r.issue_prepayment_invoice(200, 'add some money')
|
invoice = r.issue_prepayment_invoice(200, 'add some money')
|
||||||
|
|
||||||
bt = Fabricate(:bank_transaction, { sum: 10 })
|
bt = create(:bank_transaction, { sum: 10 })
|
||||||
bt.bind_invoice(invoice.number)
|
bt.bind_invoice(invoice.number)
|
||||||
|
|
||||||
bt.errors.full_messages.should match_array(["Invoice and transaction sums do not match"])
|
bt.errors.full_messages.should match_array(["Invoice and transaction sums do not match"])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not bind transaction with cancelled invoice' do
|
it 'should not bind transaction with cancelled invoice' do
|
||||||
r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663')
|
r = create(:registrar, reference_no: 'RF7086666663')
|
||||||
invoice = r.issue_prepayment_invoice(200, 'add some money')
|
invoice = r.issue_prepayment_invoice(200, 'add some money')
|
||||||
invoice.cancel
|
invoice.cancel
|
||||||
|
|
||||||
bt = Fabricate(:bank_transaction, { sum: 240 })
|
bt = create(:bank_transaction, { sum: 240 })
|
||||||
bt.bind_invoice(invoice.number)
|
bt.bind_invoice(invoice.number)
|
||||||
|
|
||||||
bt.errors.full_messages.should match_array(["Cannot bind cancelled invoice"])
|
bt.errors.full_messages.should match_array(["Cannot bind cancelled invoice"])
|
||||||
|
|
|
@ -7,11 +7,11 @@ RSpec.describe Domain, db: false do
|
||||||
before :example do
|
before :example do
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
travel_to Time.zone.parse('05.07.2010 00:00')
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
|
|
||||||
Fabricate.create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59'))
|
create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59'))
|
||||||
Fabricate.create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00'))
|
create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00'))
|
||||||
Fabricate.create(:domain, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01'))
|
create(:domain, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01'))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns expired domains' do
|
it 'returns expired domains' do
|
||||||
|
|
|
@ -4,11 +4,15 @@ RSpec.describe Domain do
|
||||||
it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) }
|
it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) }
|
||||||
|
|
||||||
before :example do
|
before :example do
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should set force delete time' do
|
it 'should set force delete time' do
|
||||||
domain = Fabricate(:domain)
|
domain = build(:domain)
|
||||||
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
|
domain.save!
|
||||||
|
|
||||||
domain.statuses = ['ok']
|
domain.statuses = ['ok']
|
||||||
domain.schedule_force_delete
|
domain.schedule_force_delete
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Contact do
|
RSpec.describe Contact do
|
||||||
before :example do
|
before :example do
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'about class' do
|
context 'about class' do
|
||||||
|
@ -102,7 +102,7 @@ RSpec.describe Contact do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@contact = Fabricate(:contact)
|
@contact = create(:contact, auth_info: 'password')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have one version' do
|
it 'should have one version' do
|
||||||
|
@ -120,7 +120,7 @@ RSpec.describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'org should be valid' do
|
it 'org should be valid' do
|
||||||
contact = Fabricate.build(:contact, ident_type: 'org', ident: '1' * 8)
|
contact = build(:contact, ident_type: 'org', ident: '1' * 8)
|
||||||
|
|
||||||
contact.validate
|
contact.validate
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ RSpec.describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should remove ok status when other non linked status present' do
|
it 'should remove ok status when other non linked status present' do
|
||||||
contact = Fabricate(:contact)
|
contact = create(:contact)
|
||||||
contact.statuses = [Contact::SERVER_UPDATE_PROHIBITED]
|
contact.statuses = [Contact::SERVER_UPDATE_PROHIBITED]
|
||||||
contact.statuses.should == [Contact::SERVER_UPDATE_PROHIBITED] # temp test
|
contact.statuses.should == [Contact::SERVER_UPDATE_PROHIBITED] # temp test
|
||||||
contact.save
|
contact.save
|
||||||
|
@ -157,9 +157,9 @@ RSpec.describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have code' do
|
it 'should have code' do
|
||||||
registrar = Fabricate.create(:registrar, code: 'registrarcode')
|
registrar = create(:registrar, code: 'registrarcode')
|
||||||
|
|
||||||
contact = Fabricate.build(:contact, registrar: registrar, code: 'contactcode')
|
contact = build(:contact, registrar: registrar, code: 'contactcode')
|
||||||
contact.generate_code
|
contact.generate_code
|
||||||
contact.save!
|
contact.save!
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ RSpec.describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save status notes' do
|
it 'should save status notes' do
|
||||||
contact = Fabricate(:contact)
|
contact = create(:contact)
|
||||||
contact.statuses = ['serverDeleteProhibited', 'serverUpdateProhibited']
|
contact.statuses = ['serverDeleteProhibited', 'serverUpdateProhibited']
|
||||||
contact.status_notes_array = [nil, 'update manually turned off']
|
contact.status_notes_array = [nil, 'update manually turned off']
|
||||||
contact.status_notes['serverDeleteProhibited'].should == nil
|
contact.status_notes['serverDeleteProhibited'].should == nil
|
||||||
|
@ -181,7 +181,7 @@ RSpec.describe Contact do
|
||||||
|
|
||||||
it 'should have not update ident updated at when initializing old contact' do
|
it 'should have not update ident updated at when initializing old contact' do
|
||||||
# creating a legacy contact
|
# creating a legacy contact
|
||||||
contact = Fabricate(:contact)
|
contact = create(:contact)
|
||||||
contact.update_column(:ident_updated_at, nil)
|
contact.update_column(:ident_updated_at, nil)
|
||||||
|
|
||||||
Contact.find(contact.id).ident_updated_at.should == nil
|
Contact.find(contact.id).ident_updated_at.should == nil
|
||||||
|
@ -189,7 +189,7 @@ RSpec.describe Contact do
|
||||||
|
|
||||||
context 'as birthday' do
|
context 'as birthday' do
|
||||||
before do
|
before do
|
||||||
@domain = Fabricate(:domain)
|
@domain = create(:domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have related domain descriptions hash' do
|
it 'should have related domain descriptions hash' do
|
||||||
|
@ -250,13 +250,13 @@ RSpec.describe Contact do
|
||||||
|
|
||||||
context 'after create' do
|
context 'after create' do
|
||||||
it 'should not allow to use same code' do
|
it 'should not allow to use same code' do
|
||||||
registrar = Fabricate.create(:registrar, code: 'FIXED')
|
registrar = create(:registrar, code: 'FIXED')
|
||||||
|
|
||||||
Fabricate.create(:contact,
|
create(:contact,
|
||||||
registrar: registrar,
|
registrar: registrar,
|
||||||
code: 'FIXED:new-code',
|
code: 'FIXED:new-code',
|
||||||
auth_info: 'qwe321')
|
auth_info: 'qwe321')
|
||||||
@contact = Fabricate.build(:contact,
|
@contact = build(:contact,
|
||||||
registrar: registrar,
|
registrar: registrar,
|
||||||
code: 'FIXED:new-code',
|
code: 'FIXED:new-code',
|
||||||
auth_info: 'qwe321')
|
auth_info: 'qwe321')
|
||||||
|
@ -267,33 +267,33 @@ RSpec.describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should generate a new password' do
|
it 'should generate a new password' do
|
||||||
@contact = Fabricate.build(:contact, code: '123asd', auth_info: nil)
|
@contact = build(:contact, code: '123asd', auth_info: nil)
|
||||||
@contact.auth_info.should == nil
|
@contact.auth_info.should == nil
|
||||||
@contact.save.should == true
|
@contact.save.should == true
|
||||||
@contact.auth_info.should_not be_nil
|
@contact.auth_info.should_not be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should allow supported code format' do
|
it 'should allow supported code format' do
|
||||||
@contact = Fabricate.build(:contact, code: 'CID:REG1:12345', registrar: Fabricate(:registrar, code: 'FIXED'))
|
@contact = build(:contact, code: 'CID:REG1:12345', registrar: create(:registrar, code: 'FIXED'))
|
||||||
@contact.valid?
|
@contact.valid?
|
||||||
@contact.errors.full_messages.should == []
|
@contact.errors.full_messages.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not allow unsupported characters in code' do
|
it 'should not allow unsupported characters in code' do
|
||||||
@contact = Fabricate.build(:contact, code: 'unsupported!ÄÖÜ~?', registrar: Fabricate(:registrar, code: 'FIXED'))
|
@contact = build(:contact, code: 'unsupported!ÄÖÜ~?', registrar: create(:registrar, code: 'FIXED'))
|
||||||
@contact.valid?
|
@contact.valid?
|
||||||
@contact.errors.full_messages.should == ['Code is invalid']
|
@contact.errors.full_messages.should == ['Code is invalid']
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should generate code if empty code is given' do
|
it 'should generate code if empty code is given' do
|
||||||
@contact = Fabricate.build(:contact, code: '')
|
@contact = build(:contact, code: '')
|
||||||
@contact.generate_code
|
@contact.generate_code
|
||||||
@contact.save!
|
@contact.save!
|
||||||
@contact.code.should_not == ''
|
@contact.code.should_not == ''
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not ignore empty spaces as code and generate new one' do
|
it 'should not ignore empty spaces as code and generate new one' do
|
||||||
@contact = Fabricate.build(:contact, code: ' ', registrar: Fabricate(:registrar, code: 'FIXED'))
|
@contact = build(:contact, code: ' ', registrar: create(:registrar, code: 'FIXED'))
|
||||||
@contact.generate_code
|
@contact.generate_code
|
||||||
@contact.valid?.should == true
|
@contact.valid?.should == true
|
||||||
@contact.code.should =~ /FIXED:..../
|
@contact.code.should =~ /FIXED:..../
|
||||||
|
@ -302,8 +302,8 @@ RSpec.describe Contact do
|
||||||
|
|
||||||
context 'after update' do
|
context 'after update' do
|
||||||
before :example do
|
before :example do
|
||||||
@contact = Fabricate.build(:contact,
|
@contact = build(:contact,
|
||||||
registrar: Fabricate(:registrar, code: 'FIXED'),
|
registrar: create(:registrar, code: 'FIXED'),
|
||||||
code: '123asd',
|
code: '123asd',
|
||||||
auth_info: 'qwe321')
|
auth_info: 'qwe321')
|
||||||
@contact.generate_code
|
@contact.generate_code
|
||||||
|
@ -328,9 +328,9 @@ end
|
||||||
|
|
||||||
describe Contact, '.destroy_orphans' do
|
describe Contact, '.destroy_orphans' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
@contact_1 = Fabricate(:contact, code: 'asd12')
|
@contact_1 = create(:contact, code: 'asd12')
|
||||||
@contact_2 = Fabricate(:contact, code: 'asd13')
|
@contact_2 = create(:contact, code: 'asd13')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'destroys orphans' do
|
it 'destroys orphans' do
|
||||||
|
@ -340,13 +340,13 @@ describe Contact, '.destroy_orphans' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should find one orphan' do
|
it 'should find one orphan' do
|
||||||
Fabricate(:domain, registrant: Registrant.find(@contact_1.id))
|
create(:domain, registrant: Registrant.find(@contact_1.id))
|
||||||
Contact.find_orphans.count.should == 1
|
Contact.find_orphans.count.should == 1
|
||||||
Contact.find_orphans.last.should == @contact_2
|
Contact.find_orphans.last.should == @contact_2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should find no orphans' do
|
it 'should find no orphans' do
|
||||||
Fabricate(:domain, registrant: Registrant.find(@contact_1.id), admin_contacts: [@contact_2])
|
create(:domain, registrant: Registrant.find(@contact_1.id), admin_contacts: [@contact_2])
|
||||||
cc = Contact.count
|
cc = Contact.count
|
||||||
Contact.find_orphans.count.should == 0
|
Contact.find_orphans.count.should == 0
|
||||||
Contact.destroy_orphans
|
Contact.destroy_orphans
|
||||||
|
@ -508,13 +508,13 @@ RSpec.describe Contact do
|
||||||
subject(:reg_no) { contact.reg_no }
|
subject(:reg_no) { contact.reg_no }
|
||||||
|
|
||||||
context 'when contact is legal entity' do
|
context 'when contact is legal entity' do
|
||||||
let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') }
|
let(:contact) { build_stubbed(:contact_legal_entity, ident: '1234') }
|
||||||
|
|
||||||
specify { expect(reg_no).to eq('1234') }
|
specify { expect(reg_no).to eq('1234') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when contact is private entity' do
|
context 'when contact is private entity' do
|
||||||
let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') }
|
let(:contact) { build_stubbed(:contact_private_entity, ident: '1234') }
|
||||||
|
|
||||||
specify { expect(reg_no).to be_nil }
|
specify { expect(reg_no).to be_nil }
|
||||||
end
|
end
|
||||||
|
@ -522,13 +522,13 @@ RSpec.describe Contact do
|
||||||
|
|
||||||
describe '#id_code' do
|
describe '#id_code' do
|
||||||
context 'when contact is private entity' do
|
context 'when contact is private entity' do
|
||||||
let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') }
|
let(:contact) { build_stubbed(:contact_private_entity, ident: '1234') }
|
||||||
|
|
||||||
specify { expect(contact.id_code).to eq('1234') }
|
specify { expect(contact.id_code).to eq('1234') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when contact is legal entity' do
|
context 'when contact is legal entity' do
|
||||||
let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') }
|
let(:contact) { build_stubbed(:contact_legal_entity, ident: '1234') }
|
||||||
|
|
||||||
specify { expect(contact.id_code).to be_nil }
|
specify { expect(contact.id_code).to be_nil }
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe Dnskey do
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
@ -42,7 +42,17 @@ describe Dnskey do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@dnskey = Fabricate(:dnskey)
|
@dnskey = create(:dnskey,
|
||||||
|
alg: 8,
|
||||||
|
flags: 257,
|
||||||
|
protocol: 3,
|
||||||
|
public_key: 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\
|
||||||
|
'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\
|
||||||
|
'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\
|
||||||
|
'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
|
||||||
|
'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
|
||||||
|
'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=',
|
||||||
|
ds_digest_type: 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -51,7 +61,7 @@ describe Dnskey do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@dnskey = Fabricate(:dnskey)
|
@dnskey = create(:dnskey)
|
||||||
@dnskey.valid?
|
@dnskey.valid?
|
||||||
@dnskey.errors.full_messages.should match_array([])
|
@dnskey.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
@ -66,7 +76,7 @@ describe Dnskey do
|
||||||
# end
|
# end
|
||||||
|
|
||||||
it 'generates correct DS digest and DS key tag for ria.ee' do
|
it 'generates correct DS digest and DS key tag for ria.ee' do
|
||||||
d = Fabricate(:domain, name: 'ria.ee', dnskeys: [@dnskey])
|
d = create(:domain, name: 'ria.ee', dnskeys: [@dnskey])
|
||||||
dk = d.dnskeys.last
|
dk = d.dnskeys.last
|
||||||
|
|
||||||
dk.generate_digest
|
dk.generate_digest
|
||||||
|
@ -75,7 +85,7 @@ describe Dnskey do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates correct DS digest and DS key tag for emta.ee' do
|
it 'generates correct DS digest and DS key tag for emta.ee' do
|
||||||
d = Fabricate(:domain, name: 'emta.ee', dnskeys: [@dnskey])
|
d = create(:domain, name: 'emta.ee', dnskeys: [@dnskey])
|
||||||
|
|
||||||
dk = d.dnskeys.last
|
dk = d.dnskeys.last
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe DomainContact do
|
describe DomainContact do
|
||||||
before :example do
|
before :example do
|
||||||
@api_user = Fabricate(:domain_contact)
|
@api_user = create(:domain_contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
@ -32,7 +32,7 @@ describe DomainContact do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@domain_contact = Fabricate(:domain_contact)
|
@domain_contact = create(:domain_contact, type: 'TechDomainContact')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -41,7 +41,7 @@ describe DomainContact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@domain_contact = Fabricate(:domain_contact)
|
@domain_contact = create(:domain_contact)
|
||||||
@domain_contact.valid?
|
@domain_contact.valid?
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
@domain_contact.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
@ -51,11 +51,11 @@ describe DomainContact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have one version' do
|
it 'should have one version' do
|
||||||
@domain_contact = Fabricate.create(:domain_contact)
|
@domain_contact = create(:domain_contact)
|
||||||
|
|
||||||
with_versioning do
|
with_versioning do
|
||||||
@domain_contact.versions.reload.should == []
|
@domain_contact.versions.reload.should == []
|
||||||
@domain_contact.contact = Fabricate.create(:contact)
|
@domain_contact.contact = create(:contact)
|
||||||
@domain_contact.save!
|
@domain_contact.save!
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
@domain_contact.errors.full_messages.should match_array([])
|
||||||
@domain_contact.versions.size.should == 1
|
@domain_contact.versions.size.should == 1
|
||||||
|
@ -65,7 +65,7 @@ describe DomainContact do
|
||||||
|
|
||||||
context 'with valid attributes with tech domain contact' do
|
context 'with valid attributes with tech domain contact' do
|
||||||
before :example do
|
before :example do
|
||||||
@domain_contact = Fabricate(:tech_domain_contact)
|
@domain_contact = create(:tech_domain_contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -74,7 +74,7 @@ describe DomainContact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@domain_contact = Fabricate(:tech_domain_contact)
|
@domain_contact = create(:tech_domain_contact)
|
||||||
@domain_contact.valid?
|
@domain_contact.valid?
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
@domain_contact.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
@ -84,11 +84,11 @@ describe DomainContact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have one version' do
|
it 'should have one version' do
|
||||||
@domain_contact = Fabricate.create(:domain_contact)
|
@domain_contact = create(:domain_contact)
|
||||||
|
|
||||||
with_versioning do
|
with_versioning do
|
||||||
@domain_contact.versions.reload.should == []
|
@domain_contact.versions.reload.should == []
|
||||||
@domain_contact.contact = Fabricate.create(:contact)
|
@domain_contact.contact = create(:contact)
|
||||||
@domain_contact.save!
|
@domain_contact.save!
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
@domain_contact.errors.full_messages.should match_array([])
|
||||||
@domain_contact.versions.size.should == 1
|
@domain_contact.versions.size.should == 1
|
||||||
|
@ -98,7 +98,7 @@ describe DomainContact do
|
||||||
|
|
||||||
context 'with valid attributes with admin domain contact' do
|
context 'with valid attributes with admin domain contact' do
|
||||||
before :example do
|
before :example do
|
||||||
@domain_contact = Fabricate(:admin_domain_contact)
|
@domain_contact = create(:admin_domain_contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -107,7 +107,7 @@ describe DomainContact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@domain_contact = Fabricate(:admin_domain_contact)
|
@domain_contact = create(:admin_domain_contact)
|
||||||
@domain_contact.valid?
|
@domain_contact.valid?
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
@domain_contact.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
@ -119,7 +119,7 @@ describe DomainContact do
|
||||||
it 'should have one version' do
|
it 'should have one version' do
|
||||||
with_versioning do
|
with_versioning do
|
||||||
@domain_contact.versions.reload.should == []
|
@domain_contact.versions.reload.should == []
|
||||||
@domain_contact.contact = Fabricate.create(:contact)
|
@domain_contact.contact = create(:contact)
|
||||||
@domain_contact.save
|
@domain_contact.save
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
@domain_contact.errors.full_messages.should match_array([])
|
||||||
@domain_contact.versions.size.should == 1
|
@domain_contact.versions.size.should == 1
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe DomainCron do
|
RSpec.describe DomainCron do
|
||||||
it 'should expire domains' do
|
it 'should expire domains' do
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
@domain = Fabricate(:domain)
|
@domain = create(:domain)
|
||||||
|
|
||||||
Setting.expire_warning_period = 1
|
Setting.expire_warning_period = 1
|
||||||
Setting.redemption_grace_period = 1
|
Setting.redemption_grace_period = 1
|
||||||
|
@ -25,8 +25,8 @@ RSpec.describe DomainCron do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should start redemption grace period' do
|
it 'should start redemption grace period' do
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
@domain = Fabricate(:domain)
|
@domain = create(:domain)
|
||||||
|
|
||||||
old_valid_to = Time.zone.now - 10.days
|
old_valid_to = Time.zone.now - 10.days
|
||||||
@domain.valid_to = old_valid_to
|
@domain.valid_to = old_valid_to
|
||||||
|
|
|
@ -21,11 +21,11 @@ RSpec.describe Domain do
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
Fabricate(:zone, origin: 'pri.ee')
|
create(:zone, origin: 'pri.ee')
|
||||||
Fabricate(:zone, origin: 'med.ee')
|
create(:zone, origin: 'med.ee')
|
||||||
Fabricate(:zone, origin: 'fie.ee')
|
create(:zone, origin: 'fie.ee')
|
||||||
Fabricate(:zone, origin: 'com.ee')
|
create(:zone, origin: 'com.ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
@ -64,7 +64,7 @@ RSpec.describe Domain do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@domain = Fabricate(:domain)
|
@domain = create(:domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -73,14 +73,14 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@domain = Fabricate(:domain)
|
@domain = create(:domain)
|
||||||
@domain.valid?
|
@domain.valid?
|
||||||
@domain.errors.full_messages.should match_array([])
|
@domain.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate uniqueness of tech contacts' do
|
it 'should validate uniqueness of tech contacts' do
|
||||||
same_contact = Fabricate(:contact, code: 'same_contact')
|
same_contact = create(:contact, code: 'same_contact')
|
||||||
domain = Fabricate(:domain)
|
domain = create(:domain)
|
||||||
domain.tech_contacts << same_contact
|
domain.tech_contacts << same_contact
|
||||||
domain.tech_contacts << same_contact
|
domain.tech_contacts << same_contact
|
||||||
domain.valid?
|
domain.valid?
|
||||||
|
@ -88,8 +88,8 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate uniqueness of tech contacts' do
|
it 'should validate uniqueness of tech contacts' do
|
||||||
same_contact = Fabricate(:contact, code: 'same_contact')
|
same_contact = create(:contact, code: 'same_contact')
|
||||||
domain = Fabricate(:domain)
|
domain = create(:domain)
|
||||||
domain.admin_contacts << same_contact
|
domain.admin_contacts << same_contact
|
||||||
domain.admin_contacts << same_contact
|
domain.admin_contacts << same_contact
|
||||||
domain.valid?
|
domain.valid?
|
||||||
|
@ -113,7 +113,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not find any domains with wrong pendings' do
|
it 'should not find any domains with wrong pendings' do
|
||||||
domain = Fabricate(:domain)
|
domain = create(:domain)
|
||||||
domain.registrant_verification_asked!('frame-str', '1')
|
domain.registrant_verification_asked!('frame-str', '1')
|
||||||
domain.registrant_verification_asked_at = 30.days.ago
|
domain.registrant_verification_asked_at = 30.days.ago
|
||||||
domain.save
|
domain.save
|
||||||
|
@ -122,7 +122,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should clean domain pendings' do
|
it 'should clean domain pendings' do
|
||||||
domain = Fabricate(:domain)
|
domain = create(:domain)
|
||||||
domain.registrant_verification_asked!('frame-str', '1')
|
domain.registrant_verification_asked!('frame-str', '1')
|
||||||
domain.registrant_verification_asked_at = 30.days.ago
|
domain.registrant_verification_asked_at = 30.days.ago
|
||||||
domain.pending_delete!
|
domain.pending_delete!
|
||||||
|
@ -165,7 +165,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should start redemption grace period' do
|
it 'should start redemption grace period' do
|
||||||
domain = Fabricate(:domain)
|
domain = create(:domain)
|
||||||
|
|
||||||
DomainCron.start_redemption_grace_period
|
DomainCron.start_redemption_grace_period
|
||||||
domain.reload
|
domain.reload
|
||||||
|
@ -253,6 +253,9 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should set pending delete' do
|
it 'should set pending delete' do
|
||||||
|
@domain.nameservers.build(attributes_for(:nameserver))
|
||||||
|
@domain.nameservers.build(attributes_for(:nameserver))
|
||||||
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
@domain.save
|
@domain.save
|
||||||
@domain.pending_delete?.should == false
|
@domain.pending_delete?.should == false
|
||||||
|
@ -281,7 +284,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should add poll message to registrar' do
|
it 'should add poll message to registrar' do
|
||||||
domain = Fabricate(:domain, name: 'testpollmessage123.ee')
|
domain = create(:domain, name: 'testpollmessage123.ee')
|
||||||
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
|
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
|
||||||
domain.registrar.messages.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee'
|
domain.registrar.messages.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee'
|
||||||
end
|
end
|
||||||
|
@ -341,13 +344,13 @@ RSpec.describe Domain do
|
||||||
|
|
||||||
it 'should return api_creator when created by api user' do
|
it 'should return api_creator when created by api user' do
|
||||||
with_versioning do
|
with_versioning do
|
||||||
@user = Fabricate(:admin_user)
|
@user = create(:admin_user)
|
||||||
@api_user = Fabricate(:api_user)
|
@api_user = create(:api_user)
|
||||||
@user.id.should == 1
|
@user.id.should == 1
|
||||||
@api_user.id.should == 2
|
@api_user.id.should == 2
|
||||||
::PaperTrail.whodunnit = '2-ApiUser: testuser'
|
::PaperTrail.whodunnit = '2-ApiUser: testuser'
|
||||||
|
|
||||||
@domain = Fabricate(:domain)
|
@domain = create(:domain)
|
||||||
@domain.creator_str.should == '2-ApiUser: testuser'
|
@domain.creator_str.should == '2-ApiUser: testuser'
|
||||||
|
|
||||||
@domain.creator.should == @api_user
|
@domain.creator.should == @api_user
|
||||||
|
@ -357,13 +360,13 @@ RSpec.describe Domain do
|
||||||
|
|
||||||
it 'should return api_creator when created by api user' do
|
it 'should return api_creator when created by api user' do
|
||||||
with_versioning do
|
with_versioning do
|
||||||
@user = Fabricate(:admin_user, id: 1000)
|
@user = create(:admin_user, id: 1000)
|
||||||
@api_user = Fabricate(:api_user, id: 2000)
|
@api_user = create(:api_user, id: 2000)
|
||||||
@user.id.should == 1000
|
@user.id.should == 1000
|
||||||
@api_user.id.should == 2000
|
@api_user.id.should == 2000
|
||||||
::PaperTrail.whodunnit = '1000-AdminUser: testuser'
|
::PaperTrail.whodunnit = '1000-AdminUser: testuser'
|
||||||
|
|
||||||
@domain = Fabricate(:domain)
|
@domain = create(:domain)
|
||||||
@domain.creator_str.should == '1000-AdminUser: testuser'
|
@domain.creator_str.should == '1000-AdminUser: testuser'
|
||||||
|
|
||||||
@domain.creator.should == @user
|
@domain.creator.should == @user
|
||||||
|
@ -374,7 +377,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates domain name' do
|
it 'validates domain name' do
|
||||||
d = Fabricate(:domain)
|
d = create(:domain)
|
||||||
expect(d.name).to_not be_nil
|
expect(d.name).to_not be_nil
|
||||||
|
|
||||||
invalid = [
|
invalid = [
|
||||||
|
@ -384,7 +387,7 @@ RSpec.describe Domain do
|
||||||
]
|
]
|
||||||
|
|
||||||
invalid.each do |x|
|
invalid.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be false
|
expect(build(:domain, name: x).valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
valid = [
|
valid = [
|
||||||
|
@ -393,28 +396,28 @@ RSpec.describe Domain do
|
||||||
]
|
]
|
||||||
|
|
||||||
valid.each do |x|
|
valid.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be true
|
expect(build(:domain, name: x).valid?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
invalid_punycode = ['xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-4we.pri.ee']
|
invalid_punycode = ['xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-4we.pri.ee']
|
||||||
|
|
||||||
invalid_punycode.each do |x|
|
invalid_punycode.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be false
|
expect(build(:domain, name: x).valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
valid_punycode = ['xn--ge-uia.pri.ee', 'xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-9te.pri.ee']
|
valid_punycode = ['xn--ge-uia.pri.ee', 'xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-9te.pri.ee']
|
||||||
|
|
||||||
valid_punycode.each do |x|
|
valid_punycode.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be true
|
expect(build(:domain, name: x).valid?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not create zone origin domain' do
|
it 'should not create zone origin domain' do
|
||||||
d = Fabricate.build(:domain, name: 'ee')
|
d = build(:domain, name: 'ee')
|
||||||
d.save.should == false
|
d.save.should == false
|
||||||
expect(d.errors.full_messages).to include('Data management policy violation: Domain name is blocked [name]')
|
expect(d.errors.full_messages).to include('Data management policy violation: Domain name is blocked [name]')
|
||||||
|
|
||||||
d = Fabricate.build(:domain, name: 'bla')
|
d = build(:domain, name: 'bla')
|
||||||
d.save.should == false
|
d.save.should == false
|
||||||
expect(d.errors.full_messages).to include('Domain name Domain name is invalid')
|
expect(d.errors.full_messages).to include('Domain name Domain name is invalid')
|
||||||
end
|
end
|
||||||
|
@ -427,13 +430,13 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid when name length is exatly 63 in characters' do
|
it 'should be valid when name length is exatly 63 in characters' do
|
||||||
d = Fabricate(:domain, name: "#{'a' * 63}.ee")
|
d = create(:domain, name: "#{'a' * 63}.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == []
|
d.errors.full_messages.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 characters' do
|
it 'should not be valid when name length is longer than 63 characters' do
|
||||||
d = Fabricate.build(:domain, name: "#{'a' * 64}.ee")
|
d = build(:domain, name: "#{'a' * 64}.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should match_array([
|
d.errors.full_messages.should match_array([
|
||||||
"Domain name Domain name is invalid",
|
"Domain name Domain name is invalid",
|
||||||
|
@ -442,7 +445,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 characters' do
|
it 'should not be valid when name length is longer than 63 characters' do
|
||||||
d = Fabricate.build(:domain,
|
d = build(:domain,
|
||||||
name: "xn--4caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ee")
|
name: "xn--4caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should match_array([
|
d.errors.full_messages.should match_array([
|
||||||
|
@ -452,7 +455,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid when name length is 63 characters' do
|
it 'should be valid when name length is 63 characters' do
|
||||||
d = Fabricate.build(:domain,
|
d = build(:domain,
|
||||||
name: "õäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžab123.pri.ee")
|
name: "õäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžab123.pri.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should match_array([
|
d.errors.full_messages.should match_array([
|
||||||
|
@ -460,7 +463,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 punycode characters' do
|
it 'should not be valid when name length is longer than 63 punycode characters' do
|
||||||
d = Fabricate.build(:domain, name: "#{'ä' * 63}.ee")
|
d = build(:domain, name: "#{'ä' * 63}.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == [
|
d.errors.full_messages.should == [
|
||||||
"Puny label Domain name is too long (maximum is 63 characters)"
|
"Puny label Domain name is too long (maximum is 63 characters)"
|
||||||
|
@ -468,7 +471,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 punycode characters' do
|
it 'should not be valid when name length is longer than 63 punycode characters' do
|
||||||
d = Fabricate.build(:domain, name: "#{'ä' * 64}.ee")
|
d = build(:domain, name: "#{'ä' * 64}.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should match_array([
|
d.errors.full_messages.should match_array([
|
||||||
"Domain name Domain name is invalid",
|
"Domain name Domain name is invalid",
|
||||||
|
@ -477,7 +480,7 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 punycode characters' do
|
it 'should not be valid when name length is longer than 63 punycode characters' do
|
||||||
d = Fabricate.build(:domain, name: "#{'ä' * 63}.pri.ee")
|
d = build(:domain, name: "#{'ä' * 63}.pri.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should match_array([
|
d.errors.full_messages.should match_array([
|
||||||
"Puny label Domain name is too long (maximum is 63 characters)"
|
"Puny label Domain name is too long (maximum is 63 characters)"
|
||||||
|
@ -485,63 +488,69 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid when punycode name length is not longer than 63' do
|
it 'should be valid when punycode name length is not longer than 63' do
|
||||||
d = Fabricate.build(:domain, name: "#{'ä' * 53}.pri.ee")
|
d = build(:domain, name: "#{'ä' * 53}.pri.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == []
|
d.errors.full_messages.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid when punycode name length is not longer than 63' do
|
it 'should be valid when punycode name length is not longer than 63' do
|
||||||
d = Fabricate.build(:domain, name: "#{'ä' * 57}.ee")
|
d = build(:domain, name: "#{'ä' * 57}.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == []
|
d.errors.full_messages.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid when name length is one pynicode' do
|
it 'should not be valid when name length is one pynicode' do
|
||||||
d = Fabricate.build(:domain, name: "xn--4ca.ee")
|
d = build(:domain, name: "xn--4ca.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid with at character' do
|
it 'should not be valid with at character' do
|
||||||
d = Fabricate.build(:domain, name: 'dass@sf.ee')
|
d = build(:domain, name: 'dass@sf.ee')
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid with invalid characters' do
|
it 'should not be valid with invalid characters' do
|
||||||
d = Fabricate.build(:domain, name: '@ba)s(?ä_:-df.ee')
|
d = build(:domain, name: '@ba)s(?ä_:-df.ee')
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid when name length is two pynicodes' do
|
it 'should be valid when name length is two pynicodes' do
|
||||||
d = Fabricate.build(:domain, name: "xn--4caa.ee")
|
d = build(:domain, name: "xn--4caa.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == []
|
d.errors.full_messages.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid when name length is two pynicodes' do
|
it 'should be valid when name length is two pynicodes' do
|
||||||
d = Fabricate.build(:domain, name: "xn--4ca0b.ee")
|
d = build(:domain, name: "xn--4ca0b.ee")
|
||||||
d.valid?
|
d.valid?
|
||||||
d.errors.full_messages.should == []
|
d.errors.full_messages.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a reserved domain' do
|
it 'does not create a reserved domain' do
|
||||||
Fabricate.create(:reserved_domain, name: 'test.ee')
|
create(:reserved_domain, name: 'test.ee')
|
||||||
|
|
||||||
domain = Fabricate.build(:domain, name: 'test.ee')
|
domain = build(:domain, name: 'test.ee')
|
||||||
domain.validate
|
domain.validate
|
||||||
|
|
||||||
expect(domain.errors[:base]).to include('Required parameter missing; reserved>pw element required for reserved domains')
|
expect(domain.errors[:base]).to include('Required parameter missing; reserved>pw element required for reserved domains')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates auth info' do
|
it 'generates auth info' do
|
||||||
d = Fabricate(:domain)
|
d = create(:domain)
|
||||||
expect(d.auth_info).to_not be_empty
|
expect(d.auth_info).to_not be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'manages statuses automatically' do
|
it 'manages statuses automatically' do
|
||||||
d = Fabricate(:domain)
|
d = build(:domain)
|
||||||
|
|
||||||
|
d.nameservers.build(attributes_for(:nameserver))
|
||||||
|
d.nameservers.build(attributes_for(:nameserver))
|
||||||
|
|
||||||
|
d.save!
|
||||||
|
|
||||||
expect(d.statuses.count).to eq(1)
|
expect(d.statuses.count).to eq(1)
|
||||||
expect(d.statuses.first).to eq(DomainStatus::OK)
|
expect(d.statuses.first).to eq(DomainStatus::OK)
|
||||||
|
|
||||||
|
@ -562,28 +571,16 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
with_versioning do
|
with_versioning do
|
||||||
context 'when not saved' do
|
|
||||||
it 'does not create domain version' do
|
|
||||||
Fabricate.build(:domain)
|
|
||||||
expect(DomainVersion.count).to eq(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create child versions' do
|
|
||||||
Fabricate.build(:domain)
|
|
||||||
expect(ContactVersion.count).to eq(0)
|
|
||||||
expect(NameserverVersion.count).to eq(0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when saved' do
|
context 'when saved' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:domain)
|
domain = create(:domain)
|
||||||
|
domain.nameservers << create(:nameserver)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates domain version' do
|
it 'creates domain version' do
|
||||||
expect(DomainVersion.count).to eq(1)
|
expect(DomainVersion.count).to eq(1)
|
||||||
expect(ContactVersion.count).to eq(3)
|
expect(ContactVersion.count).to eq(3)
|
||||||
expect(NameserverVersion.count).to eq(3)
|
expect(NameserverVersion.count).to eq(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -672,7 +669,7 @@ RSpec.describe Domain do
|
||||||
|
|
||||||
it 'rejects less than min' do
|
it 'rejects less than min' do
|
||||||
Setting.ns_min_count = 2
|
Setting.ns_min_count = 2
|
||||||
domain.nameservers.build(FactoryGirl.attributes_for(:nameserver))
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
domain.validate
|
domain.validate
|
||||||
expect(domain.errors).to have_key(:nameservers)
|
expect(domain.errors).to have_key(:nameservers)
|
||||||
end
|
end
|
||||||
|
@ -680,15 +677,15 @@ RSpec.describe Domain do
|
||||||
it 'rejects more than max' do
|
it 'rejects more than max' do
|
||||||
Setting.ns_min_count = 1
|
Setting.ns_min_count = 1
|
||||||
Setting.ns_max_count = 1
|
Setting.ns_max_count = 1
|
||||||
domain.nameservers.build(FactoryGirl.attributes_for(:nameserver))
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
domain.nameservers.build(FactoryGirl.attributes_for(:nameserver))
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
domain.validate
|
domain.validate
|
||||||
expect(domain.errors).to have_key(:nameservers)
|
expect(domain.errors).to have_key(:nameservers)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts min' do
|
it 'accepts min' do
|
||||||
Setting.ns_min_count = 1
|
Setting.ns_min_count = 1
|
||||||
domain.nameservers.build(FactoryGirl.attributes_for(:nameserver))
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
domain.validate
|
domain.validate
|
||||||
expect(domain.errors).to_not have_key(:nameservers)
|
expect(domain.errors).to_not have_key(:nameservers)
|
||||||
end
|
end
|
||||||
|
@ -696,8 +693,8 @@ RSpec.describe Domain do
|
||||||
it 'accepts max' do
|
it 'accepts max' do
|
||||||
Setting.ns_min_count = 1
|
Setting.ns_min_count = 1
|
||||||
Setting.ns_max_count = 2
|
Setting.ns_max_count = 2
|
||||||
domain.nameservers.build(FactoryGirl.attributes_for(:nameserver))
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
domain.nameservers.build(FactoryGirl.attributes_for(:nameserver))
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
domain.validate
|
domain.validate
|
||||||
expect(domain.errors).to_not have_key(:nameservers)
|
expect(domain.errors).to_not have_key(:nameservers)
|
||||||
end
|
end
|
||||||
|
@ -709,7 +706,7 @@ RSpec.describe Domain do
|
||||||
|
|
||||||
it 'rejects less than min' do
|
it 'rejects less than min' do
|
||||||
Setting.ns_min_count = 2
|
Setting.ns_min_count = 2
|
||||||
domain.nameservers.build(FactoryGirl.attributes_for(:nameserver))
|
domain.nameservers.build(attributes_for(:nameserver))
|
||||||
domain.validate
|
domain.validate
|
||||||
expect(domain.errors).to have_key(:nameservers)
|
expect(domain.errors).to have_key(:nameservers)
|
||||||
end
|
end
|
||||||
|
@ -867,11 +864,11 @@ RSpec.describe Domain do
|
||||||
before :example do
|
before :example do
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
travel_to Time.zone.parse('05.07.2010 00:00')
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
|
|
||||||
Fabricate.create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59'))
|
create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59'))
|
||||||
Fabricate.create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00'))
|
create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00'))
|
||||||
Fabricate.create(:domain, id: 3, outzone_time: Time.zone.parse('05.07.2010 00:01'))
|
create(:domain, id: 3, outzone_time: Time.zone.parse('05.07.2010 00:01'))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns domains with outzone time in the past' do
|
it 'returns domains with outzone time in the past' do
|
||||||
|
@ -883,11 +880,11 @@ RSpec.describe Domain do
|
||||||
before :example do
|
before :example do
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
travel_to Time.zone.parse('05.07.2010 00:00')
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
|
|
||||||
Fabricate.create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59'))
|
create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59'))
|
||||||
Fabricate.create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00'))
|
create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00'))
|
||||||
Fabricate.create(:domain, id: 3, delete_time: Time.zone.parse('05.07.2010 00:01'))
|
create(:domain, id: 3, delete_time: Time.zone.parse('05.07.2010 00:01'))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns domains with delete time in the past' do
|
it 'returns domains with delete time in the past' do
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe DomainTransfer do
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
@ -42,7 +42,7 @@ describe DomainTransfer do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@domain_transfer = Fabricate(:domain_transfer)
|
@domain_transfer = create(:domain_transfer)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -51,7 +51,7 @@ describe DomainTransfer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@domain_transfer = Fabricate(:domain_transfer)
|
@domain_transfer = create(:domain_transfer)
|
||||||
@domain_transfer.valid?
|
@domain_transfer.valid?
|
||||||
@domain_transfer.errors.full_messages.should match_array([])
|
@domain_transfer.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Epp::Contact, '.check_availability' do
|
describe Epp::Contact, '.check_availability' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:contact, code: 'asd12')
|
create(:contact, code: 'asd12')
|
||||||
Fabricate(:contact, code: 'asd13')
|
create(:contact, code: 'asd13')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return array if argument is string' do
|
it 'should return array if argument is string' do
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe EppSession do
|
describe EppSession do
|
||||||
let(:epp_session) { Fabricate(:epp_session) }
|
let(:epp_session) { create(:epp_session) }
|
||||||
|
|
||||||
it 'has marshalled data' do
|
it 'has marshalled data' do
|
||||||
expect(epp_session.read_attribute(:data)).to_not be_blank
|
expect(epp_session.read_attribute(:data)).to_not be_blank
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe Invoice do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :all do
|
before :all do
|
||||||
@invoice = Fabricate(:invoice)
|
@invoice = create(:invoice)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -36,24 +36,24 @@ describe Invoice do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@invoice = Fabricate(:invoice)
|
@invoice = create(:invoice)
|
||||||
@invoice.valid?
|
@invoice.valid?
|
||||||
@invoice.errors.full_messages.should match_array([])
|
@invoice.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@invoice = Fabricate(:invoice)
|
@invoice = create(:invoice)
|
||||||
@invoice.valid?
|
@invoice.valid?
|
||||||
@invoice.errors.full_messages.should match_array([])
|
@invoice.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return correct addresses' do
|
it 'should return correct addresses' do
|
||||||
@invoice = Fabricate(:invoice)
|
@invoice = create(:invoice)
|
||||||
@invoice.seller_address.should == 'Paldiski mnt. 123, Tallinn'
|
@invoice.seller_address.should == 'Paldiski mnt. 123, Tallinn'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should calculate sums correctly' do
|
it 'should calculate sums correctly' do
|
||||||
@invoice = Fabricate(:invoice)
|
@invoice = create(:invoice)
|
||||||
@invoice.vat_prc.should == BigDecimal.new('0.2')
|
@invoice.vat_prc.should == BigDecimal.new('0.2')
|
||||||
@invoice.sum_without_vat.should == BigDecimal.new('300.0')
|
@invoice.sum_without_vat.should == BigDecimal.new('300.0')
|
||||||
@invoice.vat.should == BigDecimal.new('60.0')
|
@invoice.vat.should == BigDecimal.new('60.0')
|
||||||
|
@ -67,7 +67,7 @@ describe Invoice do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should cancel overdue invoices' do
|
it 'should cancel overdue invoices' do
|
||||||
Fabricate(:invoice, created_at: Time.zone.now - 35.days, due_date: Time.zone.now - 30.days)
|
create(:invoice, created_at: Time.zone.now - 35.days, due_date: Time.zone.now - 30.days)
|
||||||
Invoice.cancel_overdue_invoices
|
Invoice.cancel_overdue_invoices
|
||||||
Invoice.where(cancelled_at: nil).count.should == 1
|
Invoice.where(cancelled_at: nil).count.should == 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe Keyrelay do
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
@ -49,7 +49,7 @@ describe Keyrelay do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@keyrelay = Fabricate(:keyrelay)
|
@keyrelay = create(:keyrelay)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -58,7 +58,7 @@ describe Keyrelay do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@keyrelay = Fabricate(:keyrelay)
|
@keyrelay = create(:keyrelay)
|
||||||
@keyrelay.valid?
|
@keyrelay.valid?
|
||||||
@keyrelay.errors.full_messages.should match_array([])
|
@keyrelay.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
@ -79,12 +79,12 @@ describe Keyrelay do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is in expired status' do
|
it 'is in expired status' do
|
||||||
kr = Fabricate(:keyrelay, pa_date: Time.zone.now - 2.weeks)
|
kr = create(:keyrelay, pa_date: Time.zone.now - 2.weeks)
|
||||||
expect(kr.status).to eq('expired')
|
expect(kr.status).to eq('expired')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not accept invalid relative expiry' do
|
it 'does not accept invalid relative expiry' do
|
||||||
kr = Fabricate.build(:keyrelay, expiry_relative: 'adf')
|
kr = build(:keyrelay, expiry_relative: 'adf')
|
||||||
expect(kr.save).to eq(false)
|
expect(kr.save).to eq(false)
|
||||||
expect(kr.errors[:expiry_relative].first).to eq('Expiry relative must be compatible to ISO 8601')
|
expect(kr.errors[:expiry_relative].first).to eq('Expiry relative must be compatible to ISO 8601')
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,16 +3,16 @@ require 'rails_helper'
|
||||||
describe LegalDocument do
|
describe LegalDocument do
|
||||||
context 'tasks' do
|
context 'tasks' do
|
||||||
it 'make files uniq' do
|
it 'make files uniq' do
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
Fabricate(:zone, origin: 'pri.ee')
|
create(:zone, origin: 'pri.ee')
|
||||||
Fabricate(:zone, origin: 'med.ee')
|
create(:zone, origin: 'med.ee')
|
||||||
Fabricate(:zone, origin: 'fie.ee')
|
create(:zone, origin: 'fie.ee')
|
||||||
Fabricate(:zone, origin: 'com.ee')
|
create(:zone, origin: 'com.ee')
|
||||||
LegalDocument.explicitly_write_file = true
|
LegalDocument.explicitly_write_file = true
|
||||||
PaperTrail.enabled = true
|
PaperTrail.enabled = true
|
||||||
|
|
||||||
domain = Fabricate(:domain)
|
domain = create(:domain)
|
||||||
domain2 = Fabricate(:domain)
|
domain2 = create(:domain)
|
||||||
legals = []
|
legals = []
|
||||||
legals << original = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
legals << original = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||||
legals << copy = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
legals << copy = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe Message do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :all do
|
before :all do
|
||||||
@mssage = Fabricate(:message)
|
@mssage = create(:message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -29,7 +29,7 @@ describe Message do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@mssage = Fabricate(:message)
|
@mssage = create(:message)
|
||||||
@mssage.valid?
|
@mssage.valid?
|
||||||
@mssage.errors.full_messages.should match_array([])
|
@mssage.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe Nameserver do
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
@ -36,7 +36,7 @@ describe Nameserver do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@nameserver = Fabricate(:nameserver)
|
@nameserver = create(:nameserver)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -45,7 +45,7 @@ describe Nameserver do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@nameserver = Fabricate(:nameserver)
|
@nameserver = create(:nameserver)
|
||||||
@nameserver.valid?
|
@nameserver.valid?
|
||||||
@nameserver.errors.full_messages.should match_array([])
|
@nameserver.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
@ -62,23 +62,23 @@ describe Nameserver do
|
||||||
|
|
||||||
context 'with many nameservers' do
|
context 'with many nameservers' do
|
||||||
before :example do
|
before :example do
|
||||||
@api_user = Fabricate(:api_user)
|
@api_user = create(:api_user)
|
||||||
@domain_1 = Fabricate(:domain, nameservers: [
|
@domain_1 = create(:domain, nameservers: [
|
||||||
Fabricate(:nameserver, hostname: 'ns1.ns.ee'),
|
create(:nameserver, hostname: 'ns1.ns.ee'),
|
||||||
Fabricate(:nameserver, hostname: 'ns2.ns.ee'),
|
create(:nameserver, hostname: 'ns2.ns.ee'),
|
||||||
Fabricate(:nameserver, hostname: 'ns2.test.ee')
|
create(:nameserver, hostname: 'ns2.test.ee')
|
||||||
], registrar: @api_user.registrar)
|
], registrar: @api_user.registrar)
|
||||||
|
|
||||||
@domain_2 = Fabricate(:domain, nameservers: [
|
@domain_2 = create(:domain, nameservers: [
|
||||||
Fabricate(:nameserver, hostname: 'ns1.ns.ee'),
|
create(:nameserver, hostname: 'ns1.ns.ee'),
|
||||||
Fabricate(:nameserver, hostname: 'ns2.ns.ee'),
|
create(:nameserver, hostname: 'ns2.ns.ee'),
|
||||||
Fabricate(:nameserver, hostname: 'ns3.test.ee')
|
create(:nameserver, hostname: 'ns3.test.ee')
|
||||||
], registrar: @api_user.registrar)
|
], registrar: @api_user.registrar)
|
||||||
|
|
||||||
@domain_3 = Fabricate(:domain, nameservers: [
|
@domain_3 = create(:domain, nameservers: [
|
||||||
Fabricate(:nameserver, hostname: 'ns1.ns.ee'),
|
create(:nameserver, hostname: 'ns1.ns.ee'),
|
||||||
Fabricate(:nameserver, hostname: 'ns2.ns.ee'),
|
create(:nameserver, hostname: 'ns2.ns.ee'),
|
||||||
Fabricate(:nameserver, hostname: 'ns3.test.ee')
|
create(:nameserver, hostname: 'ns3.test.ee')
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe RegistrantVerification do
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zone, origin: 'ee')
|
create(:zone, origin: 'ee')
|
||||||
end
|
end
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
before :example do
|
before :example do
|
||||||
|
@ -42,7 +42,7 @@ describe RegistrantVerification do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :example do
|
before :example do
|
||||||
@registrant_verification = Fabricate(:registrant_verification)
|
@registrant_verification = create(:registrant_verification)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -51,7 +51,7 @@ describe RegistrantVerification do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@registrant_verification = Fabricate(:registrant_verification)
|
@registrant_verification = create(:registrant_verification)
|
||||||
@registrant_verification.valid?
|
@registrant_verification.valid?
|
||||||
@registrant_verification.errors.full_messages.should match_array([])
|
@registrant_verification.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe Registrar do
|
||||||
|
|
||||||
it 'is not valid' do
|
it 'is not valid' do
|
||||||
@registrar.valid?
|
@registrar.valid?
|
||||||
@registrar.errors.full_messages.should match_array([
|
@registrar.errors.full_messages.should include(*[
|
||||||
'Contact e-mail is missing',
|
'Contact e-mail is missing',
|
||||||
'Country code is missing',
|
'Country code is missing',
|
||||||
'Name is missing',
|
'Name is missing',
|
||||||
|
@ -43,7 +43,7 @@ describe Registrar do
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before :all do
|
before :all do
|
||||||
@registrar = Fabricate(:registrar)
|
@registrar = create(:registrar)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid' do
|
it 'should be valid' do
|
||||||
|
@ -52,13 +52,13 @@ describe Registrar do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be valid twice' do
|
it 'should be valid twice' do
|
||||||
@registrar = Fabricate(:registrar)
|
@registrar = create(:registrar)
|
||||||
@registrar.valid?
|
@registrar.valid?
|
||||||
@registrar.errors.full_messages.should match_array([])
|
@registrar.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should remove blank from code' do
|
it 'should remove blank from code' do
|
||||||
registrar = Fabricate.build(:registrar, code: 'with blank')
|
registrar = build(:registrar, code: 'with blank')
|
||||||
registrar.valid?
|
registrar.valid?
|
||||||
registrar.errors.full_messages.should match_array([
|
registrar.errors.full_messages.should match_array([
|
||||||
])
|
])
|
||||||
|
@ -66,7 +66,7 @@ describe Registrar do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should remove colon from code' do
|
it 'should remove colon from code' do
|
||||||
registrar = Fabricate.build(:registrar, code: 'with colon:and:blank')
|
registrar = build(:registrar, code: 'with colon:and:blank')
|
||||||
registrar.valid?
|
registrar.valid?
|
||||||
registrar.errors.full_messages.should match_array([
|
registrar.errors.full_messages.should match_array([
|
||||||
])
|
])
|
||||||
|
@ -74,7 +74,7 @@ describe Registrar do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should allow dot in code' do
|
it 'should allow dot in code' do
|
||||||
registrar = Fabricate.build(:registrar, code: 'with.dot')
|
registrar = build(:registrar, code: 'with.dot')
|
||||||
registrar.valid?
|
registrar.valid?
|
||||||
registrar.errors.full_messages.should match_array([
|
registrar.errors.full_messages.should match_array([
|
||||||
])
|
])
|
||||||
|
@ -92,21 +92,19 @@ describe Registrar do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return full address' do
|
it 'should return full address' do
|
||||||
@registrar.address.should == 'Street 999, Town, County, Postal'
|
registrar = described_class.new(street: 'Street 999', city: 'Town', state: 'County', zip: 'Postal')
|
||||||
end
|
registrar.address.should == 'Street 999, Town, County, Postal'
|
||||||
|
|
||||||
it 'should have code' do
|
|
||||||
@registrar.code.should =~ /REGISTRAR/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be able to change code' do
|
it 'should not be able to change code' do
|
||||||
@registrar.code = 'not-updated'
|
registrar = create(:registrar, code: 'TEST')
|
||||||
@registrar.code.should =~ /REGISTRAR/
|
registrar.code = 'new-code'
|
||||||
|
expect(registrar.code).to eq('TEST')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to issue a prepayment invoice' do
|
it 'should be able to issue a prepayment invoice' do
|
||||||
Setting.days_to_keep_invoices_active = 30
|
Setting.days_to_keep_invoices_active = 30
|
||||||
Fabricate(:registrar, name: 'EIS', reg_no: '90010019')
|
create(:registrar, name: 'EIS', reg_no: '90010019')
|
||||||
@registrar.issue_prepayment_invoice(200, 'add some money')
|
@registrar.issue_prepayment_invoice(200, 'add some money')
|
||||||
@registrar.invoices.count.should == 1
|
@registrar.invoices.count.should == 1
|
||||||
i = @registrar.invoices.first
|
i = @registrar.invoices.first
|
||||||
|
@ -116,7 +114,7 @@ describe Registrar do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not allaw to use CID as code for leagcy reasons' do
|
it 'should not allaw to use CID as code for leagcy reasons' do
|
||||||
registrar = Fabricate.build(:registrar, code: 'CID')
|
registrar = build(:registrar, code: 'CID')
|
||||||
registrar.valid?
|
registrar.valid?
|
||||||
registrar.errors.full_messages.should == ['Code is forbidden to use']
|
registrar.errors.full_messages.should == ['Code is forbidden to use']
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe WhoisRecord do
|
RSpec.describe WhoisRecord do
|
||||||
describe '::generate_json', db: false do
|
describe '::generate_json', db: false do
|
||||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant) }
|
let(:registrant) { build_stubbed(:registrant) }
|
||||||
let(:domain) { FactoryGirl.build_stubbed(:domain, registrant: registrant) }
|
let(:domain) { build_stubbed(:domain, registrant: registrant) }
|
||||||
let(:whois_record) { described_class.new }
|
let(:whois_record) { described_class.new }
|
||||||
subject(:generated_json) { whois_record.generate_json }
|
subject(:generated_json) { whois_record.generate_json }
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ RSpec.describe WhoisRecord do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when registrant is legal entity' do
|
context 'when registrant is legal entity' do
|
||||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) }
|
let(:registrant) { build_stubbed(:registrant_legal_entity) }
|
||||||
|
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
expect(reg_no).to eq('test reg no')
|
expect(reg_no).to eq('test reg no')
|
||||||
|
@ -32,7 +32,7 @@ RSpec.describe WhoisRecord do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when registrant is private entity' do
|
context 'when registrant is private entity' do
|
||||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) }
|
let(:registrant) { build_stubbed(:registrant_private_entity) }
|
||||||
|
|
||||||
it 'is absent' do
|
it 'is absent' do
|
||||||
expect(reg_no).to be_nil
|
expect(reg_no).to be_nil
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe WhoisRecord do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when registrant is legal entity' do
|
context 'when registrant is legal entity' do
|
||||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) }
|
let(:registrant) { build_stubbed(:registrant_legal_entity) }
|
||||||
|
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
expect(country_code).to eq('test country code')
|
expect(country_code).to eq('test country code')
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe WhoisRecord do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when registrant is private entity' do
|
context 'when registrant is private entity' do
|
||||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) }
|
let(:registrant) { build_stubbed(:registrant_private_entity) }
|
||||||
|
|
||||||
it 'is absent' do
|
it 'is absent' do
|
||||||
expect(country_code).to be_nil
|
expect(country_code).to be_nil
|
||||||
|
|
|
@ -20,7 +20,7 @@ RSpec.describe 'EPP contact:update' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in_to_epp_area
|
sign_in_to_epp_area
|
||||||
FactoryGirl.create(:contact, code: 'TEST')
|
create(:contact, code: 'TEST')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when address processing is enabled' do
|
context 'when address processing is enabled' do
|
||||||
|
|
|
@ -34,7 +34,7 @@ RSpec.describe 'EPP contact:update' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in_to_epp_area
|
sign_in_to_epp_area
|
||||||
FactoryGirl.create(:contact, code: 'TEST')
|
create(:contact, code: 'TEST')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when address processing is enabled' do
|
context 'when address processing is enabled' do
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Features
|
module Features
|
||||||
module SessionHelpers
|
module SessionHelpers
|
||||||
def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user))
|
def sign_in_to_admin_area(user: create(:admin_user))
|
||||||
visit admin_login_url
|
visit admin_login_url
|
||||||
|
|
||||||
fill_in 'admin_user[username]', with: user.username
|
fill_in 'admin_user[username]', with: user.username
|
||||||
|
@ -9,7 +9,7 @@ module Features
|
||||||
click_button 'Log in'
|
click_button 'Log in'
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user))
|
def sign_in_to_registrar_area(user: create(:api_user))
|
||||||
visit registrar_login_url
|
visit registrar_login_url
|
||||||
|
|
||||||
fill_in 'depp_user_tag', with: user.username
|
fill_in 'depp_user_tag', with: user.username
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Requests
|
module Requests
|
||||||
module SessionHelpers
|
module SessionHelpers
|
||||||
def sign_in_to_epp_area(user: FactoryGirl.create(:api_user_epp))
|
def sign_in_to_epp_area(user: create(:api_user_epp))
|
||||||
login_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
|
login_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
|
||||||
<epp xmlns=\"https://epp.tld.ee/schema/epp-ee-1.0.xsd\">
|
<epp xmlns=\"https://epp.tld.ee/schema/epp-ee-1.0.xsd\">
|
||||||
<command>
|
<command>
|
||||||
|
@ -29,11 +29,11 @@ module Requests
|
||||||
post '/epp/session/login', frame: login_xml
|
post '/epp/session/login', frame: login_xml
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user))
|
def sign_in_to_admin_area(user: create(:admin_user))
|
||||||
post admin_sessions_path, admin_user: { username: user.username, password: user.password }
|
post admin_sessions_path, admin_user: { username: user.username, password: user.password }
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user))
|
def sign_in_to_registrar_area(user: create(:api_user))
|
||||||
post registrar_sessions_path, { depp_user: { tag: user.username, password: user.password } }
|
post registrar_sessions_path, { depp_user: { tag: user.username, password: user.password } }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.before :example do |example|
|
config.before :example do |example|
|
||||||
if example.metadata[:db] && (example.metadata[:settings] != false)
|
if example.metadata[:db] && (example.metadata[:settings] != false)
|
||||||
Fabricate(:zone, origin: 'com')
|
create(:zone, origin: 'com')
|
||||||
|
|
||||||
Setting.ds_algorithm = 2
|
Setting.ds_algorithm = 2
|
||||||
Setting.ds_data_allowed = true
|
Setting.ds_data_allowed = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue