diff options
Diffstat (limited to 'spec/support/helpers/api_helpers.rb')
-rw-r--r-- | spec/support/helpers/api_helpers.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/support/helpers/api_helpers.rb b/spec/support/helpers/api_helpers.rb index fd85071cca3..62bb9576695 100644 --- a/spec/support/helpers/api_helpers.rb +++ b/spec/support/helpers/api_helpers.rb @@ -19,15 +19,17 @@ 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, personal_access_token: nil, oauth_access_token: nil, job_token: nil) + def api(path, user = nil, version: API::API.version, personal_access_token: nil, oauth_access_token: nil, job_token: nil, access_token: nil) full_path = "/api/#{version}#{path}" if oauth_access_token - query_string = "access_token=#{oauth_access_token.token}" + query_string = "access_token=#{oauth_access_token.plaintext_token}" elsif personal_access_token query_string = "private_token=#{personal_access_token.token}" elsif job_token query_string = "job_token=#{job_token}" + elsif access_token + query_string = "access_token=#{access_token.token}" elsif user personal_access_token = create(:personal_access_token, user: user) query_string = "private_token=#{personal_access_token.token}" @@ -66,6 +68,13 @@ module ApiHelpers expect(json_response.map { |item| item['id'] }).to contain_exactly(*items) end + def expect_paginated_array_response_contain_exactly(*items) + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.map { |item| item['id'] }).to contain_exactly(*items) + end + def stub_last_activity_update allow_any_instance_of(Users::ActivityService).to receive(:execute) end |