mirror of
https://github.com/internetee/registry.git
synced 2025-08-23 09:40:56 +02:00
Merge pull request #2813 from internetee/update_test_coverage/zones_controller
added new tests for zones_controller
This commit is contained in:
commit
3fab373aac
1 changed files with 84 additions and 0 deletions
|
@ -24,4 +24,88 @@ class AdminAreaZonesIntegrationTest < ApplicationIntegrationTest
|
||||||
assert_equal "attachment; filename=\"test.txt\"; filename*=UTF-8''test.txt", response.headers['Content-Disposition']
|
assert_equal "attachment; filename=\"test.txt\"; filename*=UTF-8''test.txt", response.headers['Content-Disposition']
|
||||||
assert_not_empty response.body
|
assert_not_empty response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_shows_new_form
|
||||||
|
get new_admin_zone_path
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_shows_index
|
||||||
|
get admin_zones_path
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creates_zone_successfully
|
||||||
|
assert_difference 'DNS::Zone.count' do
|
||||||
|
post admin_zones_path, params: {
|
||||||
|
zone: {
|
||||||
|
origin: 'example.org',
|
||||||
|
ttl: 3600,
|
||||||
|
refresh: 1200,
|
||||||
|
retry: 1800,
|
||||||
|
expire: 3600000,
|
||||||
|
minimum_ttl: 600,
|
||||||
|
email: 'admin@example.org',
|
||||||
|
master_nameserver: 'ns1.example.org'
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_redirected_to admin_zones_url
|
||||||
|
follow_redirect!
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_fails_to_create_zone_with_invalid_data
|
||||||
|
assert_no_difference 'DNS::Zone.count' do
|
||||||
|
post admin_zones_path, params: {
|
||||||
|
zone: {
|
||||||
|
origin: '',
|
||||||
|
email: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_shows_edit_form
|
||||||
|
get edit_admin_zone_path(@zone)
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_fails_to_update_zone_with_invalid_data
|
||||||
|
patch admin_zone_path(@zone), params: { zone: { ttl: '' }}
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
assert_includes response.body, "Ttl", "Ttl field error should be shown"
|
||||||
|
assert_includes response.body, "Ttl is missing", "Presence validation message expected"
|
||||||
|
|
||||||
|
@zone.reload
|
||||||
|
refute_equal '', @zone.ttl, "Ttl should not have changed"
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_redirects_to_index_after_successful_operations
|
||||||
|
# Test redirect_to_index private method through public methods
|
||||||
|
post admin_zones_path, params: {
|
||||||
|
zone: {
|
||||||
|
origin: 'redirect-test.org',
|
||||||
|
ttl: 3600,
|
||||||
|
refresh: 1200,
|
||||||
|
retry: 1800,
|
||||||
|
expire: 3600000,
|
||||||
|
minimum_ttl: 600,
|
||||||
|
email: 'admin@redirect-test.org',
|
||||||
|
master_nameserver: 'ns1.redirect-test.org'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_redirected_to admin_zones_url
|
||||||
|
|
||||||
|
follow_redirect!
|
||||||
|
assert_response :success
|
||||||
|
assert_includes response.body, 'Zone has been created'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue