mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 20:19:34 +02:00
tests added
This commit is contained in:
parent
eeb48fa5ba
commit
a6af2f898c
1 changed files with 66 additions and 0 deletions
66
test/integration/admin_area/domains_controller_test.rb
Normal file
66
test/integration/admin_area/domains_controller_test.rb
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class AdminDomainsControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
include Devise::Test::IntegrationHelpers
|
||||||
|
include ActionDispatch::TestProcess
|
||||||
|
|
||||||
|
setup do
|
||||||
|
@admin = users(:admin)
|
||||||
|
sign_in @admin
|
||||||
|
|
||||||
|
@domain = domains(:shop)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_index_renders_successfully
|
||||||
|
get admin_domains_path
|
||||||
|
assert_response :success
|
||||||
|
assert_match @domain.name, response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_index_with_status_filter
|
||||||
|
status = @domain.statuses.first || 'client_hold'
|
||||||
|
get admin_domains_path, params: { statuses_contains: [status] }
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_update_statuses_success
|
||||||
|
Domain.stub_any_instance(:admin_status_update, true) do
|
||||||
|
Domain.stub_any_instance(:update, true) do
|
||||||
|
patch admin_domain_path(@domain),
|
||||||
|
params: { domain: { statuses: ['client_hold', ''] } },
|
||||||
|
headers: { 'HTTP_REFERER' => admin_domain_path(@domain) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_redirected_to admin_domain_path(@domain)
|
||||||
|
assert_equal I18n.t('domain_updated'), flash[:notice]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_update_statuses_failure
|
||||||
|
Domain.stub_any_instance(:admin_status_update, false) do
|
||||||
|
Domain.stub_any_instance(:update, false) do
|
||||||
|
patch admin_domain_path(@domain),
|
||||||
|
params: { domain: { statuses: ['client_hold', ''] } },
|
||||||
|
headers: { 'HTTP_REFERER' => admin_domain_path(@domain) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_match I18n.t('failed_to_update_domain'), flash[:alert]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_versions_page_success
|
||||||
|
get admin_domain_domain_versions_path(@domain)
|
||||||
|
assert_response :success
|
||||||
|
assert_match @domain.name, response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_keep_domain
|
||||||
|
Domain.stub_any_instance(:keep, true) do
|
||||||
|
patch keep_admin_domain_path(@domain)
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_redirected_to edit_admin_domain_url(@domain)
|
||||||
|
assert flash[:notice].present?
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue