diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2017-06-20 07:40:24 +0000 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2017-06-28 07:17:13 +0000 |
commit | 6f1922500bc9e2c6d53c46dfcbd420687dfe6e6b (patch) | |
tree | b9de79a82757d00156ddf2f86453ae5b2ee7944d /spec/support | |
parent | 08ad0af49c017d740b43588c0809b3811d25a448 (diff) | |
download | gitlab-ce-6f1922500bc9e2c6d53c46dfcbd420687dfe6e6b.tar.gz |
Initial attempt at refactoring API scope declarations.
- Declaring an endpoint's scopes in a `before` block has proved to be
unreliable. For example, if we're accessing the `API::Users` endpoint - code
in a `before` block in `API::API` wouldn't be able to see the scopes set in
`API::Users` since the `API::API` `before` block runs first.
- This commit moves these declarations to the class level, since they don't need
to change once set.
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/api_helpers.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb index 35d1e1cfc7d..163979a2a28 100644 --- a/spec/support/api_helpers.rb +++ b/spec/support/api_helpers.rb @@ -17,14 +17,16 @@ module ApiHelpers # => "/api/v2/issues?foo=bar&private_token=..." # # Returns the relative path to the requested API resource - def api(path, user = nil, version: API::API.version) + def api(path, user = nil, version: API::API.version, personal_access_token: nil) "/api/#{version}#{path}" + # Normalize query string (path.index('?') ? '' : '?') + + if personal_access_token.present? + "&private_token=#{personal_access_token.token}" # Append private_token if given a User object - if user.respond_to?(:private_token) + elsif user.respond_to?(:private_token) "&private_token=#{user.private_token}" else '' |