Add tests for zonefile #2806

This commit is contained in:
Martin Lensment 2015-08-03 12:53:10 +03:00
parent 72b322ae1f
commit 8c6bd53019
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,10 @@
Fabricator(:zonefile_setting) do
origin 'ee'
ttl 43200
refresh 3600
expire 1209600
minimum_ttl 3600
email 'hostmaster.eestiinternet.ee'
master_nameserver 'ns.tld.ee'
after_build { |x| x.retry = 900 }
end

View file

@ -49,4 +49,34 @@ describe ZonefileSetting do
@zonefile.scan(/^#{d.name}/).count.should == 0 @zonefile.scan(/^#{d.name}/).count.should == 0
end end
it 'does not create duplicate zones' do
Fabricate(:zonefile_setting)
expect { Fabricate(:zonefile_setting) }.to raise_error(ActiveRecord::RecordInvalid)
end
it 'does not allow deleting zone when it has existing domains' do
zs = ZonefileSetting.where({
origin: 'ee',
ttl: 43200,
refresh: 3600,
retry: 900,
expire: 1209600,
minimum_ttl: 3600,
email: 'hostmaster.eestiinternet.ee',
master_nameserver: 'ns.tld.ee'
}).first_or_create!
d = Fabricate(:domain)
zs.destroy.should == false
zs.errors.full_messages.should match_array(["There are 1 domains in this zone"])
ZonefileSetting.count.should == 1
d.destroy
zs.destroy
ZonefileSetting.count.should == 0
end
end end