mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
added new tests
This commit is contained in:
parent
97876ab1c1
commit
4567e56457
5 changed files with 159 additions and 3 deletions
|
@ -50,7 +50,7 @@ module Admin
|
|||
def set_test_date_to_api_user
|
||||
user_api = User.find(params[:user_api_id])
|
||||
|
||||
uri = URI.parse((ENV['registry_demo_registrar_api_user_url'] || 'testapi.test') + "?username=#{user_api.username}&identity_code=#{user_api.identity_code}")
|
||||
uri = URI.parse((ENV['registry_demo_registrar_api_user_url'] || 'http://testapi.test') + "?username=#{user_api.username}&identity_code=#{user_api.identity_code}")
|
||||
|
||||
response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port'])
|
||||
|
||||
|
@ -74,7 +74,7 @@ module Admin
|
|||
user_api.accreditation_date = nil
|
||||
user_api.accreditation_expire_date = nil
|
||||
user_api.save
|
||||
|
||||
|
||||
redirect_to request.referrer
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ module Admin
|
|||
def set_test_date
|
||||
registrar = Registrar.find(params[:registrar_id])
|
||||
|
||||
uri = URI.parse((ENV['registry_demo_registrar_results_url'] || 'testapi.test') + "?registrar_name=#{registrar.name}")
|
||||
uri = URI.parse((ENV['registry_demo_registrar_results_url'] || 'http://testapi.test') + "?registrar_name=#{registrar.name}")
|
||||
|
||||
response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port'])
|
||||
|
||||
|
|
22
test/interactions/record_date_of_test_test.rb
Normal file
22
test/interactions/record_date_of_test_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RecordDateOfTestTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@api_bestname = users(:api_bestnames)
|
||||
@api_bestname.accreditation_date = Time.zone.now - 10.minutes
|
||||
@api_bestname.accreditation_expire_date = @api_bestname.accreditation_date + 1.year
|
||||
@api_bestname.save
|
||||
end
|
||||
|
||||
def test_should_record_data_to_apiuser
|
||||
api_goodname = users(:api_goodnames)
|
||||
|
||||
assert_nil api_goodname.accreditation_date
|
||||
assert_nil api_goodname.accreditation_expire_date
|
||||
|
||||
Actions::RecordDateOfTest.record_result_to_api_user(api_user: api_goodname, date: @api_bestname.accreditation_date)
|
||||
|
||||
assert_equal api_goodname.accreditation_date, @api_bestname.accreditation_date
|
||||
assert_equal api_goodname.accreditation_expire_date, @api_bestname.accreditation_expire_date
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue