diff options
| author | Robert | 2017-09-11 18:03:06 +0200 |
|---|---|---|
| committer | Robert | 2017-09-11 18:03:06 +0200 |
| commit | 37865fad65adacae41bff0677651ca0a4d9db974 (patch) | |
| tree | 0889ea9d7883bb27b493c16b9b08426fa22545a0 /spec/support/api_key.rb | |
| parent | f7bc874de79ff9a68aa03523cf653407663e7c55 (diff) | |
| parent | 8fe9a39516f6fb71545d6329c448680d6f8c75d1 (diff) | |
| download | chouette-core-37865fad65adacae41bff0677651ca0a4d9db974.tar.bz2 | |
merged with master
Diffstat (limited to 'spec/support/api_key.rb')
| -rw-r--r-- | spec/support/api_key.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/spec/support/api_key.rb b/spec/support/api_key.rb index 561e1f796..cc08cd7f1 100644 --- a/spec/support/api_key.rb +++ b/spec/support/api_key.rb @@ -5,20 +5,24 @@ module ApiKeyHelper end def get_api_key - Api::V1::ApiKey.first_or_create( :referential_id => referential.id, :name => "test") + Api::V1::ApiKey.first_or_create(referential: referential, organisation: organisation) end + def config_formatted_request_with_authorization( format) request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials( get_api_key.token) request.accept = format end + def config_formatted_request_with_dummy_authorization( format) request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials( "dummy") request.accept = format end + def config_formatted_request_without_authorization( format) request.env['HTTP_AUTHORIZATION'] = nil request.accept = format end + def json_xml_format? request.accept == "application/json" || request.accept == "application/xml" end |
