mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
parent
bff7437277
commit
1ed7c7c95b
3 changed files with 94 additions and 0 deletions
36
spec/requests/admin/dns/zones/create_spec.rb
Normal file
36
spec/requests/admin/dns/zones/create_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'admin zone create' do
|
||||
subject(:zone) { DNS::Zone.first }
|
||||
|
||||
before :example do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
it 'creates new zone' do
|
||||
expect { post admin_zones_path, zone: attributes_for(:zone) }
|
||||
.to change { DNS::Zone.count }.from(0).to(1)
|
||||
end
|
||||
|
||||
text_attributes = %i[origin email master_nameserver]
|
||||
integer_attributes = %i[ttl refresh retry expire minimum_ttl]
|
||||
|
||||
text_attributes.each do |attr_name|
|
||||
it "saves #{attr_name}" do
|
||||
post admin_zones_path, { zone: attributes_for(:zone, attr_name => 'test') }
|
||||
expect(zone.send(attr_name)).to eq('test')
|
||||
end
|
||||
end
|
||||
|
||||
integer_attributes.each do |attr_name|
|
||||
it "saves #{attr_name}" do
|
||||
post admin_zones_path, { zone: attributes_for(:zone, attr_name => '1') }
|
||||
expect(zone.send(attr_name)).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'redirects to :index' do
|
||||
post admin_zones_path, { zone: attributes_for(:zone) }
|
||||
expect(response).to redirect_to admin_zones_url
|
||||
end
|
||||
end
|
18
spec/requests/admin/dns/zones/destroy_spec.rb
Normal file
18
spec/requests/admin/dns/zones/destroy_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'admin zone destroy' do
|
||||
let!(:zone) { create(:zone) }
|
||||
|
||||
before :example do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
it 'deletes zone' do
|
||||
expect { delete admin_zone_path(zone) }.to change { DNS::Zone.count }.from(1).to(0)
|
||||
end
|
||||
|
||||
it 'redirects to :index' do
|
||||
delete admin_zone_path(zone)
|
||||
expect(response).to redirect_to admin_zones_url
|
||||
end
|
||||
end
|
40
spec/requests/admin/dns/zones/update_spec.rb
Normal file
40
spec/requests/admin/dns/zones/update_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'admin zone update' do
|
||||
before :example do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
text_attributes = %i[origin email master_nameserver]
|
||||
integer_attributes = %i[ttl refresh retry expire minimum_ttl]
|
||||
|
||||
text_attributes.each do |attr_name|
|
||||
it "updates #{attr_name}" do
|
||||
zone = create(:zone, attr_name => 'test')
|
||||
|
||||
patch admin_zone_path(zone), zone: attributes_for(:zone, attr_name => 'new-test')
|
||||
zone.reload
|
||||
|
||||
expect(zone.send(attr_name)).to eq('new-test')
|
||||
end
|
||||
end
|
||||
|
||||
integer_attributes.each do |attr_name|
|
||||
it "updates #{attr_name}" do
|
||||
zone = create(:zone, attr_name => '1')
|
||||
|
||||
patch admin_zone_path(zone), zone: attributes_for(:zone, attr_name => '2')
|
||||
zone.reload
|
||||
|
||||
expect(zone.send(attr_name)).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
it 'redirects to :index' do
|
||||
zone = create(:zone)
|
||||
|
||||
patch admin_zone_path(zone), { zone: attributes_for(:zone) }
|
||||
|
||||
expect(response).to redirect_to admin_zones_url
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue