mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Basic archiving overhaul
This commit is contained in:
parent
19846a3abf
commit
3b1e21d6eb
12 changed files with 260 additions and 30 deletions
84
spec/models/domain_version_spec.rb
Normal file
84
spec/models/domain_version_spec.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe DomainVersion do
|
||||
with_versioning do
|
||||
before(:each) { Fabricate(:domain_validation_setting_group) }
|
||||
before(:each) do
|
||||
Fabricate(:domain, name: 'version.ee') do
|
||||
owner_contact { Fabricate(:contact, name: 'owner_contact', code: 'asd', email: 'owner1@v.ee') }
|
||||
nameservers(count: 1) { Fabricate(:nameserver, hostname: 'ns.test.ee')}
|
||||
admin_contacts(count: 1) { Fabricate(:contact, name: 'admin_contact 1', code: 'qwe', email: 'admin1@v.ee') }
|
||||
tech_contacts(count: 1) { Fabricate(:contact, name: 'tech_contact 1', code: 'zxc', email: 'tech1@v.ee') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when domain is created' do
|
||||
it('creates a domain version') { expect(DomainVersion.count).to eq(1) }
|
||||
it('has a snapshot') { expect(DomainVersion.first.snapshot).not_to be_empty }
|
||||
it 'has a snapshot with correct info' do
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
:admin_contacts => [{:name=>"admin_contact 1", :phone=>"+372.12345678", :code=>"qwe", :ident=>"37605030299", :email=>"admin1@v.ee"}],
|
||||
:domain => {:name=>"version.ee", :status=>nil},
|
||||
:nameservers => [{:hostname=>"ns.test.ee", :ipv4=>nil, :ipv6=>nil}],
|
||||
:owner_contact => {:name=>"owner_contact", :phone=>"+372.12345678", :code=>"asd", :ident=>"37605030299", :email=>"owner1@v.ee"},
|
||||
:tech_contacts => [{:name=>"tech_contact 1", :phone=>"+372.12345678", :code=>"zxc", :ident=>"37605030299", :email=>"tech1@v.ee"}]
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'when domain is deleted' do
|
||||
it 'creates a version' do
|
||||
expect(DomainVersion.count).to eq(1)
|
||||
Domain.first.destroy
|
||||
expect(DomainVersion.count).to eq(2)
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
:admin_contacts => [],
|
||||
:domain => {:name=>"version.ee", :status=>nil},
|
||||
:nameservers => [],
|
||||
:owner_contact => {:name=>"owner_contact", :phone=>"+372.12345678", :code=>"asd", :ident=>"37605030299", :email=>"owner1@v.ee"},
|
||||
:tech_contacts => []
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'when deleting children' do
|
||||
it 'creates a version' do
|
||||
expect(DomainVersion.count).to eq(1)
|
||||
Contact.find_by(name: 'tech_contact 1').destroy
|
||||
expect(DomainVersion.count).to eq(2)
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
:admin_contacts => [{:name=>"admin_contact 1", :phone=>"+372.12345678", :code=>"qwe", :ident=>"37605030299", :email=>"admin1@v.ee"}],
|
||||
:domain => {:name=>"version.ee", :status=>nil},
|
||||
:nameservers => [{:hostname=>"ns.test.ee", :ipv4=>nil, :ipv6=>nil}],
|
||||
:owner_contact => {:name=>"owner_contact", :phone=>"+372.12345678", :code=>"asd", :ident=>"37605030299", :email=>"owner1@v.ee"},
|
||||
:tech_contacts => []
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'when editing children' do
|
||||
it 'creates a version' do
|
||||
expect(DomainVersion.count).to eq(1)
|
||||
Contact.find_by(name: 'owner_contact').update_attributes!(name: 'edited owner_contact')
|
||||
expect(DomainVersion.count).to eq(2)
|
||||
end
|
||||
|
||||
it 'creates 3 versions' do
|
||||
expect(DomainVersion.count).to eq(1)
|
||||
Contact.find_by(name: 'owner_contact').update_attributes!(name: 'edited owner_contact')
|
||||
expect(DomainVersion.count).to eq(2)
|
||||
Contact.find_by(name: 'tech_contact 1').update_attributes!(name: 'edited tech_contact')
|
||||
expect(DomainVersion.count).to eq(3)
|
||||
Contact.find_by(name: 'admin_contact 1').update_attributes!(name: 'edited admin_contact')
|
||||
expect(DomainVersion.count).to eq(4)
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
:admin_contacts => [{:name=>"edited admin_contact", :phone=>"+372.12345678", :code=>"qwe", :ident=>"37605030299", :email=>"admin1@v.ee"}],
|
||||
:domain => {:name=>"version.ee", :status=>nil},
|
||||
:nameservers => [{:hostname=>"ns.test.ee", :ipv4=>nil, :ipv6=>nil}],
|
||||
:owner_contact => {:name=>"edited owner_contact", :phone=>"+372.12345678", :code=>"asd", :ident=>"37605030299", :email=>"owner1@v.ee"},
|
||||
:tech_contacts => [{:name=>"edited tech_contact", :phone=>"+372.12345678", :code=>"zxc", :ident=>"37605030299", :email=>"tech1@v.ee"}]
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue