mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 23:16:23 +02:00
added registrar controller tests
This commit is contained in:
parent
c07abaea59
commit
95f5bad64b
3 changed files with 25 additions and 11 deletions
|
@ -93,8 +93,8 @@ module Admin
|
|||
return redirect_to request.referrer, 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(a, api.accreditation_date) unless a.nil?
|
||||
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'
|
||||
|
|
|
@ -5,18 +5,9 @@ module Actions
|
|||
TEST_DEADLINE = 1.year.freeze
|
||||
|
||||
def record_result_to_api_user(api_user:, date:)
|
||||
p "+++++++++++"
|
||||
p api_user
|
||||
p "-----------"
|
||||
p DateTime.parse(date)
|
||||
p "+++++++++++"
|
||||
|
||||
api_user.accreditation_date = date
|
||||
api_user.accreditation_expire_date = api_user.accreditation_date + TEST_DEADLINE
|
||||
api_user.save
|
||||
|
||||
# api_user.update(accreditation_date: date,
|
||||
# accreditation_expire_date: DateTime.parse(date) + TEST_DEADLINE)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,4 +17,27 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest
|
|||
|
||||
assert_equal new_iban, @registrar.iban
|
||||
end
|
||||
|
||||
def test_set_test_date
|
||||
api_user = @registrar.api_users.first.dup
|
||||
api_user.accreditation_date = Time.zone.now - 10.minutes
|
||||
api_user.accreditation_expire_date = api_user.accreditation_date + 1.year
|
||||
api_user.save
|
||||
|
||||
assert_nil @registrar.api_users.first.accreditation_date
|
||||
|
||||
stub_request(:get, "http://registry.test:3000/api/v1/accreditation_center/results?registrar_name=#{@registrar.name}").
|
||||
with(
|
||||
headers: {
|
||||
'Accept'=>'*/*',
|
||||
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
||||
'User-Agent'=>'Ruby'
|
||||
}).to_return(status: 200, body: { code: 200, registrar_users: [api_user] }.to_json, headers: {})
|
||||
|
||||
post set_test_date_admin_registrars_path, params: { registrar_id: @registrar.id }, headers: { "HTTP_REFERER" => root_path }
|
||||
@registrar.reload
|
||||
|
||||
assert_equal @registrar.api_users.first.accreditation_date.to_date, api_user.accreditation_date.to_date
|
||||
assert_equal @registrar.api_users.first.accreditation_expire_date.to_date, api_user.accreditation_expire_date.to_date
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue