added new tests

This commit is contained in:
olegphenomenon 2021-12-13 10:43:16 +02:00
parent 97876ab1c1
commit 4567e56457
5 changed files with 159 additions and 3 deletions

View file

@ -3,6 +3,7 @@ require 'application_system_test_case'
class AdminApiUsersSystemTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
@registrar = registrars(:bestnames)
end
def test_shows_api_user_list
@ -11,4 +12,71 @@ class AdminApiUsersSystemTest < ApplicationSystemTestCase
api_user = users(:api_bestnames)
assert_link api_user.username, href: admin_registrar_api_user_path(api_user.registrar, api_user)
end
def test_should_display_tests_button_in_api_user
visit admin_api_users_path
assert_button 'Set Test'
assert_no_button 'Remove Test'
end
def test_should_display_remove_test_if_there_accreditated_apiuser
date = Time.zone.now - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_api_users_path
assert_button 'Remove Test'
end
def test_should_not_display_remove_test_if_api_user_accreditation_date_is_expired
date = Time.zone.now - 1.year - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_api_users_path
assert_no_button 'Remove'
end
def test_should_display_tests_button_in_api_user_details
api_user = @registrar.api_users.first
visit admin_api_user_path(api_user)
assert_button 'Set Test'
assert_no_button 'Remove Test'
end
def test_should_display_remove_test_in_api_user_details_if_there_accreditated_apiuser
date = Time.zone.now - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_api_user_path(api_user)
assert_button 'Remove Test'
end
def test_should_not_display_remove_test_if_api_user_accreditation_date_is_expired_in_api_details
date = Time.zone.now - 1.year - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_api_user_path(api_user)
assert_no_button 'Remove'
end
end

View file

@ -93,4 +93,70 @@ class AdminRegistrarsSystemTest < ApplicationSystemTestCase
assert_text 'Language English'
assert_text 'billing@bestnames.test'
end
def test_should_display_btn_for_set_test_date
visit admin_registrars_path
assert_button 'Set Test'
assert_no_button 'Remove Test'
end
def test_should_display_remove_test_if_there_accreditated_registrars
date = Time.zone.now - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_registrars_path
assert_button 'Remove Test'
end
def test_should_not_display_remove_test_if_accreditation_date_is_expired
date = Time.zone.now - 1.year - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_registrars_path
assert_no_button 'Remove'
end
def test_should_display_tests_button_in_registrar_deftails
visit admin_registrar_path(@registrar)
assert_button 'Set Test'
assert_no_button 'Remove Test'
end
def test_should_display_remove_test_if_there_accreditated_registrars_in_registrar_details
date = Time.zone.now - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_registrar_path(@registrar)
assert_button 'Remove Test'
end
def test_should_not_display_remove_test_if_accreditation_date_is_expired_in_registrar_details
date = Time.zone.now - 1.year - 10.minutes
api_user = @registrar.api_users.first
api_user.accreditation_date = date
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
api_user.save
visit admin_registrar_path(@registrar)
assert_no_button 'Remove'
end
end