mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 22:16:19 +02:00
test refactoring
This commit is contained in:
parent
4567e56457
commit
72f184d9b0
7 changed files with 65 additions and 73 deletions
|
@ -17,8 +17,7 @@ module Admin
|
|||
|
||||
if @api_user.valid?
|
||||
@api_user.save!
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user),
|
||||
notice: t('.created')
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), notice: t('.created')
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
|
@ -35,8 +34,7 @@ module Admin
|
|||
|
||||
if @api_user.valid?
|
||||
@api_user.save!
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user),
|
||||
notice: t('.updated')
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), notice: t('.updated')
|
||||
else
|
||||
render 'edit'
|
||||
end
|
||||
|
@ -50,7 +48,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'] || 'http://testapi.test') + "?username=#{user_api.username}&identity_code=#{user_api.identity_code}")
|
||||
uri = URI.parse((ENV['registry_demo_registrar_api_user_url']) + "?username=#{user_api.username}&identity_code=#{user_api.identity_code}")
|
||||
|
||||
response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port'])
|
||||
|
||||
|
@ -58,9 +56,8 @@ module Admin
|
|||
result = JSON.parse(response.body)
|
||||
demo_user_api = result['user_api']
|
||||
|
||||
Actions::RecordDateOfTest.record_result_to_api_user(
|
||||
api_user:user_api,
|
||||
date: demo_user_api['accreditation_date']) unless demo_user_api.empty?
|
||||
Actions::RecordDateOfTest.record_result_to_api_user(api_user:user_api,
|
||||
date: demo_user_api['accreditation_date']) unless demo_user_api.empty?
|
||||
return redirect_to request.referrer, notice: 'User Api found'
|
||||
else
|
||||
return redirect_to request.referrer, notice: 'User Api no found or not accriditated yet'
|
||||
|
|
|
@ -60,17 +60,17 @@ module Admin
|
|||
def set_test_date
|
||||
registrar = Registrar.find(params[:registrar_id])
|
||||
|
||||
uri = URI.parse((ENV['registry_demo_registrar_results_url'] || 'http://testapi.test') + "?registrar_name=#{registrar.name}")
|
||||
uri = URI.parse((ENV['registry_demo_registrar_results_url']) + "?registrar_name=#{registrar.name}")
|
||||
|
||||
response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port'])
|
||||
|
||||
if response.code == "200"
|
||||
return record_result_for_each_api_user(response: response)
|
||||
else
|
||||
return redirect_to request.referrer, notice: 'Registrar no found'
|
||||
return redirect_to request.referer, notice: 'Registrar no found'
|
||||
end
|
||||
|
||||
redirect_to request.referrer, notice: 'Something goes wrong'
|
||||
redirect_to request.referer, notice: 'Something goes wrong'
|
||||
end
|
||||
|
||||
def remove_test_date
|
||||
|
@ -81,7 +81,7 @@ module Admin
|
|||
api.save
|
||||
end
|
||||
|
||||
redirect_to request.referrer
|
||||
redirect_to request.referer
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -90,14 +90,14 @@ module Admin
|
|||
result = JSON.parse(response.body)
|
||||
registrar_users = result['registrar_users']
|
||||
|
||||
return redirect_to request.referrer, notice: 'Registrar found, but not accreditated yet' if registrar_users.empty?
|
||||
return redirect_to request.referer, notice: 'Registrar found, but not accreditated yet' if registrar_users.empty?
|
||||
|
||||
registrar_users.each do |api|
|
||||
a = ApiUser.find_by(username: api['username'], identity_code: api['identity_code'])
|
||||
Actions::RecordDateOfTest.record_result_to_api_user(api_user: a, date: api['accreditation_date']) unless a.nil?
|
||||
end
|
||||
|
||||
redirect_to request.referrer, notice: 'Registrar found'
|
||||
redirect_to request.referer, notice: 'Registrar found'
|
||||
end
|
||||
|
||||
def base_get_request(uri:, port:)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue