diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2017-10-19 20:28:19 +0200 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2017-10-20 10:13:18 +0200 |
commit | 2f40dac35280f9de9af8c47bdf85c2f0b2d53680 (patch) | |
tree | ece7f87f18b32c8961e784973caf1dd299e877c7 /spec/support/api | |
parent | b4dc0ba2c57c150f847d255b0d2d831ff60728ad (diff) | |
download | gitlab-ce-2f40dac35280f9de9af8c47bdf85c2f0b2d53680.tar.gz |
Refactor `have_http_status` into `have_gitlab_http_status` in the specs
Diffstat (limited to 'spec/support/api')
6 files changed, 60 insertions, 60 deletions
diff --git a/spec/support/api/issues_resolving_discussions_shared_examples.rb b/spec/support/api/issues_resolving_discussions_shared_examples.rb index d26d279363c..d2d6260dfa8 100644 --- a/spec/support/api/issues_resolving_discussions_shared_examples.rb +++ b/spec/support/api/issues_resolving_discussions_shared_examples.rb @@ -1,6 +1,6 @@ shared_examples 'creating an issue resolving discussions through the API' do it 'creates a new project issue' do - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) end it 'resolves the discussions in a merge request' do diff --git a/spec/support/api/members_shared_examples.rb b/spec/support/api/members_shared_examples.rb index dab71a35a55..8d910e52eda 100644 --- a/spec/support/api/members_shared_examples.rb +++ b/spec/support/api/members_shared_examples.rb @@ -6,6 +6,6 @@ shared_examples 'a 404 response when source is private' do it 'returns 404' do route - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/support/api/milestones_shared_examples.rb b/spec/support/api/milestones_shared_examples.rb index 4bb5113957e..d9080b02541 100644 --- a/spec/support/api/milestones_shared_examples.rb +++ b/spec/support/api/milestones_shared_examples.rb @@ -10,7 +10,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns milestones list' do get api(route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['title']).to eq(milestone.title) @@ -19,13 +19,13 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a 401 error if user not authenticated' do get api(route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns an array of active milestones' do get api("#{route}/?state=active", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -35,7 +35,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns an array of closed milestones' do get api("#{route}/?state=closed", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -47,7 +47,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(route, user), iids: [closed_milestone.iid, other_milestone.iid] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.map { |m| m['id'] }).to match_array([closed_milestone.id, other_milestone.id]) @@ -56,7 +56,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'does not return any milestone if none found' do get api(route, user), iids: [Milestone.maximum(:iid).succ] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -75,7 +75,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestone by searching for title' do get api(route, user), search: 'version2' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.size).to eq(1) expect(json_response.first['title']).to eq milestone.title @@ -85,7 +85,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestones by searching for description' do get api(route, user), search: 'open' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.size).to eq(1) expect(json_response.first['title']).to eq milestone.title @@ -97,7 +97,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestone by id' do get api(resource_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(milestone.title) expect(json_response['iid']).to eq(milestone.iid) end @@ -105,7 +105,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestone by id' do get api(resource_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(milestone.title) expect(json_response['iid']).to eq(milestone.iid) end @@ -113,13 +113,13 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns 401 error if user not authenticated' do get api(resource_route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 404 error if milestone id not found' do get api("#{route}/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -127,7 +127,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'creates a new milestone' do post api(route, user), title: 'new milestone' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new milestone') expect(json_response['description']).to be_nil end @@ -136,7 +136,7 @@ shared_examples_for 'group and project milestones' do |route_definition| post api(route, user), title: 'new milestone', description: 'release', due_date: '2013-03-02', start_date: '2013-02-02' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['description']).to eq('release') expect(json_response['due_date']).to eq('2013-03-02') expect(json_response['start_date']).to eq('2013-02-02') @@ -145,20 +145,20 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a 400 error if title is missing' do post api(route, user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 error if params are invalid (duplicate title)' do post api(route, user), title: milestone.title, description: 'release', due_date: '2013-03-02' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'creates a new milestone with reserved html characters' do post api(route, user), title: 'foo & bar 1.1 -> 2.2' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('foo & bar 1.1 -> 2.2') expect(json_response['description']).to be_nil end @@ -169,7 +169,7 @@ shared_examples_for 'group and project milestones' do |route_definition| put api(resource_route, user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -178,7 +178,7 @@ shared_examples_for 'group and project milestones' do |route_definition| put api(resource_route, user), due_date: nil - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to be_nil end @@ -186,13 +186,13 @@ shared_examples_for 'group and project milestones' do |route_definition| put api("#{route}/1234", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'closes milestone' do put api(resource_route, user), state_event: 'close' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq('closed') end @@ -207,7 +207,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns issues for a particular milestone' do get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['milestone']['title']).to eq(milestone.title) @@ -228,14 +228,14 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'matches V4 response schema for a list of issues' do get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/issues') end it 'returns a 401 error if user not authenticated' do get api(issues_route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end describe 'confidential issues' do @@ -265,7 +265,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns confidential issues to team members' do get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array # 2 for projects, 3 for group(which has another project with an issue) @@ -279,7 +279,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(issues_route, member) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -289,7 +289,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'does not return confidential issues to regular users' do get api(issues_route, create(:user)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -302,7 +302,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array # 2 for projects, 3 for group(which has another project with an issue) @@ -325,7 +325,7 @@ shared_examples_for 'group and project milestones' do |route_definition| another_merge_request get api(merge_requests_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) expect(json_response.first['title']).to eq(merge_request.title) @@ -349,20 +349,20 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(not_found_route, user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 if the user has no access to the milestone' do new_user = create :user get api(merge_requests_route, new_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 401 error if user not authenticated' do get api(merge_requests_route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns merge_requests ordered by position asc' do @@ -372,7 +372,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(merge_requests_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(2) diff --git a/spec/support/api/scopes/read_user_shared_examples.rb b/spec/support/api/scopes/read_user_shared_examples.rb index 111534f2f26..06ae8792c61 100644 --- a/spec/support/api/scopes/read_user_shared_examples.rb +++ b/spec/support/api/scopes/read_user_shared_examples.rb @@ -6,7 +6,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, personal_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -16,7 +16,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, personal_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -30,7 +30,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "403" response' do get api_call.call(path, user, personal_access_token: token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -44,7 +44,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, oauth_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -54,7 +54,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, oauth_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -64,7 +64,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "403" response' do get api_call.call(path, user, oauth_access_token: token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -77,7 +77,7 @@ shared_examples_for 'does not allow the "read_user" scope' do it 'returns a "403" response' do post api_call.call(path, user, personal_access_token: token), attributes_for(:user, projects_limit: 3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end diff --git a/spec/support/api/time_tracking_shared_examples.rb b/spec/support/api/time_tracking_shared_examples.rb index 16a3cf06be7..af1083f4bfd 100644 --- a/spec/support/api/time_tracking_shared_examples.rb +++ b/spec/support/api/time_tracking_shared_examples.rb @@ -15,7 +15,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it "sets the time estimate for #{issuable_name}" do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), duration: '1w' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['human_time_estimate']).to eq('1w') end @@ -28,7 +28,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it 'does not modify the original estimate' do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), duration: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(issuable.reload.human_time_estimate).to eq('1w') end end @@ -37,7 +37,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it 'updates the estimate' do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), duration: '3w1h' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(issuable.reload.human_time_estimate).to eq('3w 1h') end end @@ -54,7 +54,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it "resets the time estimate for #{issuable_name}" do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_time_estimate", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['time_estimate']).to eq(0) end end @@ -73,7 +73,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), duration: '2h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['human_total_time_spent']).to eq('2h') end @@ -84,7 +84,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), duration: '-1h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['total_time_spent']).to eq(3600) end end @@ -96,7 +96,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), duration: '-1w' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['time_spent'].first).to match(/exceeds the total time spent/) end end @@ -112,7 +112,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it "resets spent time for #{issuable_name}" do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_spent_time", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(0) end end @@ -124,7 +124,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| get api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_stats", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(1800) expect(json_response['time_estimate']).to eq(3600) end diff --git a/spec/support/api/v3/time_tracking_shared_examples.rb b/spec/support/api/v3/time_tracking_shared_examples.rb index f982b10d999..afe0f4cecda 100644 --- a/spec/support/api/v3/time_tracking_shared_examples.rb +++ b/spec/support/api/v3/time_tracking_shared_examples.rb @@ -11,7 +11,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it "sets the time estimate for #{issuable_name}" do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_estimate", user), duration: '1w' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['human_time_estimate']).to eq('1w') end @@ -24,7 +24,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it 'does not modify the original estimate' do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_estimate", user), duration: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(issuable.reload.human_time_estimate).to eq('1w') end end @@ -33,7 +33,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it 'updates the estimate' do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_estimate", user), duration: '3w1h' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(issuable.reload.human_time_estimate).to eq('3w 1h') end end @@ -50,7 +50,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it "resets the time estimate for #{issuable_name}" do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/reset_time_estimate", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['time_estimate']).to eq(0) end end @@ -69,7 +69,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/add_spent_time", user), duration: '2h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['human_total_time_spent']).to eq('2h') end @@ -80,7 +80,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/add_spent_time", user), duration: '-1h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['total_time_spent']).to eq(3600) end end @@ -92,7 +92,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/add_spent_time", user), duration: '-1w' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['time_spent'].first).to match(/exceeds the total time spent/) end end @@ -108,7 +108,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it "resets spent time for #{issuable_name}" do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/reset_spent_time", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(0) end end @@ -120,7 +120,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| get v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_stats", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(1800) expect(json_response['time_estimate']).to eq(3600) end |