mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
parent
39d7c6ad1d
commit
ad0220088a
30 changed files with 697 additions and 59 deletions
57
spec/models/concerns/domain/expirable_spec.rb
Normal file
57
spec/models/concerns/domain/expirable_spec.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Domain, db: false do
|
||||
it { is_expected.to alias_attribute(:expire_time, :valid_to) }
|
||||
|
||||
describe '::expired', db: true do
|
||||
before :example do
|
||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
||||
|
||||
FactoryGirl.create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59'))
|
||||
FactoryGirl.create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00'))
|
||||
FactoryGirl.create(:domain, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01'))
|
||||
end
|
||||
|
||||
it 'returns expired domains' do
|
||||
expect(described_class.expired.ids).to eq([1, 2])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#registered?' do
|
||||
before :example do
|
||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
||||
end
|
||||
|
||||
context 'when :valid_to is in the future' do
|
||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('06.07.2010 00:01')) }
|
||||
|
||||
specify { expect(domain).to be_registered }
|
||||
end
|
||||
|
||||
context 'when :valid_to is the same as current time' do
|
||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:00')) }
|
||||
|
||||
specify { expect(domain).to_not be_registered }
|
||||
end
|
||||
|
||||
context 'when :valid_to is in the past' do
|
||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('04.07.2010 23:59')) }
|
||||
|
||||
specify { expect(domain).to_not be_registered }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#expired?' do
|
||||
context 'when :statuses contains expired status' do
|
||||
let(:domain) { described_class.new(statuses: [DomainStatus::EXPIRED]) }
|
||||
|
||||
specify { expect(domain).to be_expired }
|
||||
end
|
||||
|
||||
context 'when :statuses does not contain expired status' do
|
||||
let(:domain) { described_class.new(statuses: [DomainStatus::CLIENT_HOLD]) }
|
||||
|
||||
specify { expect(domain).to_not be_expired }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Contact do
|
||||
RSpec.describe Contact 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
|
||||
|
||||
Fabricate(:zonefile_setting, origin: 'ee')
|
||||
@api_user = Fabricate(:api_user)
|
||||
end
|
||||
|
||||
context 'about class' do
|
||||
|
|
|
@ -928,29 +928,4 @@ RSpec.describe Domain, db: false do
|
|||
expect(domain.nameserver_hostnames).to eq('hostnames')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#registered?' do
|
||||
before :example do
|
||||
travel_to Time.zone.parse('05.07.2010 00:00:01')
|
||||
end
|
||||
|
||||
context 'when :valid_to is in the future' do
|
||||
let(:domain) { described_class.new(valid_to: Time.zone.parse('06.07.2010')) }
|
||||
|
||||
specify { expect(domain).to be_registered }
|
||||
end
|
||||
|
||||
context 'when :valid_to is the same as current time' do
|
||||
let(:domain) { described_class.new(valid_to: Time.zone.parse('05.07.2010 00:00:01')) }
|
||||
|
||||
|
||||
specify { expect(domain).to be_registered }
|
||||
end
|
||||
|
||||
context 'when :valid_to is in the past' do
|
||||
let(:domain) { described_class.new(valid_to: Time.zone.parse('04.07.2010 23:59:59')) }
|
||||
|
||||
specify { expect(domain).to_not be_registered }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue