test refactoring

This commit is contained in:
olegphenomenon 2021-12-13 10:54:09 +02:00
parent 4567e56457
commit 72f184d9b0
7 changed files with 65 additions and 73 deletions

View file

@ -4,6 +4,8 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
setup do
ENV['registry_demo_registrar_results_url'] = 'http://registry.test:3000/api/v1/accreditation_center/results'
ENV['registry_demo_registrar_port'] = '3000'
@registrar = registrars(:bestnames)
sign_in users(:admin)
end
@ -26,18 +28,20 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest
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: {})
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 }
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
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