Add feature tests for zonefile settings #2806

This commit is contained in:
Martin Lensment 2015-08-03 13:31:13 +03:00
parent 57aa65263a
commit e8e730a6e1
4 changed files with 84 additions and 2 deletions

View file

@ -53,7 +53,8 @@ class Admin::ZonefileSettingsController < AdminController
def zonefile_setting_params
params.require(:zonefile_setting).permit(
:origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :ns_records, :a_records, :a4_records
:origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email,
:master_nameserver, :ns_records, :a_records, :a4_records
)
end
end

View file

@ -1,6 +1,6 @@
class ZonefileSetting < ActiveRecord::Base
include Versions # version/zonefile_setting_version.rb
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
validates :origin, uniqueness: true

View file

@ -50,6 +50,12 @@
.col-md-8
= f.text_field :email, class: 'form-control'
.form-group
.col-md-4.control-label
= f.label :master_nameserver
.col-md-8
= f.text_field :master_nameserver, class: 'form-control'
.form-group
.col-md-4.control-label
= f.label :ns_records

View file

@ -20,5 +20,80 @@ feature 'Zonefile settings', type: :feature do
page.should have_content('Zonefile settings')
end
it 'should create zone' do
sign_in @user
visit admin_zonefile_settings_url
page.should_not have_content('Generate zonefile')
click_link 'New'
fill_in 'Origin', with: 'ee'
fill_in 'TTL', with: '43200'
fill_in 'Refresh', with: '3600'
fill_in 'Retry', with: '900'
fill_in 'Expire', with: '1209600'
fill_in 'Minimum TTL', with: '3600'
fill_in 'E-Mail', with: 'hostmaster.eestiinternet.ee'
fill_in 'Master nameserver', with: 'ns.tld.ee'
fill_in('Ns records', with: '
ee. IN NS sunic.sunet.se.
ee. IN NS ns.eenet.ee.
ee. IN NS ns.tld.ee.
ee. IN NS ns.ut.ee.
ee. IN NS e.tld.ee.
ee. IN NS b.tld.ee.
ee. IN NS ee.aso.ee.
')
fill_in('A records', with: '
ns.ut.ee. IN A 193.40.5.99
ns.tld.ee. IN A 195.43.87.10
ee.aso.ee. IN A 213.184.51.122
b.tld.ee. IN A 194.146.106.110
ns.eenet.ee. IN A 193.40.56.245
e.tld.ee. IN A 204.61.216.36
')
fill_in('AAAA records', with: '
ee.aso.ee. IN AAAA 2A02:88:0:21::2
b.tld.ee. IN AAAA 2001:67C:1010:28::53
ns.eenet.ee. IN AAAA 2001:BB8::1
e.tld.ee. IN AAAA 2001:678:94:53::53
')
click_button 'Save'
page.should have_content('Record created')
page.should have_content('ee')
page.should have_content('Generate zonefile')
click_link 'Generate zonefile'
response_headers['Content-Type'].should == 'text/plain'
response_headers['Content-Disposition'].should == "attachment; filename=\"ee.txt\""
end
it 'does not delete zone with existin domains' do
ZonefileSetting.find_by(origin: 'ee') || Fabricate(:zonefile_setting)
Fabricate(:domain)
sign_in @user
visit admin_zonefile_settings_url
click_link 'ee'
click_link 'Delete'
page.should have_content("There are 1 domains in this zone")
page.should have_content('Failed to delete record')
end
it 'deletes a zone' do
ZonefileSetting.find_by(origin: 'ee') || Fabricate(:zonefile_setting)
Domain.destroy_all
sign_in @user
visit admin_zonefile_settings_url
click_link 'ee'
click_link 'Delete'
page.should have_content('Record deleted')
page.should_not have_content("Generate zonefile")
end
end
end