X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9ba66dcc4f4c166fa08512ce0c75e324f26c7b0d..7e8f99556391cc81c014b517a9fa6efed8fe8113:/services/api/test/test_helper.rb?ds=sidebyside diff --git a/services/api/test/test_helper.rb b/services/api/test/test_helper.rb index 8e3399523e..286cf66f28 100644 --- a/services/api/test/test_helper.rb +++ b/services/api/test/test_helper.rb @@ -9,10 +9,22 @@ class ActiveSupport::TestCase # -- they do not yet inherit this setting fixtures :all + teardown do + Thread.current[:api_client_ip_address] = nil + Thread.current[:api_client_authorization] = nil + Thread.current[:api_client_uuid] = nil + Thread.current[:api_client] = nil + Thread.current[:user] = nil + end + def expect_json self.request.headers["Accept"] = "text/json" end + def json_response + @json_response ||= ActiveSupport::JSON.decode @response.body + end + def authorize_with(api_client_auth_name) self.request.env['HTTP_AUTHORIZATION'] = "OAuth2 #{api_client_authorizations(api_client_auth_name).api_token}" end @@ -21,8 +33,17 @@ class ActiveSupport::TestCase end class ActionDispatch::IntegrationTest - def jresponse - @jresponse ||= ActiveSupport::JSON.decode @response.body + + teardown do + Thread.current[:api_client_ip_address] = nil + Thread.current[:api_client_authorization] = nil + Thread.current[:api_client_uuid] = nil + Thread.current[:api_client] = nil + Thread.current[:user] = nil + end + + def auth auth_fixture + {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(auth_fixture).api_token}"} end end