diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-10-29 20:51:34 -0500 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-10-29 20:51:34 -0500 |
commit | 6a92dff2bc368aa362a0e239f9fcf953ad4e9e52 (patch) | |
tree | 458a7621335bf04895223cd9789729d0e3e68a13 /spec/requests | |
parent | 40ee89bc7da8b1c0500f2358d2548f2395bc2323 (diff) | |
parent | 1aae91cf24606275834d6e17279ce14c1074dade (diff) | |
download | gitlab-ce-6a92dff2bc368aa362a0e239f9fcf953ad4e9e52.tar.gz |
Merge branch 'master' into sh-headless-chrome-support
* master: (96 commits)
Fetch the merged branches at once
Merging EE doc into CE
Avoid using Rugged in Gitlab::Git::Wiki#preview_slug
Cache commits on the repository model
Remove groups_select from global namespace & simplifies the code
Change default disabled merge request widget message to "Merge is not allowed yet"
Semi-linear history merge is now available in CE.
Remove repetitive karma spec
Improve spec to check hidden component
Rename to shouldShowUsername
Add KubernetesService#default_namespace tests
Revert "Merge branch '36670-remove-edit-form' into 'master'"
Fix bitbucket login
Remove duped tests
Add path attribute to WikiFile class
Make local_branches OPT_OUT
Clarify the language around External Group membership with SAML SSO to clarify that this will NOT add users to GitLab Groups.
Added ssh fingerprint, gitlab ci and pages information in an instance configuration page
Fix the incorrect value being used to set GL_USERNAME on hooks
Resolve "Remove overzealous tooltips in projects page tabs"
...
Diffstat (limited to 'spec/requests')
87 files changed, 2566 insertions, 2126 deletions
diff --git a/spec/requests/api/access_requests_spec.rb b/spec/requests/api/access_requests_spec.rb index 50d0f72f6bc..35ca3635a9d 100644 --- a/spec/requests/api/access_requests_spec.rb +++ b/spec/requests/api/access_requests_spec.rb @@ -35,7 +35,7 @@ describe API::AccessRequests do user = public_send(type) get api("/#{source_type.pluralize}/#{source.id}/access_requests", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -45,7 +45,7 @@ describe API::AccessRequests do it 'returns access requesters' do get api("/#{source_type.pluralize}/#{source.id}/access_requests", master) - 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) @@ -68,7 +68,7 @@ describe API::AccessRequests do user = public_send(type) post api("/#{source_type.pluralize}/#{source.id}/access_requests", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end.not_to change { source.requesters.count } end end @@ -80,7 +80,7 @@ describe API::AccessRequests do expect do post api("/#{source_type.pluralize}/#{source.id}/access_requests", access_requester) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end.not_to change { source.requesters.count } end end @@ -95,7 +95,7 @@ describe API::AccessRequests do expect do post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end.not_to change { source.requesters.count } end end @@ -104,7 +104,7 @@ describe API::AccessRequests do expect do post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.requesters.count }.by(1) # User attributes @@ -135,7 +135,7 @@ describe API::AccessRequests do user = public_send(type) put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -147,7 +147,7 @@ describe API::AccessRequests do put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", master), access_level: Member::MASTER - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) # User attributes expect(json_response['id']).to eq(access_requester.id) @@ -166,7 +166,7 @@ describe API::AccessRequests do expect do put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}/approve", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.members.count } end end @@ -187,7 +187,7 @@ describe API::AccessRequests do user = public_send(type) delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -198,7 +198,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", access_requester) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.requesters.count }.by(-1) end end @@ -208,7 +208,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", master) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.requesters.count }.by(-1) end @@ -217,7 +217,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{developer.id}", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.requesters.count } end end @@ -227,7 +227,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.requesters.count } end end diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb index 7a0765c1fae..eaf12f71421 100644 --- a/spec/requests/api/award_emoji_spec.rb +++ b/spec/requests/api/award_emoji_spec.rb @@ -18,7 +18,7 @@ describe API::AwardEmoji do it "returns an array of award_emoji" do get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", 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.first['name']).to eq(award_emoji.name) end @@ -26,7 +26,7 @@ describe API::AwardEmoji do it "returns a 404 error when issue id not found" do get api("/projects/#{project.id}/issues/12345/award_emoji", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -34,7 +34,7 @@ describe API::AwardEmoji do it "returns an array of award_emoji" do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji", 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['name']).to eq(downvote.name) @@ -48,7 +48,7 @@ describe API::AwardEmoji do it 'returns the awarded emoji' do get api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", 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.first['name']).to eq(award.name) end @@ -60,7 +60,7 @@ describe API::AwardEmoji do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -71,7 +71,7 @@ describe API::AwardEmoji do it 'returns an array of award emoji' do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", 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.first['name']).to eq(rocket.name) end @@ -82,7 +82,7 @@ describe API::AwardEmoji do it "returns the award emoji" do get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award_emoji.name) expect(json_response['awardable_id']).to eq(issue.id) expect(json_response['awardable_type']).to eq("Issue") @@ -91,7 +91,7 @@ describe API::AwardEmoji do it "returns a 404 error if the award is not found" do get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -99,7 +99,7 @@ describe API::AwardEmoji do it 'returns the award emoji' do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(downvote.name) expect(json_response['awardable_id']).to eq(merge_request.id) expect(json_response['awardable_type']).to eq("MergeRequest") @@ -113,7 +113,7 @@ describe API::AwardEmoji do it 'returns the awarded emoji' do get api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award.name) expect(json_response['awardable_id']).to eq(snippet.id) expect(json_response['awardable_type']).to eq("Snippet") @@ -126,7 +126,7 @@ describe API::AwardEmoji do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -137,7 +137,7 @@ describe API::AwardEmoji do it 'returns an award emoji' do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to be_an Array expect(json_response['name']).to eq(rocket.name) end @@ -150,7 +150,7 @@ describe API::AwardEmoji do it "creates a new award emoji" do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -158,19 +158,19 @@ describe API::AwardEmoji do it "returns a 400 bad request error if the name is not given" do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if the user is not authenticated" do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji"), name: 'thumbsup' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns a 404 error if the user authored issue" do post api("/projects/#{project.id}/issues/#{issue2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -184,7 +184,7 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'thumbsup' post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -196,7 +196,7 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -211,14 +211,14 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' end.to change { note.award_emoji.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['user']['username']).to eq(user.username) end it "it returns 404 error when user authored note" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -232,7 +232,7 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -244,14 +244,14 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { issue.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when the award emoji can not be found' do delete api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -264,14 +264,14 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { merge_request.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -287,7 +287,7 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { snippet.award_emoji.count }.from(1).to(0) end @@ -304,7 +304,7 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { note.award_emoji.count }.from(1).to(0) end diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb index fcfa4ddfbfe..546a1697e56 100644 --- a/spec/requests/api/boards_spec.rb +++ b/spec/requests/api/boards_spec.rb @@ -44,7 +44,7 @@ describe API::Boards do it "returns authentication error" do get api(base_url) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -52,7 +52,7 @@ describe API::Boards do it "returns the project issue board" do get api(base_url, 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) @@ -70,7 +70,7 @@ describe API::Boards do it 'returns issue board lists' do get api(base_url, 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(2) @@ -80,7 +80,7 @@ describe API::Boards do it 'returns 404 if board not found' do get api("/projects/#{project.id}/boards/22343/lists", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -90,7 +90,7 @@ describe API::Boards do it 'returns a list' do get api("#{base_url}/#{dev_list.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(dev_list.id) expect(json_response['label']['name']).to eq(dev_label.title) expect(json_response['position']).to eq(1) @@ -99,7 +99,7 @@ describe API::Boards do it 'returns 404 if list not found' do get api("#{base_url}/5324", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -113,7 +113,7 @@ describe API::Boards do post api(base_url, user), label_id: group_label.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['label']['name']).to eq(group_label.title) expect(json_response['position']).to eq(3) end @@ -121,7 +121,7 @@ describe API::Boards do it 'creates a new issue board list for project labels' do post api(base_url, user), label_id: ux_label.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['label']['name']).to eq(ux_label.title) expect(json_response['position']).to eq(3) end @@ -129,13 +129,13 @@ describe API::Boards do it 'returns 400 when creating a new list if label_id is invalid' do post api(base_url, user), label_id: 23423 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 403 for project members with guest role' do put api("#{base_url}/#{test_list.id}", guest), position: 1 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -146,7 +146,7 @@ describe API::Boards do put api("#{base_url}/#{test_list.id}", user), position: 1 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['position']).to eq(1) end @@ -154,14 +154,14 @@ describe API::Boards do put api("#{base_url}/44444", user), position: 1 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 403 for project members with guest role" do put api("#{base_url}/#{test_list.id}", guest), position: 1 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -171,19 +171,19 @@ describe API::Boards do it "rejects a non member from deleting a list" do delete api("#{base_url}/#{dev_list.id}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a user with guest role from deleting a list" do delete api("#{base_url}/#{dev_list.id}", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 404 error if list id not found" do delete api("#{base_url}/44444", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when the user is project owner" do @@ -196,7 +196,7 @@ describe API::Boards do it "deletes the list if an admin requests it" do delete api("#{base_url}/#{dev_list.id}", owner) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it_behaves_like '412 response' do diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index eacc575d97f..fe8a14fae9e 100644 --- a/spec/requests/api/broadcast_messages_spec.rb +++ b/spec/requests/api/broadcast_messages_spec.rb @@ -9,13 +9,13 @@ describe API::BroadcastMessages do it 'returns a 401 for anonymous users' do get api('/broadcast_messages') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api('/broadcast_messages', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns an Array of BroadcastMessages for admins' do @@ -23,7 +23,7 @@ describe API::BroadcastMessages do get api('/broadcast_messages', admin) - 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_kind_of(Array) expect(json_response.first.keys) @@ -35,19 +35,19 @@ describe API::BroadcastMessages do it 'returns a 401 for anonymous users' do get api("/broadcast_messages/#{message.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api("/broadcast_messages/#{message.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns the specified message for admins' do get api("/broadcast_messages/#{message.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq message.id expect(json_response.keys) .to match_array(%w(id message starts_at ends_at color font active)) @@ -58,13 +58,13 @@ describe API::BroadcastMessages do it 'returns a 401 for anonymous users' do post api('/broadcast_messages'), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do post api('/broadcast_messages', user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'as an admin' do @@ -74,7 +74,7 @@ describe API::BroadcastMessages do post api('/broadcast_messages', admin), attrs - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'message is missing' end @@ -83,7 +83,7 @@ describe API::BroadcastMessages do travel_to(time) do post api('/broadcast_messages', admin), message: 'Test message' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z' expect(json_response['ends_at']).to eq '2016-07-02T11:11:12.000Z' end @@ -94,7 +94,7 @@ describe API::BroadcastMessages do post api('/broadcast_messages', admin), attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['color']).to eq attrs[:color] expect(json_response['font']).to eq attrs[:font] end @@ -106,14 +106,14 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}"), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do put api("/broadcast_messages/#{message.id}", user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'as an admin' do @@ -122,7 +122,7 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}", admin), attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['color']).to eq attrs[:color] expect(json_response['font']).to eq attrs[:font] end @@ -134,7 +134,7 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}", admin), attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z' expect(json_response['ends_at']).to eq '2016-07-02T13:11:12.000Z' end @@ -145,7 +145,7 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}", admin), attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect { message.reload }.to change { message.message }.to('new message') end end @@ -156,14 +156,14 @@ describe API::BroadcastMessages do delete api("/broadcast_messages/#{message.id}"), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do delete api("/broadcast_messages/#{message.id}", user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it_behaves_like '412 response' do @@ -174,7 +174,7 @@ describe API::BroadcastMessages do expect do delete api("/broadcast_messages/#{message.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { BroadcastMessage.count }.by(-1) end end diff --git a/spec/requests/api/circuit_breakers_spec.rb b/spec/requests/api/circuit_breakers_spec.rb index 76521e55994..3b858c40fd6 100644 --- a/spec/requests/api/circuit_breakers_spec.rb +++ b/spec/requests/api/circuit_breakers_spec.rb @@ -8,13 +8,13 @@ describe API::CircuitBreakers do it 'returns a 401 for anonymous users' do get api('/circuit_breakers/repository_storage') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api('/circuit_breakers/repository_storage', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns an Array of storages' do @@ -24,7 +24,7 @@ describe API::CircuitBreakers do get api('/circuit_breakers/repository_storage', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_kind_of(Array) expect(json_response.first['storage_name']).to eq('broken') expect(json_response.first['failing_on_hosts']).to eq(['web01']) @@ -39,7 +39,7 @@ describe API::CircuitBreakers do get api('/circuit_breakers/repository_storage/failing', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_kind_of(Array) end end @@ -51,7 +51,7 @@ describe API::CircuitBreakers do delete api('/circuit_breakers/repository_storage', admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end end end diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index e4c73583545..ffa17d296e8 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -39,7 +39,7 @@ describe API::CommitStatuses do end it 'returns latest commit statuses' do - 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 @@ -55,7 +55,7 @@ describe API::CommitStatuses do end it 'returns all commit statuses' do - 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(statuses_id).to contain_exactly(status1.id, status2.id, @@ -70,7 +70,7 @@ describe API::CommitStatuses do end it 'returns latest commit statuses for specific ref' do - 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(statuses_id).to contain_exactly(status3.id, status5.id) @@ -83,7 +83,7 @@ describe API::CommitStatuses do end it 'return latest commit statuses for specific name' do - 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(statuses_id).to contain_exactly(status4.id, status5.id) @@ -110,7 +110,7 @@ describe API::CommitStatuses do end it "does not return project commits" do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -120,7 +120,7 @@ describe API::CommitStatuses do end it "does not return project commits" do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -135,7 +135,7 @@ describe API::CommitStatuses do it 'creates commit status' do post api(post_url, developer), state: status - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq(status) expect(json_response['name']).to eq('default') @@ -159,7 +159,7 @@ describe API::CommitStatuses do it "to #{status}" do expect { post api(post_url, developer), state: status }.not_to change { CommitStatus.count } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['status']).to eq(status) end end @@ -181,7 +181,7 @@ describe API::CommitStatuses do it 'creates commit status' do subject - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') expect(json_response['name']).to eq('coverage') @@ -197,7 +197,7 @@ describe API::CommitStatuses do it 'sets head pipeline' do subject - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(merge_request.reload.head_pipeline).not_to be_nil end end @@ -224,7 +224,7 @@ describe API::CommitStatuses do end it 'updates a commit status' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') expect(json_response['name']).to eq('coverage') @@ -250,7 +250,7 @@ describe API::CommitStatuses do end it 'correctly posts a new commit status' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') end @@ -268,7 +268,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -278,7 +278,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -290,7 +290,7 @@ describe API::CommitStatuses do end it 'returns not found error' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -301,7 +301,7 @@ describe API::CommitStatuses do end it 'responds with bad request status and validation errors' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['target_url']) .to include 'must be a valid URL' end @@ -314,7 +314,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -324,7 +324,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -334,7 +334,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 94462b4572d..0d2bd3207c0 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -24,7 +24,7 @@ describe API::Commits do get api(route, current_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/commits') expect(json_response.first['id']).to eq(commit.id) expect(json_response.first['committer_name']).to eq(commit.committer_name) @@ -119,7 +119,7 @@ describe API::Commits do it "returns an invalid parameter error message" do get api("/projects/#{project_id}/repository/commits?since=invalid-date", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('since is invalid') end end @@ -198,13 +198,13 @@ describe API::Commits do it 'returns a 403 unauthorized for user without permissions' do post api(url, guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns a 400 bad request if no params are given' do post api(url, user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end describe 'create' do @@ -248,7 +248,7 @@ describe API::Commits do it 'returns a 400 bad request if file exists' do post api(url, user), invalid_c_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'with project path containing a dot in URL' do @@ -257,7 +257,7 @@ describe API::Commits do it 'a new file in project repo' do post api(url, user), valid_c_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -292,14 +292,14 @@ describe API::Commits do it 'an existing file in project repo' do post api(url, user), valid_d_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post api(url, user), invalid_d_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -337,14 +337,14 @@ describe API::Commits do it 'an existing file in project repo' do post api(url, user), valid_m_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post api(url, user), invalid_m_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -380,14 +380,14 @@ describe API::Commits do it 'an existing file in project repo' do post api(url, user), valid_u_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post api(url, user), invalid_u_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -453,14 +453,14 @@ describe API::Commits do it 'are commited as one in project repo' do post api(url, user), valid_mo_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'return a 400 bad request if there are any issues' do post api(url, user), invalid_mo_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -571,7 +571,7 @@ describe API::Commits do it 'includes a "created" status' do get api(route, current_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/commit/detail') expect(json_response['status']).to eq('created') expect(json_response['last_pipeline']['id']).to eq(pipeline.id) @@ -588,7 +588,7 @@ describe API::Commits do it 'includes a "success" status' do get api(route, current_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/commit/detail') expect(json_response['status']).to eq('success') end diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index 684877c33c0..1f1e6ea17e4 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -48,7 +48,7 @@ describe API::DeployKeys do it 'returns array of ssh keys' do get api("/projects/#{project.id}/deploy_keys", admin) - 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(deploy_key.title) @@ -59,14 +59,14 @@ describe API::DeployKeys do it 'returns a single key' do get api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(deploy_key.title) end it 'returns 404 Not Found with invalid ID' do get api("/projects/#{project.id}/deploy_keys/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -74,14 +74,14 @@ describe API::DeployKeys do it 'does not create an invalid ssh key' do post api("/projects/#{project.id}/deploy_keys", admin), { title: 'invalid key' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create a key without title' do post api("/projects/#{project.id}/deploy_keys", admin), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end @@ -98,7 +98,7 @@ describe API::DeployKeys do post api("/projects/#{project.id}/deploy_keys", admin), { key: deploy_key.key, title: deploy_key.title } end.not_to change { project.deploy_keys.count } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'joins an existing ssh key to a new project' do @@ -106,7 +106,7 @@ describe API::DeployKeys do post api("/projects/#{project2.id}/deploy_keys", admin), { key: deploy_key.key, title: deploy_key.title } end.to change { project2.deploy_keys.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'accepts can_push parameter' do @@ -114,7 +114,7 @@ describe API::DeployKeys do post api("/projects/#{project.id}/deploy_keys", admin), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['can_push']).to eq(true) end end @@ -130,7 +130,7 @@ describe API::DeployKeys do put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin), { title: 'new title' } end.not_to change(deploy_key, :title) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not update a public deploy key as non admin' do @@ -138,7 +138,7 @@ describe API::DeployKeys do put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user), { title: 'new title' } end.not_to change(deploy_key, :title) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not update a private key with invalid title' do @@ -148,7 +148,7 @@ describe API::DeployKeys do put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), { title: '' } end.not_to change(deploy_key, :title) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'updates a private ssh key with correct attributes' do @@ -181,14 +181,14 @@ describe API::DeployKeys do expect do delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { project.deploy_keys.count }.by(-1) end it 'returns 404 Not Found with invalid ID' do delete api("/projects/#{project.id}/deploy_keys/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -205,7 +205,7 @@ describe API::DeployKeys do post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", admin) end.to change { project2.deploy_keys.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(deploy_key.id) end end @@ -214,7 +214,7 @@ describe API::DeployKeys do it 'returns a 404 error' do post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/deployments_spec.rb b/spec/requests/api/deployments_spec.rb index 90d78d060ca..c7977e624ff 100644 --- a/spec/requests/api/deployments_spec.rb +++ b/spec/requests/api/deployments_spec.rb @@ -15,7 +15,7 @@ describe API::Deployments do it 'returns projects deployments' do get api("/projects/#{project.id}/deployments", 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) @@ -28,7 +28,7 @@ describe API::Deployments do it 'returns a 404 status code' do get api("/projects/#{project.id}/deployments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -38,7 +38,7 @@ describe API::Deployments do it 'returns the projects deployment' do get api("/projects/#{project.id}/deployments/#{deployment.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ expect(json_response['id']).to eq(deployment.id) end @@ -48,7 +48,7 @@ describe API::Deployments do it 'returns a 404 status code' do get api("/projects/#{project.id}/deployments/#{deployment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/doorkeeper_access_spec.rb b/spec/requests/api/doorkeeper_access_spec.rb index 868fef65c1c..de7ce848a31 100644 --- a/spec/requests/api/doorkeeper_access_spec.rb +++ b/spec/requests/api/doorkeeper_access_spec.rb @@ -8,7 +8,7 @@ describe 'doorkeeper access' do describe "unauthenticated" do it "returns authentication success" do get api("/user"), access_token: token.token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end include_examples 'user login request with unique ip limit' do @@ -21,14 +21,14 @@ describe 'doorkeeper access' do describe "when token invalid" do it "returns authentication error" do get api("/user"), access_token: "123a" - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end describe "authorization by private token" do it "returns authentication success" do get api("/user", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end include_examples 'user login request with unique ip limit' do @@ -43,7 +43,7 @@ describe 'doorkeeper access' do user.block get api("/user"), access_token: token.token - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -52,7 +52,7 @@ describe 'doorkeeper access' do user.ldap_block get api("/user"), access_token: token.token - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb index f8cd529a06c..3665cfd7241 100644 --- a/spec/requests/api/environments_spec.rb +++ b/spec/requests/api/environments_spec.rb @@ -25,7 +25,7 @@ describe API::Environments do get api("/projects/#{project.id}/environments", 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) @@ -39,7 +39,7 @@ describe API::Environments do it 'returns a 404 status code' do get api("/projects/#{project.id}/environments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -49,7 +49,7 @@ describe API::Environments do it 'creates a environment with valid params' do post api("/projects/#{project.id}/environments", user), name: "mepmep" - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('mepmep') expect(json_response['slug']).to eq('mepmep') expect(json_response['external']).to be nil @@ -58,19 +58,19 @@ describe API::Environments do it 'requires name to be passed' do post api("/projects/#{project.id}/environments", user), external_url: 'test.gitlab.com' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if environment already exists' do post api("/projects/#{project.id}/environments", user), name: environment.name - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if slug is specified' do post api("/projects/#{project.id}/environments", user), name: "foo", slug: "foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end end @@ -79,7 +79,7 @@ describe API::Environments do it 'rejects the request' do post api("/projects/#{project.id}/environments", non_member), name: 'gitlab.com' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 when the required params are missing' do @@ -94,7 +94,7 @@ describe API::Environments do put api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep', external_url: url - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -104,7 +104,7 @@ describe API::Environments do api_url = api("/projects/#{project.id}/environments/#{environment.id}", user) put api_url, slug: slug + "-foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end @@ -113,7 +113,7 @@ describe API::Environments do put api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -121,7 +121,7 @@ describe API::Environments do it 'returns a 404 if the environment does not exist' do put api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -130,13 +130,13 @@ describe API::Environments do it 'returns a 200 for an existing environment' do delete api("/projects/#{project.id}/environments/#{environment.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'returns a 404 for non existing id' do delete api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end @@ -149,7 +149,7 @@ describe API::Environments do it 'rejects the request' do delete api("/projects/#{project.id}/environments/#{environment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -164,7 +164,7 @@ describe API::Environments do end it 'returns a 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'actually stops the environment' do @@ -175,7 +175,7 @@ describe API::Environments do it 'returns a 404 for non existing id' do post api("/projects/#{project.id}/environments/12345/stop", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -184,7 +184,7 @@ describe API::Environments do it 'rejects the request' do post api("/projects/#{project.id}/environments/#{environment.id}/stop", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/events_spec.rb b/spec/requests/api/events_spec.rb index a23d28994ce..962c845f36d 100644 --- a/spec/requests/api/events_spec.rb +++ b/spec/requests/api/events_spec.rb @@ -14,7 +14,7 @@ describe API::Events do it 'returns authentication error' do get api('/events') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -22,7 +22,7 @@ describe API::Events do it 'returns users events' do get api('/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31', 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) @@ -35,7 +35,7 @@ describe API::Events do it 'returns no events' do get api("/users/#{user.id}/events", other_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -44,7 +44,7 @@ describe API::Events do it 'accepts a username' do get api("/users/#{user.username}/events", 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) @@ -53,7 +53,7 @@ describe API::Events do it 'returns the events' do get api("/users/#{user.id}/events", 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) @@ -72,7 +72,7 @@ describe API::Events do end it 'responds with HTTP 200 OK' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'includes the push payload as a Hash' do @@ -120,7 +120,7 @@ describe API::Events do it 'returns a 404 error if not found' do get api('/users/42/events', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end @@ -130,7 +130,7 @@ describe API::Events do it 'returns 404 for private project' do get api("/projects/#{private_project.id}/events") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 200 status for a public project' do @@ -138,7 +138,7 @@ describe API::Events do get api("/projects/#{public_project.id}/events") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -146,7 +146,7 @@ describe API::Events do it 'returns 404' do get api("/projects/#{private_project.id}/events", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -154,7 +154,7 @@ describe API::Events do it 'returns project events' do get api("/projects/#{private_project.id}/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", 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) @@ -163,7 +163,7 @@ describe API::Events do it 'returns 404 if project does not exist' do get api("/projects/1234/events", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index 7e21006b254..267058d98ee 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -44,19 +44,19 @@ describe API::Features do it 'returns a 401 for anonymous users' do get api('/features') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api('/features', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns the feature list for admins' do get api('/features', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to match_array(expected_features) end end @@ -68,20 +68,20 @@ describe API::Features do it 'returns a 401 for anonymous users' do post api("/features/#{feature_name}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do post api("/features/#{feature_name}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'when passed value=true' do it 'creates an enabled feature' do post api("/features/#{feature_name}", admin), value: 'true' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'on', @@ -91,7 +91,7 @@ describe API::Features do it 'creates an enabled feature for the given Flipper group when passed feature_group=perf_team' do post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -104,7 +104,7 @@ describe API::Features do it 'creates an enabled feature for the given user when passed user=username' do post api("/features/#{feature_name}", admin), value: 'true', user: user.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -117,7 +117,7 @@ describe API::Features do it 'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team' do post api("/features/#{feature_name}", admin), value: 'true', user: user.username, feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -132,7 +132,7 @@ describe API::Features do it 'creates a feature with the given percentage if passed an integer' do post api("/features/#{feature_name}", admin), value: '50' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -154,7 +154,7 @@ describe API::Features do it 'enables the feature' do post api("/features/#{feature_name}", admin), value: 'true' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'on', @@ -164,7 +164,7 @@ describe API::Features do it 'enables the feature for the given Flipper group when passed feature_group=perf_team' do post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -177,7 +177,7 @@ describe API::Features do it 'enables the feature for the given user when passed user=username' do post api("/features/#{feature_name}", admin), value: 'true', user: user.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -195,7 +195,7 @@ describe API::Features do post api("/features/#{feature_name}", admin), value: 'false' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'off', @@ -208,7 +208,7 @@ describe API::Features do post api("/features/#{feature_name}", admin), value: 'false', feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'off', @@ -221,7 +221,7 @@ describe API::Features do post api("/features/#{feature_name}", admin), value: 'false', user: user.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'off', @@ -237,7 +237,7 @@ describe API::Features do it 'updates the percentage of time if passed an integer' do post api("/features/#{feature_name}", admin), value: '30' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index 114019441a3..5d8338a3fb7 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -26,7 +26,7 @@ describe API::Files do it 'returns file attributes as json' do get api(route(file_path), current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) expect(json_response['file_name']).to eq('popen.rb') expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') @@ -38,7 +38,7 @@ describe API::Files do get api(route(file_path), current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq('application/json') end @@ -49,7 +49,7 @@ describe API::Files do get api(route(file_path), current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_name']).to eq('commit.js.coffee') expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n") end @@ -60,7 +60,7 @@ describe API::Files do get api(url, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when mandatory params are not given' do @@ -122,7 +122,7 @@ describe API::Files do get api(url, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns raw file info for files with dots' do @@ -131,7 +131,7 @@ describe API::Files do get api(url, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns file by commit sha' do @@ -142,7 +142,7 @@ describe API::Files do get api(route(file_path) + "/raw", current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when mandatory params are not given' do @@ -209,7 +209,7 @@ describe API::Files do it "creates a new file in project repo" do post api(route(file_path), user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["file_path"]).to eq(CGI.unescape(file_path)) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -219,7 +219,7 @@ describe API::Files do it "returns a 400 bad request if no mandatory params given" do post api(route("any%2Etxt"), user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if editor fails to create file" do @@ -228,7 +228,7 @@ describe API::Files do post api(route("any%2Etxt"), user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -237,7 +237,7 @@ describe API::Files do post api(route("new_file_with_author%2Etxt"), user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(response.content_type).to eq('application/json') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) @@ -251,7 +251,7 @@ describe API::Files do it "creates a new file in project repo" do post api(route("newfile%2Erb"), user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['file_path']).to eq('newfile.rb') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -272,7 +272,7 @@ describe API::Files do it "updates existing file in project repo" do put api(route(file_path), user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -284,7 +284,7 @@ describe API::Files do put api(route(file_path), user), params_with_stale_id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('You are attempting to update a file that has changed since you started editing it.') end @@ -295,13 +295,13 @@ describe API::Files do put api(route(file_path), user), params_with_correct_id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns a 400 bad request if no params given" do put api(route(file_path), user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -310,7 +310,7 @@ describe API::Files do put api(route(file_path), user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -329,13 +329,13 @@ describe API::Files do it "deletes existing file in project repo" do delete api(route(file_path), user), valid_params - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it "returns a 400 bad request if no params given" do delete api(route(file_path), user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if fails to delete file" do @@ -343,7 +343,7 @@ describe API::Files do delete api(route(file_path), user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -352,7 +352,7 @@ describe API::Files do delete api(route(file_path), user), valid_params - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end end end @@ -380,7 +380,7 @@ describe API::Files do it "remains unchanged" do get api(route(file_path), user), get_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) expect(json_response['file_name']).to eq(CGI.unescape(file_path)) expect(json_response['content']).to eq(put_params[:content]) diff --git a/spec/requests/api/group_variables_spec.rb b/spec/requests/api/group_variables_spec.rb index 93b9cf85c1d..a4f198eb5c9 100644 --- a/spec/requests/api/group_variables_spec.rb +++ b/spec/requests/api/group_variables_spec.rb @@ -15,7 +15,7 @@ describe API::GroupVariables do it 'returns group variables' do get api("/groups/#{group.id}/variables", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Array) end end @@ -24,7 +24,7 @@ describe API::GroupVariables do it 'does not return group variables' do get api("/groups/#{group.id}/variables", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -32,7 +32,7 @@ describe API::GroupVariables do it 'does not return group variables' do get api("/groups/#{group.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -48,7 +48,7 @@ describe API::GroupVariables do it 'returns group variable details' do get api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['value']).to eq(variable.value) expect(json_response['protected']).to eq(variable.protected?) end @@ -56,7 +56,7 @@ describe API::GroupVariables do it 'responds with 404 Not Found if requesting non-existing variable' do get api("/groups/#{group.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -64,7 +64,7 @@ describe API::GroupVariables do it 'does not return group variable details' do get api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -72,7 +72,7 @@ describe API::GroupVariables do it 'does not return group variable details' do get api("/groups/#{group.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -90,7 +90,7 @@ describe API::GroupVariables do post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true end.to change {group.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_truthy @@ -101,7 +101,7 @@ describe API::GroupVariables do post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' end.to change {group.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_falsey @@ -112,7 +112,7 @@ describe API::GroupVariables do post api("/groups/#{group.id}/variables", user), key: variable.key, value: 'VALUE_2' end.to change {group.variables.count}.by(0) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -120,7 +120,7 @@ describe API::GroupVariables do it 'does not create variable' do post api("/groups/#{group.id}/variables", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -128,7 +128,7 @@ describe API::GroupVariables do it 'does not create variable' do post api("/groups/#{group.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -149,7 +149,7 @@ describe API::GroupVariables do updated_variable = group.variables.first - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(value_before).to eq(variable.value) expect(updated_variable.value).to eq('VALUE_1_UP') expect(updated_variable).to be_protected @@ -158,7 +158,7 @@ describe API::GroupVariables do it 'responds with 404 Not Found if requesting non-existing variable' do put api("/groups/#{group.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -166,7 +166,7 @@ describe API::GroupVariables do it 'does not update variable' do put api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -174,7 +174,7 @@ describe API::GroupVariables do it 'does not update variable' do put api("/groups/#{group.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -191,14 +191,14 @@ describe API::GroupVariables do expect do delete api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {group.variables.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing variable' do delete api("/groups/#{group.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -210,7 +210,7 @@ describe API::GroupVariables do it 'does not delete variable' do delete api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -218,7 +218,7 @@ describe API::GroupVariables do it 'does not delete variable' do delete api("/groups/#{group.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 1671a046fdf..8ce9fcc80bf 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -23,7 +23,7 @@ describe API::Groups do it "returns public groups" do get api("/groups") - 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) @@ -36,7 +36,7 @@ describe API::Groups do it "normal user: returns an array of groups of user1" do get api("/groups", user1) - 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 @@ describe API::Groups do it "does not include statistics" do get api("/groups", user1), statistics: true - 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).not_to include 'statistics' @@ -58,7 +58,7 @@ describe API::Groups do it "admin: returns an array of all groups" do get api("/groups", admin) - 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(2) @@ -67,7 +67,7 @@ describe API::Groups do it "does not include statistics by default" do get api("/groups", admin) - 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).not_to include('statistics') @@ -87,7 +87,7 @@ describe API::Groups do get api("/groups", admin), statistics: true - 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) @@ -99,7 +99,7 @@ describe API::Groups do it "returns all groups excluding skipped groups" do get api("/groups", admin), skip_groups: [group2.id] - 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) @@ -114,7 +114,7 @@ describe API::Groups do get api("/groups", user1), all_available: true - 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(response_groups).to contain_exactly(public_group.name, group1.name) @@ -132,7 +132,7 @@ describe API::Groups do it "sorts by name ascending by default" do get api("/groups", user1) - 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(response_groups).to eq([group3.name, group1.name]) @@ -141,7 +141,7 @@ describe API::Groups do it "sorts in descending order when passed" do get api("/groups", user1), sort: "desc" - 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(response_groups).to eq([group1.name, group3.name]) @@ -150,7 +150,7 @@ describe API::Groups do it "sorts by the order_by param" do get api("/groups", user1), order_by: "path" - 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(response_groups).to eq([group1.name, group3.name]) @@ -163,7 +163,7 @@ describe API::Groups do get api('/groups', user2), owned: true - 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) @@ -176,12 +176,12 @@ describe API::Groups do context 'when unauthenticated' do it 'returns 404 for a private group' do get api("/groups/#{group2.id}") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 200 for a public group' do get api("/groups/#{group1.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -192,7 +192,7 @@ describe API::Groups do get api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(group1.id) expect(json_response['name']).to eq(group1.name) expect(json_response['path']).to eq(group1.path) @@ -214,13 +214,13 @@ describe API::Groups do it "does not return a non existing group" do get api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -228,14 +228,14 @@ describe API::Groups do it "returns any existing group" do get api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group2.name) end it "does not return a non existing group" do get api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -243,20 +243,20 @@ describe API::Groups do it 'returns any existing group' do get api("/groups/#{group1.path}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group1.name) end it 'does not return a non existing group' do get api('/groups/unknown', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get api("/groups/#{group2.path}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -268,7 +268,7 @@ describe API::Groups do it 'updates the group' do put api("/groups/#{group1.id}", user1), name: new_group_name, request_access_enabled: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) expect(json_response['request_access_enabled']).to eq(true) end @@ -276,7 +276,7 @@ describe API::Groups do it 'returns 404 for a non existing group' do put api('/groups/1328', user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -284,7 +284,7 @@ describe API::Groups do it 'updates the group' do put api("/groups/#{group1.id}", admin), name: new_group_name - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) end end @@ -293,7 +293,7 @@ describe API::Groups do it 'does not updates the group' do put api("/groups/#{group1.id}", user2), name: new_group_name - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -301,7 +301,7 @@ describe API::Groups do it 'returns 404 when trying to update the group' do put api("/groups/#{group2.id}", user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -311,7 +311,7 @@ describe API::Groups do it "returns the group's projects" do get api("/groups/#{group1.id}/projects", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } @@ -322,7 +322,7 @@ describe API::Groups do it "returns the group's projects with simple representation" do get api("/groups/#{group1.id}/projects", user1), simple: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } @@ -335,7 +335,7 @@ describe API::Groups do get api("/groups/#{group1.id}/projects", user1), visibility: 'public' - 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) @@ -345,13 +345,13 @@ describe API::Groups do it "does not return a non existing group" do get api("/groups/1328/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get api("/groups/#{group2.id}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "only returns projects to which user has access" do @@ -359,7 +359,7 @@ describe API::Groups do get api("/groups/#{group1.id}/projects", user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project3.name) @@ -370,7 +370,7 @@ describe API::Groups do get api("/groups/#{project2.group.id}/projects", user3), owned: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) end @@ -380,7 +380,7 @@ describe API::Groups do get api("/groups/#{group1.id}/projects", user1), starred: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project1.name) end @@ -390,7 +390,7 @@ describe API::Groups do it "returns any existing group" do get api("/groups/#{group2.id}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) @@ -399,7 +399,7 @@ describe API::Groups do it "does not return a non existing group" do get api("/groups/1328/projects", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -407,7 +407,7 @@ describe API::Groups do it 'returns any existing group' do get api("/groups/#{group1.path}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) @@ -416,13 +416,13 @@ describe API::Groups do it 'does not return a non existing group' do get api('/groups/unknown/projects', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get api("/groups/#{group2.path}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -432,7 +432,7 @@ describe API::Groups do it "does not create group" do post api("/groups", user1), attributes_for(:group) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'as owner', :nested_groups do @@ -443,7 +443,7 @@ describe API::Groups do it 'can create subgroups' do post api("/groups", user1), parent_id: group2.id, name: 'foo', path: 'foo' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -455,7 +455,7 @@ describe API::Groups do it 'cannot create subgroups' do post api("/groups", user1), parent_id: group2.id, name: 'foo', path: 'foo' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -466,7 +466,7 @@ describe API::Groups do post api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(group[:name]) expect(json_response["path"]).to eq(group[:path]) @@ -481,7 +481,7 @@ describe API::Groups do post api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["full_path"]).to eq("#{parent.path}/#{group[:path]}") expect(json_response["parent_id"]).to eq(parent.id) @@ -490,20 +490,20 @@ describe API::Groups do it "does not create group, duplicate" do post api("/groups", user3), { name: 'Duplicate Test', path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(response.message).to eq("Bad Request") end it "returns 400 bad request error if name not given" do post api("/groups", user3), { path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 bad request error if path not given" do post api("/groups", user3), { name: 'test' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -513,7 +513,7 @@ describe API::Groups do it "removes group" do delete api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it_behaves_like '412 response' do @@ -526,19 +526,19 @@ describe API::Groups do delete api("/groups/#{group1.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "does not remove a non existing group" do delete api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not remove a group not attached to user1" do delete api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -546,13 +546,13 @@ describe API::Groups do it "removes any existing group" do delete api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it "does not remove a non existing group" do delete api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -570,7 +570,7 @@ describe API::Groups do it "does not transfer project to group" do post api("/groups/#{group1.id}/projects/#{project.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -578,7 +578,7 @@ describe API::Groups do it "transfers project to group" do post api("/groups/#{group1.id}/projects/#{project.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when using project path in URL' do @@ -586,7 +586,7 @@ describe API::Groups do it "transfers project to group" do post api("/groups/#{group1.id}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -594,7 +594,7 @@ describe API::Groups do it "does not transfer project to group" do post api("/groups/#{group1.id}/projects/nogroup%2Fnoproject", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -604,7 +604,7 @@ describe API::Groups do it "transfers project to group" do post api("/groups/#{group1.path}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -612,7 +612,7 @@ describe API::Groups do it "does not transfer project to group" do post api("/groups/noexist/projects/#{project_path}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 1274e66bb4c..d919899282d 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -14,7 +14,7 @@ describe API::Internal do get api("/internal/check"), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['api_version']).to eq(API::API.version) expect(json_response['redis']).to be(true) end @@ -35,7 +35,7 @@ describe API::Internal do it 'returns one broadcast message' do get api('/internal/broadcast_message'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['message']).to eq(broadcast_message.message) end end @@ -44,7 +44,7 @@ describe API::Internal do it 'returns nothing' do get api('/internal/broadcast_message'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -55,7 +55,7 @@ describe API::Internal do get api('/internal/broadcast_message'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -68,7 +68,7 @@ describe API::Internal do it 'returns active broadcast message(s)' do get api('/internal/broadcast_messages'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response[0]['message']).to eq(broadcast_message.message) end end @@ -77,7 +77,7 @@ describe API::Internal do it 'returns nothing' do get api('/internal/broadcast_messages'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -154,7 +154,7 @@ describe API::Internal do it 'returns the correct information about the key' do lfs_auth(key.id, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['username']).to eq(user.username) expect(json_response['lfs_token']).to eq(Gitlab::LfsToken.new(key).token) @@ -164,7 +164,7 @@ describe API::Internal do it 'returns a 404 when the wrong key is provided' do lfs_auth(nil, project) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -174,7 +174,7 @@ describe API::Internal do it 'returns the correct information about the key' do lfs_auth(key.id, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['username']).to eq("lfs+deploy-key-#{key.id}") expect(json_response['lfs_token']).to eq(Gitlab::LfsToken.new(key).token) expect(json_response['repository_http_path']).to eq(project.http_url_to_repo) @@ -186,7 +186,7 @@ describe API::Internal do it do get(api("/internal/discover"), key_id: key.id, secret_token: secret_token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(user.name) end @@ -214,7 +214,7 @@ describe API::Internal do GIT_ALTERNATE_OBJECT_DIRECTORIES: 'bar' }.to_json) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -222,7 +222,7 @@ describe API::Internal do it 'responds with success' do push(key, project.wiki) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.wiki.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") @@ -234,7 +234,7 @@ describe API::Internal do it 'responds with success' do pull(key, project.wiki) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.wiki.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") @@ -248,7 +248,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_upload_pack).and_return(false) pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -262,7 +262,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_upload_pack).and_return(true) pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -283,7 +283,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_receive_pack).and_return(false) push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -297,7 +297,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_receive_pack).and_return(true) push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -315,7 +315,7 @@ describe API::Internal do it do pull(key, project_with_repo_path('/' + project.full_path)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -326,7 +326,7 @@ describe API::Internal do it do pull(key, project_with_repo_path(project.full_path)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -344,7 +344,7 @@ describe API::Internal do it do pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -354,7 +354,7 @@ describe API::Internal do it do push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -372,7 +372,7 @@ describe API::Internal do it do pull(key, personal_project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -382,7 +382,7 @@ describe API::Internal do it do push(key, personal_project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -399,7 +399,7 @@ describe API::Internal do it do pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy end end @@ -408,7 +408,7 @@ describe API::Internal do it do push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -425,7 +425,7 @@ describe API::Internal do it do archive(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy end end @@ -434,7 +434,7 @@ describe API::Internal do it do archive(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -444,7 +444,7 @@ describe API::Internal do it do pull(key, project_with_repo_path('gitlab/notexist')) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -453,7 +453,7 @@ describe API::Internal do it do pull(OpenStruct.new(id: 0), project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -535,7 +535,7 @@ describe API::Internal do it 'rejects the push' do push_with_path(key, old_path_to_repo) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq(project_moved_message) end @@ -543,7 +543,7 @@ describe API::Internal do it 'rejects the SSH pull' do pull_with_path(key, old_path_to_repo) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq(project_moved_message) end @@ -614,7 +614,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # # it "calls the Gitaly client with the wiki's repository if it's a wiki" do @@ -626,7 +626,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_wiki_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # # it "returns 500 if the gitaly call fails" do @@ -635,7 +635,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_http_status(500) + # expect(response).to have_gitlab_http_status(500) # end # # context 'with a gl_repository parameter' do @@ -656,7 +656,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # # it "calls the Gitaly client with the wiki's repository if it's a wiki" do @@ -668,7 +668,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_wiki_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # end # end @@ -734,7 +734,7 @@ describe API::Internal do it 'returns one broadcast message' do post api("/internal/post_receive"), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(broadcast_message.message) end end @@ -743,7 +743,7 @@ describe API::Internal do it 'returns empty string' do post api("/internal/post_receive"), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(nil) end end @@ -754,7 +754,7 @@ describe API::Internal do post api("/internal/post_receive"), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(nil) end end diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 972e57bc373..99525cd0a6a 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -67,7 +67,7 @@ describe API::Issues, :mailer do it "returns authentication error" do get api("/issues") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context "when authenticated" do @@ -297,7 +297,7 @@ describe API::Issues, :mailer do it 'matches V4 response schema' do get api('/issues', 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 end @@ -474,7 +474,7 @@ describe API::Issues, :mailer do it 'returns an array of issues with no milestone' do get api("#{base_url}?milestone=#{no_milestone_title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_confidential_issue.id) @@ -535,7 +535,7 @@ describe API::Issues, :mailer do it 'returns 404 when project does not exist' do get api('/projects/1000/issues', non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 on private projects for other users" do @@ -544,7 +544,7 @@ describe API::Issues, :mailer do get api("/projects/#{private_project.id}/issues", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns no issues when user has access to project but not issues' do @@ -732,7 +732,7 @@ describe API::Issues, :mailer do it 'exposes known attributes' do get api("/projects/#{project.id}/issues/#{issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(issue.id) expect(json_response['iid']).to eq(issue.iid) expect(json_response['project_id']).to eq(issue.project.id) @@ -753,7 +753,7 @@ describe API::Issues, :mailer do it "exposes the 'closed_at' attribute" do get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['closed_at']).to be_present end @@ -773,39 +773,39 @@ describe API::Issues, :mailer do it "returns a project issue by internal id" do get api("/projects/#{project.id}/issues/#{issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(issue.title) expect(json_response['iid']).to eq(issue.iid) end it "returns 404 if issue id not found" do get api("/projects/#{project.id}/issues/54321", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 if the issue ID is used" do get api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'confidential issues' do it "returns 404 for non project members" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 for project members with guest role" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns confidential issue for project members" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -813,7 +813,7 @@ describe API::Issues, :mailer do it "returns confidential issue for author" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -821,7 +821,7 @@ describe API::Issues, :mailer do it "returns confidential issue for assignee" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", assignee) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -829,7 +829,7 @@ describe API::Issues, :mailer do it "returns confidential issue for admin" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -842,7 +842,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', assignee_id: user2.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['assignee']['name']).to eq(user2.name) expect(json_response['assignees'].first['name']).to eq(user2.name) @@ -854,7 +854,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', assignee_ids: [user2.id, guest.id] - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['assignees'].count).to eq(1) end @@ -865,7 +865,7 @@ describe API::Issues, :mailer do title: 'new issue', labels: 'label, label2', weight: 3, assignee_ids: [user2.id] - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['labels']).to eq(%w(label label2)) @@ -878,7 +878,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -887,7 +887,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'y' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -896,7 +896,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: false - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_falsy end @@ -905,7 +905,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end @@ -923,7 +923,7 @@ describe API::Issues, :mailer do it "returns a 400 bad request if title not given" do post api("/projects/#{project.id}/issues", user), labels: 'label, label2' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do @@ -941,7 +941,7 @@ describe API::Issues, :mailer do it 'returns 400 if title is too long' do post api("/projects/#{project.id}/issues", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -985,7 +985,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', due_date: due_date - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['due_date']).to eq(due_date) @@ -998,7 +998,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', labels: 'label, label2', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) end end @@ -1028,7 +1028,7 @@ describe API::Issues, :mailer do it "does not create a new project issue" do expect { post api("/projects/#{project.id}/issues", user), params }.not_to change(Issue, :count) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -1044,7 +1044,7 @@ describe API::Issues, :mailer do it "updates a project issue" do put api("/projects/#{project.id}/issues/#{issue.iid}", 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 @@ -1052,13 +1052,13 @@ describe API::Issues, :mailer do it "returns 404 error if issue iid not found" do put api("/projects/#{project.id}/issues/44444", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 error if issue id is used instead of the iid" do put api("/projects/#{project.id}/issues/#{issue.id}", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'allows special label names' do @@ -1078,33 +1078,33 @@ describe API::Issues, :mailer do it "returns 403 for non project members" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 403 for project members with guest role" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "updates a confidential issue for project members" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", 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 it "updates a confidential issue for author" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author), 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 it "updates a confidential issue for admin" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin), 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 @@ -1112,7 +1112,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), confidential: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_truthy end @@ -1120,7 +1120,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), confidential: false - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_falsy end @@ -1128,7 +1128,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end end @@ -1149,7 +1149,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -1167,7 +1167,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_id: 0 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']).to be_nil end @@ -1176,7 +1176,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_id: user2.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']['name']).to eq(user2.name) end @@ -1186,7 +1186,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_ids: [0] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignees']).to be_empty end @@ -1195,7 +1195,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_ids: [user2.id] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignees'].first['name']).to eq(user2.name) end @@ -1205,7 +1205,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_ids: [user2.id, guest.id] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignees'].size).to eq(1) end @@ -1219,7 +1219,7 @@ describe API::Issues, :mailer do it 'does not update labels if not present' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([label.title]) end @@ -1238,14 +1238,14 @@ describe API::Issues, :mailer do it 'removes all labels' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: '' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([]) end it 'updates labels' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: 'foo,bar' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'foo' expect(json_response['labels']).to include 'bar' end @@ -1267,7 +1267,7 @@ describe API::Issues, :mailer do it 'returns 400 if title is too long' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -1278,7 +1278,7 @@ describe API::Issues, :mailer do it "updates a project issue" do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: 'label2', state_event: "close" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label2' expect(json_response['state']).to eq "closed" @@ -1287,7 +1287,7 @@ describe API::Issues, :mailer do it 'reopens a project isssue' do put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), state_event: 'reopen' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq 'opened' end @@ -1297,7 +1297,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: 'label3', state_event: 'close', updated_at: update_time - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label3' expect(Time.parse(json_response['updated_at'])).to be_like_time(update_time) end @@ -1310,7 +1310,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), due_date: due_date - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to eq(due_date) end end @@ -1318,12 +1318,12 @@ describe API::Issues, :mailer do describe "DELETE /projects/:id/issues/:issue_iid" do it "rejects a non member from deleting an issue" do delete api("/projects/#{project.id}/issues/#{issue.iid}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a developer from deleting an issue" do delete api("/projects/#{project.id}/issues/#{issue.iid}", author) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context "when the user is project owner" do @@ -1333,7 +1333,7 @@ describe API::Issues, :mailer do it "deletes the issue if an admin requests it" do delete api("/projects/#{project.id}/issues/#{issue.iid}", owner) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it_behaves_like '412 response' do @@ -1345,14 +1345,14 @@ describe API::Issues, :mailer do it 'returns 404 when trying to move an issue' do delete api("/projects/#{project.id}/issues/123", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end it 'returns 404 when using the issue ID instead of IID' do delete api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1364,7 +1364,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project.id) end @@ -1373,7 +1373,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: project.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue to project it originates from!') end end @@ -1383,7 +1383,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: target_project2.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!') end end @@ -1392,7 +1392,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", admin), to_project_id: target_project2.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project2.id) end @@ -1401,7 +1401,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') end end @@ -1411,7 +1411,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/123/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') end end @@ -1421,7 +1421,7 @@ describe API::Issues, :mailer do post api("/projects/123/issues/#{issue.iid}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end end @@ -1431,7 +1431,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: 123 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1440,32 +1440,32 @@ describe API::Issues, :mailer do it 'subscribes to an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/subscribe", user2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do post api("/projects/#{project.id}/issues/#{issue.iid}/subscribe", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do post api("/projects/#{project.id}/issues/123/subscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue ID is used instead of the iid' do post api("/projects/#{project.id}/issues/#{issue.id}/subscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/subscribe", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1473,32 +1473,32 @@ describe API::Issues, :mailer do it 'unsubscribes from an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/unsubscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do post api("/projects/#{project.id}/issues/#{issue.iid}/unsubscribe", user2) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do post api("/projects/#{project.id}/issues/123/unsubscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if using the issue ID instead of iid' do post api("/projects/#{project.id}/issues/#{issue.id}/unsubscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/unsubscribe", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1539,7 +1539,7 @@ describe API::Issues, :mailer do it "returns 404 when issue doesn't exists" do get api("/projects/#{project.id}/issues/9999/closed_by", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1549,7 +1549,7 @@ describe API::Issues, :mailer do it 'exposes known attributes' do get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -1558,12 +1558,12 @@ describe API::Issues, :mailer do it "returns unautorized for non-admin users" do get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end def expect_paginated_array_response(size: nil) - 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(size) if size diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index 2d7cc1a1798..3b7b9c889e7 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -31,7 +31,7 @@ describe API::Jobs do context 'authorized user' do it 'returns project jobs' do - 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 end @@ -55,7 +55,7 @@ describe API::Jobs do let(:query) { { 'scope' => 'pending' } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -64,7 +64,7 @@ describe API::Jobs do let(:query) { { scope: %w(pending running) } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -72,7 +72,7 @@ describe API::Jobs do context 'respond 400 when scope contains invalid state' do let(:query) { { scope: %w(unknown running) } } - it { expect(response).to have_http_status(400) } + it { expect(response).to have_gitlab_http_status(400) } end end @@ -80,7 +80,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return project jobs' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -94,7 +94,7 @@ describe API::Jobs do context 'authorized user' do it 'returns pipeline jobs' do - 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 end @@ -118,7 +118,7 @@ describe API::Jobs do let(:query) { { 'scope' => 'pending' } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -127,7 +127,7 @@ describe API::Jobs do let(:query) { { scope: %w(pending running) } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -135,7 +135,7 @@ describe API::Jobs do context 'respond 400 when scope contains invalid state' do let(:query) { { scope: %w(unknown running) } } - it { expect(response).to have_http_status(400) } + it { expect(response).to have_gitlab_http_status(400) } end context 'jobs in different pipelines' do @@ -152,7 +152,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return jobs' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -164,7 +164,7 @@ describe API::Jobs do context 'authorized user' do it 'returns specific job data' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('test') end @@ -183,7 +183,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return specific job data' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -207,7 +207,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -219,7 +219,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -231,7 +231,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -244,7 +244,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers) .to include('Content-Type' => 'application/json', 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) @@ -256,7 +256,7 @@ describe API::Jobs do it 'does not return job artifact file' do get_artifact_file('some/artifact') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -281,7 +281,7 @@ describe API::Jobs do end it 'returns specific job artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers).to include(download_headers) expect(response.body).to match_file(job.artifacts_file.file.file) end @@ -292,13 +292,13 @@ describe API::Jobs do it 'hides artifacts and rejects request' do expect(project).to be_private - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end it 'does not return job artifacts if not uploaded' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -323,7 +323,7 @@ describe API::Jobs do it 'does not find a resource in a private project' do expect(project).to be_private - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -335,13 +335,13 @@ describe API::Jobs do end it 'gives 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'non-existing job' do shared_examples 'not found' do - it { expect(response).to have_http_status(:not_found) } + it { expect(response).to have_gitlab_http_status(:not_found) } end context 'has no such ref' do @@ -369,7 +369,7 @@ describe API::Jobs do "attachment; filename=#{job.artifacts_file.filename}" } end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } it { expect(response.headers).to include(download_headers) } end @@ -410,7 +410,7 @@ describe API::Jobs do context 'authorized user' do it 'returns specific job trace' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq(job.trace.raw) end end @@ -419,7 +419,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return specific job trace' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -432,7 +432,7 @@ describe API::Jobs do context 'authorized user' do context 'user with :update_build persmission' do it 'cancels running or pending job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') end end @@ -441,7 +441,7 @@ describe API::Jobs do let(:api_user) { reporter } it 'does not cancel job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -450,7 +450,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not cancel job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -465,7 +465,7 @@ describe API::Jobs do context 'authorized user' do context 'user with :update_build permission' do it 'retries non-running job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') expect(json_response['status']).to eq('pending') end @@ -475,7 +475,7 @@ describe API::Jobs do let(:api_user) { reporter } it 'does not retry job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -484,7 +484,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not retry job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -498,7 +498,7 @@ describe API::Jobs do let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) } it 'erases job content' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job).not_to have_trace expect(job.artifacts_file.exists?).to be_falsy expect(job.artifacts_metadata.exists?).to be_falsy @@ -516,7 +516,7 @@ describe API::Jobs do let(:job) { create(:ci_build, :trace, project: project, pipeline: pipeline) } it 'responds with forbidden' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -533,7 +533,7 @@ describe API::Jobs do end it 'keeps artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(job.reload.artifacts_expire_at).to be_nil end end @@ -542,7 +542,7 @@ describe API::Jobs do let(:job) { create(:ci_build, project: project, pipeline: pipeline) } it 'responds with not found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -557,7 +557,7 @@ describe API::Jobs do context 'when user is authorized to trigger a manual action' do it 'plays the job' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user']['id']).to eq(user.id) expect(json_response['id']).to eq(job.id) expect(job.reload).to be_pending @@ -570,7 +570,7 @@ describe API::Jobs do it 'does not trigger a manual action' do expect(job.reload).to be_manual - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -579,7 +579,7 @@ describe API::Jobs do it 'does not trigger a manual action' do expect(job.reload).to be_manual - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -587,7 +587,7 @@ describe API::Jobs do context 'on a non-playable job' do it 'returns a status code 400, Bad Request' do - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 expect(response.body).to match("Unplayable Job") end end diff --git a/spec/requests/api/keys_spec.rb b/spec/requests/api/keys_spec.rb index f534332ca6c..3c4719964b6 100644 --- a/spec/requests/api/keys_spec.rb +++ b/spec/requests/api/keys_spec.rb @@ -10,14 +10,14 @@ describe API::Keys do context 'when unauthenticated' do it 'returns authentication error' do get api("/keys/#{key.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing key' do get api('/keys/999999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end @@ -25,7 +25,7 @@ describe API::Keys do user.keys << key user.save get api("/keys/#{key.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(key.title) expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['username']).to eq(user.username) diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index b231fdea2a3..3498e5bc8d9 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -27,7 +27,7 @@ describe API::Labels do get api("/projects/#{project.id}/labels", 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(3) @@ -75,7 +75,7 @@ describe API::Labels do description: 'test', priority: 2 - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('Foo') expect(json_response['color']).to eq('#FFAABB') expect(json_response['description']).to eq('test') @@ -109,19 +109,19 @@ describe API::Labels do it 'returns a 400 bad request if name not given' do post api("/projects/#{project.id}/labels", user), color: '#FFAABB' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 bad request if color not given' do post api("/projects/#{project.id}/labels", user), name: 'Foobar' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 for invalid color' do post api("/projects/#{project.id}/labels", user), name: 'Foo', color: '#FFAA' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -129,7 +129,7 @@ describe API::Labels do post api("/projects/#{project.id}/labels", user), name: 'Foo', color: '#FFAAFFFF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -137,7 +137,7 @@ describe API::Labels do post api("/projects/#{project.id}/labels", user), name: ',', color: '#FFAABB' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end @@ -150,7 +150,7 @@ describe API::Labels do name: group_label.name, color: '#FFAABB' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') end @@ -160,14 +160,14 @@ describe API::Labels do color: '#FFAAFFFF', priority: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 409 if label already exists in project' do post api("/projects/#{project.id}/labels", user), name: 'label1', color: '#FFAABB' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') end end @@ -176,18 +176,18 @@ describe API::Labels do it 'returns 204 for existing label' do delete api("/projects/#{project.id}/labels", user), name: 'label1' - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'returns 404 for non existing label' do delete api("/projects/#{project.id}/labels", user), name: 'label2' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Label Not Found') end it 'returns 400 for wrong parameters' do delete api("/projects/#{project.id}/labels", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it_behaves_like '412 response' do @@ -203,7 +203,7 @@ describe API::Labels do new_name: 'New Label', color: '#FFFFFF', description: 'test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq('#FFFFFF') expect(json_response['description']).to eq('test') @@ -213,7 +213,7 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label1', new_name: 'New Label' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq(label1.color) end @@ -222,7 +222,7 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label1', color: '#FFFFFF' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(label1.name) expect(json_response['color']).to eq('#FFFFFF') end @@ -232,7 +232,7 @@ describe API::Labels do name: 'bug', description: 'test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(priority_label.name) expect(json_response['description']).to eq('test') expect(json_response['priority']).to eq(3) @@ -272,18 +272,18 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label2', new_name: 'label3' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 if no label name given' do put api("/projects/#{project.id}/labels", user), new_name: 'label2' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end it 'returns 400 if no new parameters given' do put api("/projects/#{project.id}/labels", user), name: 'label1' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('new_name, color, description, priority are missing, '\ 'at least one parameter must be provided') end @@ -293,7 +293,7 @@ describe API::Labels do name: 'label1', new_name: ',', color: '#FFFFFF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end @@ -301,7 +301,7 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label1', color: '#FF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -309,7 +309,7 @@ describe API::Labels do post api("/projects/#{project.id}/labels", user), name: 'Foo', color: '#FFAAFFFF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -318,7 +318,7 @@ describe API::Labels do name: 'Foo', priority: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -327,7 +327,7 @@ describe API::Labels do it "subscribes to the label" do post api("/projects/#{project.id}/labels/#{label1.title}/subscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -337,7 +337,7 @@ describe API::Labels do it "subscribes to the label" do post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -351,7 +351,7 @@ describe API::Labels do it "returns 304" do post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -359,7 +359,7 @@ describe API::Labels do it "returns 404 error" do post api("/projects/#{project.id}/labels/1234/subscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -373,7 +373,7 @@ describe API::Labels do it "unsubscribes from the label" do post api("/projects/#{project.id}/labels/#{label1.title}/unsubscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -383,7 +383,7 @@ describe API::Labels do it "unsubscribes from the label" do post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -397,7 +397,7 @@ describe API::Labels do it "returns 304" do post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -405,7 +405,7 @@ describe API::Labels do it "returns 404 error" do post api("/projects/#{project.id}/labels/1234/unsubscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb index df7c91b5bc1..e3065840e6f 100644 --- a/spec/requests/api/lint_spec.rb +++ b/spec/requests/api/lint_spec.rb @@ -10,7 +10,7 @@ describe API::Lint do it 'passes validation' do post api('/ci/lint'), { content: yaml_content } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Hash expect(json_response['status']).to eq('valid') expect(json_response['errors']).to eq([]) @@ -21,7 +21,7 @@ describe API::Lint do it 'responds with errors about invalid syntax' do post api('/ci/lint'), { content: 'invalid content' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('invalid') expect(json_response['errors']).to eq(['Invalid configuration format']) end @@ -29,7 +29,7 @@ describe API::Lint do it "responds with errors about invalid configuration" do post api('/ci/lint'), { content: '{ image: "ruby:2.1", services: ["postgres"] }' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('invalid') expect(json_response['errors']).to eq(['jobs config should contain at least one visible job']) end @@ -39,7 +39,7 @@ describe API::Lint do it 'responds with validation error about missing content' do post api('/ci/lint') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('content is missing') end end diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb index d3bae8d2888..3349e396ab8 100644 --- a/spec/requests/api/members_spec.rb +++ b/spec/requests/api/members_spec.rb @@ -35,7 +35,7 @@ describe API::Members do get api("/#{source_type.pluralize}/#{source.id}/members", 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) @@ -49,7 +49,7 @@ describe API::Members do get api("/#{source_type.pluralize}/#{source.id}/members", developer) - 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) @@ -59,7 +59,7 @@ describe API::Members do it 'finds members with query string' do get api("/#{source_type.pluralize}/#{source.id}/members", developer), query: master.username - 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.count).to eq(1) @@ -81,7 +81,7 @@ describe API::Members do user = public_send(type) get api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # User attributes expect(json_response['id']).to eq(developer.id) expect(json_response['name']).to eq(developer.name) @@ -116,7 +116,7 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", user), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -129,7 +129,7 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(source.requesters.count).to eq(0) expect(json_response['id']).to eq(access_requester.id) @@ -142,7 +142,7 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: '2016-08-05' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(json_response['id']).to eq(stranger.id) expect(json_response['access_level']).to eq(Member::DEVELOPER) @@ -154,28 +154,28 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: master.id, access_level: Member::MASTER - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) end it 'returns 400 when user_id is not given' do post api("/#{source_type.pluralize}/#{source.id}/members", master), access_level: Member::MASTER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not given' do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not valid' do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -197,7 +197,7 @@ describe API::Members do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user), access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -208,7 +208,7 @@ describe API::Members do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: Member::MASTER, expires_at: '2016-08-05' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(developer.id) expect(json_response['access_level']).to eq(Member::MASTER) expect(json_response['expires_at']).to eq('2016-08-05') @@ -219,20 +219,20 @@ describe API::Members do put api("/#{source_type.pluralize}/#{source.id}/members/123", master), access_level: Member::MASTER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 when access_level is not given' do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access level is not valid' do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -250,7 +250,7 @@ describe API::Members do user = public_send(type) delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -261,7 +261,7 @@ describe API::Members do expect do delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", developer) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.members.count }.by(-1) end end @@ -272,7 +272,7 @@ describe API::Members do expect do delete api("/#{source_type.pluralize}/#{source.id}/members/#{access_requester.id}", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.requesters.count } end end @@ -281,7 +281,7 @@ describe API::Members do expect do delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.members.count }.by(-1) end @@ -293,7 +293,7 @@ describe API::Members do it 'returns 404 if member does not exist' do delete api("/#{source_type.pluralize}/#{source.id}/members/123", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -344,7 +344,7 @@ describe API::Members do post api("/projects/#{project.id}/members", master), user_id: stranger.id, access_level: Member::OWNER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end.to change { project.members.count }.by(0) end end diff --git a/spec/requests/api/merge_request_diffs_spec.rb b/spec/requests/api/merge_request_diffs_spec.rb index d9da94d4713..bf4c8443b23 100644 --- a/spec/requests/api/merge_request_diffs_spec.rb +++ b/spec/requests/api/merge_request_diffs_spec.rb @@ -26,12 +26,12 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request id is used instead of the iid' do get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 when merge_request_iid not found' do get api("/projects/#{project.id}/merge_requests/999/versions", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -49,17 +49,17 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request id is used instead of the iid' do get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions/#{merge_request_diff.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 when merge_request version_id is not found' do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions/999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 when merge_request_iid is not found' do get api("/projects/#{project.id}/merge_requests/12345/versions/#{merge_request_diff.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 5e66e1607ba..28b1404a4f7 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -33,26 +33,26 @@ describe API::MergeRequests do it 'returns an array of all merge requests' do get api('/merge_requests', user), scope: 'all' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end it "returns authentication error without any scope" do get api("/merge_requests") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns authentication error when scope is assigned-to-me" do get api("/merge_requests"), scope: 'assigned-to-me' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns authentication error when scope is created-by-me" do get api("/merge_requests"), scope: 'created-by-me' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -158,7 +158,7 @@ describe API::MergeRequests do it 'returns merge requests for public projects' do get api("/projects/#{project.id}/merge_requests") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end @@ -166,7 +166,7 @@ describe API::MergeRequests do project = create(:project, :private) get api("/projects/#{project.id}/merge_requests") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb index 26cf653ca8e..e60716d46d7 100644 --- a/spec/requests/api/namespaces_spec.rb +++ b/spec/requests/api/namespaces_spec.rb @@ -10,7 +10,7 @@ describe API::Namespaces do context "when unauthenticated" do it "returns authentication error" do get api("/namespaces") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -21,7 +21,7 @@ describe API::Namespaces do group_kind_json_response = json_response.find { |resource| resource['kind'] == 'group' } user_kind_json_response = json_response.find { |resource| resource['kind'] == 'user' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(group_kind_json_response.keys).to contain_exactly('id', 'kind', 'name', 'path', 'full_path', 'parent_id', 'members_count_with_descendants') @@ -32,7 +32,7 @@ describe API::Namespaces do it "admin: returns an array of all namespaces" do get api("/namespaces", admin) - 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(Namespace.count) @@ -41,7 +41,7 @@ describe API::Namespaces do it "admin: returns an array of matched namespaces" do get api("/namespaces?search=#{group2.name}", admin) - 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) @@ -75,7 +75,7 @@ describe API::Namespaces do it "user: returns an array of namespaces" do get api("/namespaces", 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) @@ -84,7 +84,7 @@ describe API::Namespaces do it "admin: returns an array of matched namespaces" do get api("/namespaces?search=#{user.username}", 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) diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index fb440fa551c..784070db173 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -37,7 +37,7 @@ describe API::Notes do it "returns an array of issue notes" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes", 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['body']).to eq(issue_note.note) @@ -46,14 +46,14 @@ describe API::Notes do it "returns a 404 error when issue id not found" do get api("/projects/#{project.id}/issues/12345/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the notes" do it "returns an empty array" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", 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).to be_empty @@ -67,7 +67,7 @@ describe API::Notes do it "returns 404" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -75,7 +75,7 @@ describe API::Notes do it "returns an empty array" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", private_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['body']).to eq(cross_reference_note.note) @@ -88,7 +88,7 @@ describe API::Notes do it "returns an array of snippet notes" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes", 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['body']).to eq(snippet_note.note) @@ -97,13 +97,13 @@ describe API::Notes do it "returns a 404 error when snippet id not found" do get api("/projects/#{project.id}/snippets/42/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -111,7 +111,7 @@ describe API::Notes do it "returns an array of merge_requests notes" do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", 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['body']).to eq(merge_request_note.note) @@ -120,13 +120,13 @@ describe API::Notes do it "returns a 404 error if merge request id not found" do get api("/projects/#{project.id}/merge_requests/4444/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get api("/projects/#{project.id}/merge_requests/4444/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -136,21 +136,21 @@ describe API::Notes do it "returns an issue note by id" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{issue_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(issue_note.note) end it "returns a 404 error if issue note not found" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the note" do it "returns a 404 error" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes/#{cross_reference_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when issue is confidential" do @@ -161,7 +161,7 @@ describe API::Notes do it "returns 404" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{issue_note.id}", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -169,7 +169,7 @@ describe API::Notes do it "returns an issue note by id" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes/#{cross_reference_note.id}", private_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(cross_reference_note.note) end end @@ -180,14 +180,14 @@ describe API::Notes do it "returns a snippet note by id" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(snippet_note.note) end it "returns a 404 error if snippet note not found" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -197,7 +197,7 @@ describe API::Notes do it "creates a new issue note" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -205,13 +205,13 @@ describe API::Notes do it "returns a 400 bad request error if body not given" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end context 'when an admin or owner makes the request' do @@ -220,7 +220,7 @@ describe API::Notes do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: 'hi!', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) @@ -233,7 +233,7 @@ describe API::Notes do it 'creates a new issue note' do post api("/projects/#{project.id}/issues/#{issue2.iid}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -242,7 +242,7 @@ describe API::Notes do it 'creates a new issue note' do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -252,7 +252,7 @@ describe API::Notes do it "creates a new snippet note" do post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -260,13 +260,13 @@ describe API::Notes do it "returns a 400 bad request error if body not given" do post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post api("/projects/#{project.id}/snippets/#{snippet.id}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -278,7 +278,7 @@ describe API::Notes do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: 'Foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -314,7 +314,7 @@ describe API::Notes do it 'returns 200 status' do subject - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'creates a new note' do @@ -328,7 +328,7 @@ describe API::Notes do it 'returns 403 status' do subject - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not create a new note' do @@ -352,7 +352,7 @@ describe API::Notes do put api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -360,14 +360,14 @@ describe API::Notes do put api("/projects/#{project.id}/issues/#{issue.iid}/notes/12345", user), body: 'Hello!' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 bad request error if body not given' do put api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -376,7 +376,7 @@ describe API::Notes do put api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -384,7 +384,7 @@ describe API::Notes do put api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -393,7 +393,7 @@ describe API::Notes do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/"\ "notes/#{merge_request_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -401,7 +401,7 @@ describe API::Notes do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -412,17 +412,17 @@ describe API::Notes do delete api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) # Check if note is really deleted delete api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/issues/#{issue.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -435,18 +435,18 @@ describe API::Notes do delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) # Check if note is really deleted delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -459,18 +459,18 @@ describe API::Notes do delete api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.iid}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) # Check if note is really deleted delete api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.iid}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do diff --git a/spec/requests/api/notification_settings_spec.rb b/spec/requests/api/notification_settings_spec.rb index 7968659a1ec..3273cd26690 100644 --- a/spec/requests/api/notification_settings_spec.rb +++ b/spec/requests/api/notification_settings_spec.rb @@ -9,7 +9,7 @@ describe API::NotificationSettings do it "returns global notification settings for the current user" do get api("/notification_settings", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['notification_email']).to eq(user.notification_email) expect(json_response['level']).to eq(user.global_notification_setting.level) @@ -22,7 +22,7 @@ describe API::NotificationSettings do it "updates global notification settings for the current user" do put api("/notification_settings", user), { level: 'watch', notification_email: email.email } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['notification_email']).to eq(email.email) expect(user.reload.notification_email).to eq(email.email) expect(json_response['level']).to eq(user.reload.global_notification_setting.level) @@ -33,7 +33,7 @@ describe API::NotificationSettings do it "fails on non-user email address" do put api("/notification_settings", user), { notification_email: 'invalid@example.com' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -41,7 +41,7 @@ describe API::NotificationSettings do it "returns group level notification settings for the current user" do get api("/groups/#{group.id}/notification_settings", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['level']).to eq(user.notification_settings_for(group).level) end @@ -51,7 +51,7 @@ describe API::NotificationSettings do it "updates group level notification settings for the current user" do put api("/groups/#{group.id}/notification_settings", user), { level: 'watch' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['level']).to eq(user.reload.notification_settings_for(group).level) end end @@ -60,7 +60,7 @@ describe API::NotificationSettings do it "returns project level notification settings for the current user" do get api("/projects/#{project.id}/notification_settings", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['level']).to eq(user.notification_settings_for(project).level) end @@ -70,7 +70,7 @@ describe API::NotificationSettings do it "updates project level notification settings for the current user" do put api("/projects/#{project.id}/notification_settings", user), { level: 'custom', new_note: true } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['level']).to eq(user.reload.notification_settings_for(project).level) expect(json_response['events']['new_note']).to be_truthy expect(json_response['events']['new_issue']).to be_falsey @@ -81,7 +81,7 @@ describe API::NotificationSettings do it "fails on invalid level" do put api("/projects/#{project.id}/notification_settings", user), { level: 'invalid' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end diff --git a/spec/requests/api/oauth_tokens_spec.rb b/spec/requests/api/oauth_tokens_spec.rb index 0d56e1f732e..bdda80cc229 100644 --- a/spec/requests/api/oauth_tokens_spec.rb +++ b/spec/requests/api/oauth_tokens_spec.rb @@ -12,7 +12,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['error']).to eq('invalid_grant') end end @@ -23,7 +23,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['access_token']).not_to be_nil end end @@ -35,7 +35,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -46,7 +46,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/pages_domains_spec.rb b/spec/requests/api/pages_domains_spec.rb new file mode 100644 index 00000000000..d13b3a958c9 --- /dev/null +++ b/spec/requests/api/pages_domains_spec.rb @@ -0,0 +1,440 @@ +require 'rails_helper' + +describe API::PagesDomains do + set(:project) { create(:project) } + set(:user) { create(:user) } + + set(:pages_domain) { create(:pages_domain, domain: 'www.domain.test', project: project) } + set(:pages_domain_secure) { create(:pages_domain, :with_certificate, :with_key, domain: 'ssl.domain.test', project: project) } + set(:pages_domain_expired) { create(:pages_domain, :with_expired_certificate, :with_key, domain: 'expired.domain.test', project: project) } + + let(:pages_domain_params) { build(:pages_domain, domain: 'www.other-domain.test').slice(:domain) } + let(:pages_domain_secure_params) { build(:pages_domain, :with_certificate, :with_key, domain: 'ssl.other-domain.test', project: project).slice(:domain, :certificate, :key) } + let(:pages_domain_secure_key_missmatch_params) {build(:pages_domain, :with_trusted_chain, :with_key, project: project).slice(:domain, :certificate, :key) } + let(:pages_domain_secure_missing_chain_params) {build(:pages_domain, :with_missing_chain, project: project).slice(:certificate) } + + let(:route) { "/projects/#{project.id}/pages/domains" } + let(:route_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain.domain}" } + let(:route_secure_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain_secure.domain}" } + let(:route_expired_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain_expired.domain}" } + let(:route_vacant_domain) { "/projects/#{project.id}/pages/domains/www.vacant-domain.test" } + + before do + allow(Gitlab.config.pages).to receive(:enabled).and_return(true) + end + + describe 'GET /projects/:project_id/pages/domains' do + shared_examples_for 'get pages domains' do + it 'returns paginated pages domains' do + get api(route, user) + + 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(3) + expect(json_response.map { |pages_domain| pages_domain['domain'] }).to include(pages_domain.domain) + expect(json_response.last).to have_key('domain') + end + end + + context 'when pages is disabled' do + before do + allow(Gitlab.config.pages).to receive(:enabled).and_return(false) + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'get pages domains' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { get api(route, user) } + end + end + end + + describe 'GET /projects/:project_id/pages/domains/:domain' do + shared_examples_for 'get pages domain' do + it 'returns pages domain' do + get api(route_domain, user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['domain']).to eq(pages_domain.domain) + expect(json_response['url']).to eq(pages_domain.url) + expect(json_response['certificate']).to be_nil + end + + it 'returns pages domain with a certificate' do + get api(route_secure_domain, user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['domain']).to eq(pages_domain_secure.domain) + expect(json_response['url']).to eq(pages_domain_secure.url) + expect(json_response['certificate']['subject']).to eq(pages_domain_secure.subject) + expect(json_response['certificate']['expired']).to be false + end + + it 'returns pages domain with an expired certificate' do + get api(route_expired_domain, user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['certificate']['expired']).to be true + end + end + + context 'when domain is vacant' do + before do + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { get api(route_vacant_domain, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'get pages domain' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { get api(route, user) } + end + end + end + + describe 'POST /projects/:project_id/pages/domains' do + let(:params) { pages_domain_params.slice(:domain) } + let(:params_secure) { pages_domain_secure_params.slice(:domain, :certificate, :key) } + + shared_examples_for 'post pages domains' do + it 'creates a new pages domain' do + post api(route, user), params + pages_domain = PagesDomain.find_by(domain: json_response['domain']) + + expect(response).to have_gitlab_http_status(201) + expect(pages_domain.domain).to eq(params[:domain]) + expect(pages_domain.certificate).to be_nil + expect(pages_domain.key).to be_nil + end + + it 'creates a new secure pages domain' do + post api(route, user), params_secure + pages_domain = PagesDomain.find_by(domain: json_response['domain']) + + expect(response).to have_gitlab_http_status(201) + expect(pages_domain.domain).to eq(params_secure[:domain]) + expect(pages_domain.certificate).to eq(params_secure[:certificate]) + expect(pages_domain.key).to eq(params_secure[:key]) + end + + it 'fails to create pages domain without key' do + post api(route, user), pages_domain_secure_params.slice(:domain, :certificate) + + expect(response).to have_gitlab_http_status(400) + end + + it 'fails to create pages domain with key missmatch' do + post api(route, user), pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key) + + expect(response).to have_gitlab_http_status(400) + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'post pages domains' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { post api(route, user), params } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { post api(route, user), params } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { post api(route, user), params } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { post api(route, user), params } + end + end + end + + describe 'PUT /projects/:project_id/pages/domains/:domain' do + let(:params_secure) { pages_domain_secure_params.slice(:certificate, :key) } + let(:params_secure_nokey) { pages_domain_secure_params.slice(:certificate) } + + shared_examples_for 'put pages domain' do + it 'updates pages domain removing certificate' do + put api(route_secure_domain, user) + pages_domain_secure.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain_secure.certificate).to be_nil + expect(pages_domain_secure.key).to be_nil + end + + it 'updates pages domain adding certificate' do + put api(route_domain, user), params_secure + pages_domain.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain.certificate).to eq(params_secure[:certificate]) + expect(pages_domain.key).to eq(params_secure[:key]) + end + + it 'updates pages domain with expired certificate' do + put api(route_expired_domain, user), params_secure + pages_domain_expired.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain_expired.certificate).to eq(params_secure[:certificate]) + expect(pages_domain_expired.key).to eq(params_secure[:key]) + end + + it 'updates pages domain with expired certificate not updating key' do + put api(route_secure_domain, user), params_secure_nokey + pages_domain_secure.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate]) + end + + it 'fails to update pages domain adding certificate without key' do + put api(route_domain, user), params_secure_nokey + + expect(response).to have_gitlab_http_status(400) + end + + it 'fails to update pages domain adding certificate with missing chain' do + put api(route_domain, user), pages_domain_secure_missing_chain_params.slice(:certificate) + + expect(response).to have_gitlab_http_status(400) + end + + it 'fails to update pages domain with key missmatch' do + put api(route_secure_domain, user), pages_domain_secure_key_missmatch_params.slice(:certificate, :key) + + expect(response).to have_gitlab_http_status(400) + end + end + + context 'when domain is vacant' do + before do + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { put api(route_vacant_domain, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'put pages domain' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { put api(route_domain, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { put api(route_domain, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { put api(route_domain, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { put api(route_domain, user) } + end + end + end + + describe 'DELETE /projects/:project_id/pages/domains/:domain' do + shared_examples_for 'delete pages domain' do + it 'deletes a pages domain' do + delete api(route_domain, user) + + expect(response).to have_gitlab_http_status(204) + end + end + + context 'when domain is vacant' do + before do + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { delete api(route_vacant_domain, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'delete pages domain' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { delete api(route_domain, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { delete api(route_domain, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { delete api(route_domain, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { delete api(route_domain, user) } + end + end + end +end diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index f650df57383..7ea25059756 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -20,7 +20,7 @@ describe API::PipelineSchedules do it 'returns list of pipeline_schedules' do get api("/projects/#{project.id}/pipeline_schedules", developer) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(response).to match_response_schema('pipeline_schedules') end @@ -67,7 +67,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -75,7 +75,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -91,14 +91,14 @@ describe API::PipelineSchedules do it 'returns pipeline_schedule details' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule') end it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do get api("/projects/#{project.id}/pipeline_schedules/-5", developer) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -106,7 +106,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -118,7 +118,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -126,7 +126,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -142,7 +142,7 @@ describe API::PipelineSchedules do params end.to change { project.pipeline_schedules.count }.by(1) - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('pipeline_schedule') expect(json_response['description']).to eq(params[:description]) expect(json_response['ref']).to eq(params[:ref]) @@ -156,7 +156,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule' do post api("/projects/#{project.id}/pipeline_schedules", developer) - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -165,7 +165,7 @@ describe API::PipelineSchedules do post api("/projects/#{project.id}/pipeline_schedules", developer), params.merge('cron' => 'invalid-cron') - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('cron') end end @@ -175,7 +175,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule' do post api("/projects/#{project.id}/pipeline_schedules", user), params - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -183,7 +183,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule' do post api("/projects/#{project.id}/pipeline_schedules"), params - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -198,7 +198,7 @@ describe API::PipelineSchedules do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer), cron: '1 2 3 4 *' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule') expect(json_response['cron']).to eq('1 2 3 4 *') end @@ -208,7 +208,7 @@ describe API::PipelineSchedules do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer), cron: 'invalid-cron' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('cron') end end @@ -218,7 +218,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -226,7 +226,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -240,7 +240,7 @@ describe API::PipelineSchedules do it 'updates owner' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership", developer) - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('pipeline_schedule') end end @@ -249,7 +249,7 @@ describe API::PipelineSchedules do it 'does not update owner' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -257,7 +257,7 @@ describe API::PipelineSchedules do it 'does not update owner' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -279,13 +279,13 @@ describe API::PipelineSchedules do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", master) end.to change { project.pipeline_schedules.count }.by(-1) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do delete api("/projects/#{project.id}/pipeline_schedules/-5", master) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end it_behaves_like '412 response' do @@ -299,7 +299,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer) - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -307,7 +307,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -327,7 +327,7 @@ describe API::PipelineSchedules do params end.to change { pipeline_schedule.variables.count }.by(1) - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('pipeline_schedule_variable') expect(json_response['key']).to eq(params[:key]) expect(json_response['value']).to eq(params[:value]) @@ -338,7 +338,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule_variable' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer) - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -347,7 +347,7 @@ describe API::PipelineSchedules do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer), params.merge('key' => '!?!?') - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('key') end end @@ -357,7 +357,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule_variable' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", user), params - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -365,7 +365,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule_variable' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables"), params - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -384,7 +384,7 @@ describe API::PipelineSchedules do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", developer), value: 'updated_value' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule_variable') expect(json_response['value']).to eq('updated_value') end @@ -394,7 +394,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule_variable' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -402,7 +402,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule_variable' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -428,14 +428,14 @@ describe API::PipelineSchedules do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", master) end.to change { Ci::PipelineScheduleVariable.count }.by(-1) - expect(response).to have_http_status(:accepted) + expect(response).to have_gitlab_http_status(:accepted) expect(response).to match_response_schema('pipeline_schedule_variable') end it 'responds with 404 Not Found if requesting non-existing pipeline_schedule_variable' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/____", master) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -445,7 +445,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule_variable' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", developer) - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -453,7 +453,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule_variable' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 258085e503f..e4dcc9252fa 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -19,7 +19,7 @@ describe API::Pipelines do it 'returns project pipelines' do get api("/projects/#{project.id}/pipelines", 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['sha']).to match /\A\h{40}\z/ @@ -37,7 +37,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: target - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['status']).to eq(target) } @@ -55,7 +55,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: 'finished' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['status']).to be_in(%w[success failed canceled]) } @@ -70,7 +70,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: 'branches' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty expect(json_response.last['id']).to eq(pipeline_branch.id) @@ -81,7 +81,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: 'tags' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty expect(json_response.last['id']).to eq(pipeline_tag.id) @@ -93,7 +93,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), scope: 'invalid-scope' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -108,7 +108,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), status: target - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['status']).to eq(target) } @@ -120,7 +120,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), status: 'invalid-status' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -133,7 +133,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), ref: 'master' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['ref']).to eq('master') } @@ -144,7 +144,7 @@ describe API::Pipelines do it 'returns empty' do get api("/projects/#{project.id}/pipelines", user), ref: 'invalid-ref' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_empty end @@ -158,7 +158,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), name: user.name - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline.id) end @@ -168,7 +168,7 @@ describe API::Pipelines do it 'returns empty' do get api("/projects/#{project.id}/pipelines", user), name: 'invalid-name' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_empty end @@ -182,7 +182,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), username: user.username - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline.id) end @@ -192,7 +192,7 @@ describe API::Pipelines do it 'returns empty' do get api("/projects/#{project.id}/pipelines", user), username: 'invalid-username' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_empty end @@ -207,7 +207,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), yaml_errors: true - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline1.id) end @@ -217,7 +217,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), yaml_errors: false - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline2.id) end @@ -227,7 +227,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), yaml_errors: 'invalid-yaml_errors' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -244,7 +244,7 @@ describe API::Pipelines do it 'sorts as user_id: :desc' do get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'desc' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty @@ -257,7 +257,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'invalid_sort' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -266,7 +266,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), order_by: 'lock_version', sort: 'asc' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -277,7 +277,7 @@ describe API::Pipelines do it 'does not return project pipelines' do get api("/projects/#{project.id}/pipelines", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -296,7 +296,7 @@ describe API::Pipelines do post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch end.to change { Ci::Pipeline.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to be_a Hash expect(json_response['sha']).to eq project.commit.id end @@ -304,7 +304,7 @@ describe API::Pipelines do it 'fails when using an invalid ref' do post api("/projects/#{project.id}/pipeline", user), ref: 'invalid_ref' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Reference not found' expect(json_response).not_to be_an Array end @@ -314,7 +314,7 @@ describe API::Pipelines do it 'fails to create pipeline' do post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Missing .gitlab-ci.yml file' expect(json_response).not_to be_an Array end @@ -325,7 +325,7 @@ describe API::Pipelines do it 'does not create pipeline' do post api("/projects/#{project.id}/pipeline", non_member), ref: project.default_branch - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -337,14 +337,14 @@ describe API::Pipelines do it 'returns project pipelines' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ end it 'returns 404 when it does not exist' do get api("/projects/#{project.id}/pipelines/123456", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Not found' expect(json_response['id']).to be nil end @@ -366,7 +366,7 @@ describe API::Pipelines do it 'should not return a project pipeline' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -387,7 +387,7 @@ describe API::Pipelines do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user) end.to change { pipeline.builds.count }.from(1).to(2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(build.reload.retried?).to be true end end @@ -396,7 +396,7 @@ describe API::Pipelines do it 'should not return a project pipeline' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -415,7 +415,7 @@ describe API::Pipelines do it 'retries failed builds' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('canceled') end end @@ -430,7 +430,7 @@ describe API::Pipelines do it 'rejects the action' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(pipeline.reload.status).to eq('pending') end end diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb index ac3bab09c4c..f31344a6238 100644 --- a/spec/requests/api/project_hooks_spec.rb +++ b/spec/requests/api/project_hooks_spec.rb @@ -22,7 +22,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns project hooks" do get api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response).to include_pagination_headers expect(json_response.count).to eq(1) @@ -43,7 +43,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "does not access project hooks" do get api("/projects/#{project.id}/hooks", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -53,7 +53,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a project hook" do get api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq(hook.url) expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(hook.push_events) @@ -69,20 +69,20 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 404 error if hook id is not available" do get api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context "unauthorized user" do it "does not access an existing hook" do get api("/projects/#{project.id}/hooks/#{hook.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it "returns a 404 error if hook id is not available" do get api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -94,7 +94,7 @@ describe API::ProjectHooks, 'ProjectHooks' do job_events: true end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['url']).to eq('http://example.com') expect(json_response['issues_events']).to eq(true) expect(json_response['push_events']).to eq(true) @@ -115,7 +115,7 @@ describe API::ProjectHooks, 'ProjectHooks' do post api("/projects/#{project.id}/hooks", user), url: "http://example.com", token: token end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["url"]).to eq("http://example.com") expect(json_response).not_to include("token") @@ -127,12 +127,12 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 400 error if url not given" do post api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url not valid" do post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com" - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -141,7 +141,7 @@ describe API::ProjectHooks, 'ProjectHooks' do put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'http://example.org', push_events: false, job_events: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq('http://example.org') expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(false) @@ -159,7 +159,7 @@ describe API::ProjectHooks, 'ProjectHooks' do put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: "http://example.org", token: token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["url"]).to eq("http://example.org") expect(json_response).not_to include("token") @@ -169,17 +169,17 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns 404 error if hook id not found" do put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 400 error if url is not given" do put api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url is not valid" do put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -188,19 +188,19 @@ describe API::ProjectHooks, 'ProjectHooks' do expect do delete api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {project.hooks.count}.by(-1) end it "returns a 404 error when deleting non existent hook" do delete api("/projects/#{project.id}/hooks/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 error if hook id not given" do delete api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 if a user attempts to delete project hooks he/she does not own" do @@ -209,7 +209,7 @@ describe API::ProjectHooks, 'ProjectHooks' do other_project.team << [test_user, :master] delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(WebHook.exists?(hook.id)).to be_truthy end diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index db34149eb73..e741ac4b7bd 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -12,7 +12,7 @@ describe API::ProjectSnippets do it 'exposes known attributes' do get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -21,7 +21,7 @@ describe API::ProjectSnippets do it "returns unautorized for non-admin users" do get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -36,7 +36,7 @@ describe API::ProjectSnippets do get api("/projects/#{project.id}/snippets", 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(3) @@ -49,7 +49,7 @@ describe API::ProjectSnippets do get api("/projects/#{project.id}/snippets/", 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(0) @@ -63,7 +63,7 @@ describe API::ProjectSnippets do it 'returns snippet json' do get api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) expect(json_response['description']).to eq(snippet.description) @@ -73,7 +73,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do get api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -92,7 +92,7 @@ describe API::ProjectSnippets do it 'creates a new snippet' do post api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) snippet = ProjectSnippet.find(json_response['id']) expect(snippet.content).to eq(params[:code]) expect(snippet.description).to eq(params[:description]) @@ -106,7 +106,7 @@ describe API::ProjectSnippets do post api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -132,7 +132,7 @@ describe API::ProjectSnippets do expect { create_snippet(project, visibility: 'public') } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -154,7 +154,7 @@ describe API::ProjectSnippets do put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content, description: new_description - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) snippet.reload expect(snippet.content).to eq(new_content) expect(snippet.description).to eq(new_description) @@ -163,14 +163,14 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do put api("/projects/#{snippet.project.id}/snippets/1234", admin), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put api("/projects/#{project.id}/snippets/1234", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -212,7 +212,7 @@ describe API::ProjectSnippets do expect { update_snippet(title: 'Foo', visibility: 'public') } .not_to change { snippet.reload.title } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -230,13 +230,13 @@ describe API::ProjectSnippets do it 'deletes snippet' do delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'returns 404 for invalid snippet id' do delete api("/projects/#{snippet.project.id}/snippets/1234", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end @@ -251,7 +251,7 @@ describe API::ProjectSnippets do it 'returns raw text' do get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -259,7 +259,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 5964244f8c5..e095ba2af5d 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -45,7 +45,7 @@ describe API::Projects do it 'returns an array of projects' do get api('/projects', current_user), filter - 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.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id)) @@ -147,7 +147,7 @@ describe API::Projects do it "does not include statistics by default" do get api('/projects', 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).not_to include('statistics') @@ -156,7 +156,7 @@ describe API::Projects do it "includes statistics if requested" do get api('/projects', user), statistics: true - 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).to include 'statistics' @@ -201,7 +201,7 @@ describe API::Projects do get api('/projects?simple=true', 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.keys).to match_array expected_keys @@ -228,7 +228,7 @@ describe API::Projects do it 'filters based on private visibility param' do get api('/projects', user), { visibility: 'private' } - 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.map { |p| p['id'] }).to contain_exactly(project.id, project2.id, project3.id) @@ -239,7 +239,7 @@ describe API::Projects do get api('/projects', user), { visibility: 'internal' } - 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.map { |p| p['id'] }).to contain_exactly(project2.id) @@ -248,7 +248,7 @@ describe API::Projects do it 'filters based on public visibility param' do get api('/projects', user), { visibility: 'public' } - 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.map { |p| p['id'] }).to contain_exactly(public_project.id) @@ -259,7 +259,7 @@ describe API::Projects do it 'returns the correct order when sorted by id' do get api('/projects', user), { order_by: 'id', sort: 'desc' } - 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['id']).to eq(project3.id) @@ -270,7 +270,7 @@ describe API::Projects do it 'returns an array of projects the user owns' do get api('/projects', user4), owned: true - 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['name']).to eq(project4.name) @@ -289,7 +289,7 @@ describe API::Projects do it 'returns the starred projects viewable by the user' do get api('/projects', user3), starred: true - 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.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id) @@ -311,7 +311,7 @@ describe API::Projects do it 'returns only projects that satisfy all query parameters' do get api('/projects', user), { visibility: 'public', owned: true, starred: true, search: 'gitlab' } - 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) @@ -330,7 +330,7 @@ describe API::Projects do it 'returns only projects that satisfy all query parameters' do get api('/projects', user), { visibility: 'public', membership: true, starred: true, search: 'gitlab' } - 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) @@ -363,14 +363,14 @@ describe API::Projects do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) expect { post api('/projects', user2), name: 'foo' } .to change {Project.count}.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'creates new project without path but with name and returns 201' do expect { post api('/projects', user), name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -381,7 +381,7 @@ describe API::Projects do it 'creates new project without name but with path and returns 201' do expect { post api('/projects', user), path: 'foo_project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -392,7 +392,7 @@ describe API::Projects do it 'creates new project with name and path and returns 201' do expect { post api('/projects', user), path: 'path-project-Foo', name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -403,12 +403,12 @@ describe API::Projects do it 'creates last project before reaching project limit' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) post api('/projects', user2), name: 'foo' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'does not create new project without name or path and returns 400' do expect { post api('/projects', user) }.not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "assigns attributes to project" do @@ -427,7 +427,7 @@ describe API::Projects do post api('/projects', user), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled].include?(k) @@ -543,7 +543,7 @@ describe API::Projects do post api('/projects', user), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when a visibility level is restricted' do @@ -556,7 +556,7 @@ describe API::Projects do it 'does not allow a non-admin to use a restricted visibility level' do post api('/projects', user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['visibility_level'].first).to( match('restricted by your GitLab administrator') ) @@ -576,14 +576,14 @@ describe API::Projects do it 'returns error when user not found' do get api('/users/9999/projects/') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns projects filtered by user' do get api("/users/#{user4.id}/projects/", 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.map { |project| project['id'] }).to contain_exactly(public_project.id) @@ -597,7 +597,7 @@ describe API::Projects do it 'creates new project without path but with name and return 201' do expect { post api("/projects/user/#{user.id}", admin), name: 'Foo Project' }.to change {Project.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.last @@ -608,7 +608,7 @@ describe API::Projects do it 'creates new project with name and path and returns 201' do expect { post api("/projects/user/#{user.id}", admin), path: 'path-project-Foo', name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.last @@ -620,7 +620,7 @@ describe API::Projects do expect { post api("/projects/user/#{user.id}", admin) } .not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end @@ -634,7 +634,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| next if %i[has_external_issue_tracker path].include?(k) expect(json_response[k.to_s]).to eq(v) @@ -646,7 +646,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['visibility']).to eq('public') end @@ -655,7 +655,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['visibility']).to eq('internal') end @@ -720,7 +720,7 @@ describe API::Projects do it "uploads the file and returns its info" do post api("/projects/#{project.id}/uploads", user), file: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['alt']).to eq("dk") expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to end_with("/dk.png") @@ -734,7 +734,7 @@ describe API::Projects do get api("/projects/#{public_project.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(public_project.id) expect(json_response['description']).to eq(public_project.description) expect(json_response['default_branch']).to eq(public_project.default_branch) @@ -754,7 +754,7 @@ describe API::Projects do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) @@ -798,20 +798,20 @@ describe API::Projects do it 'returns a project by path name' do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'returns a 404 error if not found' do get api('/projects/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'returns a 404 error if user is not a member' do other_user = create(:user) get api("/projects/#{project.id}", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'handles users with dots' do @@ -819,14 +819,14 @@ describe API::Projects do project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) get api("/projects/#{CGI.escape(project.full_path)}", dot_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'exposes namespace fields' do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['namespace']).to eq({ 'id' => user.namespace.id, 'name' => user.namespace.name, @@ -840,28 +840,28 @@ describe API::Projects do it "does not include statistics by default" do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to include 'statistics' end it "includes statistics if requested" do get api("/projects/#{project.id}", user), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include 'statistics' end it "includes import_error if user can admin project" do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include("import_error") end it "does not include import_error if user cannot admin project" do get api("/projects/#{project.id}", user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to include("import_error") end @@ -906,7 +906,7 @@ describe API::Projects do it 'contains permission information' do get api("/projects", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.first['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil @@ -918,7 +918,7 @@ describe API::Projects do project.team << [user, :master] get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil @@ -935,7 +935,7 @@ describe API::Projects do it 'sets the owner and return 200' do get api("/projects/#{project2.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -952,7 +952,7 @@ describe API::Projects do user = project.namespace.owner - 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) @@ -981,7 +981,7 @@ describe API::Projects do it 'returns a 404 error if not found' do get api('/projects/42/users', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -990,7 +990,7 @@ describe API::Projects do get api("/projects/#{project.id}/users", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1003,7 +1003,7 @@ describe API::Projects do it 'returns an array of project snippets' do get api("/projects/#{project.id}/snippets", 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(snippet.title) @@ -1013,13 +1013,13 @@ describe API::Projects do describe 'GET /projects/:id/snippets/:snippet_id' do it 'returns a project snippet' do get api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) end it 'returns a 404 error if snippet id not found' do get api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1027,7 +1027,7 @@ describe API::Projects do it 'creates a new project snippet' do post api("/projects/#{project.id}/snippets", user), title: 'api test', file_name: 'sample.rb', code: 'test', visibility: 'private' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('api test') end @@ -1041,7 +1041,7 @@ describe API::Projects do it 'updates an existing project snippet' do put api("/projects/#{project.id}/snippets/#{snippet.id}", user), code: 'updated code' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('example') expect(snippet.reload.content).to eq('updated code') end @@ -1049,7 +1049,7 @@ describe API::Projects do it 'updates an existing project snippet with new title' do put api("/projects/#{project.id}/snippets/#{snippet.id}", user), title: 'other api test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('other api test') end end @@ -1063,13 +1063,13 @@ describe API::Projects do expect do delete api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Snippet.count }.by(-1) end it 'returns 404 when deleting unknown snippet id' do delete api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -1080,12 +1080,12 @@ describe API::Projects do describe 'GET /projects/:id/snippets/:snippet_id/raw' do it 'gets a raw project snippet' do get api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 404 error if raw project snippet not found' do get api("/projects/#{project.id}/snippets/5555/raw", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1098,13 +1098,13 @@ describe API::Projects do it "is not available for non admin users" do post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'allows project to be forked from an existing project' do expect(project_fork_target.forked?).not_to be_truthy post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked_project_link).not_to be_nil @@ -1121,7 +1121,7 @@ describe API::Projects do it 'fails if forked_from project which does not exist' do post api("/projects/#{project_fork_target.id}/fork/9999", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'fails with 409 if already forked' do @@ -1129,7 +1129,7 @@ describe API::Projects do project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) post api("/projects/#{project_fork_target.id}/fork/#{new_project_fork_source.id}", admin) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked?).to be_truthy @@ -1139,7 +1139,7 @@ describe API::Projects do describe 'DELETE /projects/:id/fork' do it "is not visible to users outside group" do delete api("/projects/#{project_fork_target.id}/fork", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'when users belong to project group' do @@ -1161,7 +1161,7 @@ describe API::Projects do it 'makes forked project unforked' do delete api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) project_fork_target.reload expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target.forked?).not_to be_truthy @@ -1174,13 +1174,13 @@ describe API::Projects do it 'is forbidden to non-owner users' do delete api("/projects/#{project_fork_target.id}/fork", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'is idempotent if not forked' do expect(project_fork_target.forked_from_project).to be_nil delete api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) expect(project_fork_target.reload.forked_from_project).to be_nil end end @@ -1210,7 +1210,7 @@ describe API::Projects do it 'returns the forks' do get api("/projects/#{project_fork_source.id}/forks", 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.length).to eq(1) expect(json_response[0]['name']).to eq(private_fork.name) @@ -1221,7 +1221,7 @@ describe API::Projects do it 'returns an empty array' do get api("/projects/#{project_fork_source.id}/forks", non_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.length).to eq(0) end @@ -1232,7 +1232,7 @@ describe API::Projects do it 'returns an empty array' do get api("/projects/#{project_fork_source.id}/forks") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(0) end @@ -1250,7 +1250,7 @@ describe API::Projects do post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at end.to change { ProjectGroupLink.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['group_id']).to eq(group.id) expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['expires_at']).to eq(expires_at.to_s) @@ -1258,18 +1258,18 @@ describe API::Projects do it "returns a 400 error when group id is not given" do post api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when access level is not given" do post api("/projects/#{project.id}/share", user), group_id: group.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when sharing is disabled" do project.namespace.update(share_with_group_lock: true) post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when user cannot read group' do @@ -1277,19 +1277,19 @@ describe API::Projects do post api("/projects/#{project.id}/share", user), group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when group does not exist' do post api("/projects/#{project.id}/share", user), group_id: 1234, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 400 error when wrong params passed" do post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'group_access does not have a valid value' end end @@ -1305,7 +1305,7 @@ describe API::Projects do it 'returns 204 when deleting a group share' do delete api("/projects/#{project.id}/share/#{group.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(project.project_group_links).to be_empty end @@ -1317,19 +1317,19 @@ describe API::Projects do it 'returns a 400 when group id is not an integer' do delete api("/projects/#{project.id}/share/foo", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when group link does not exist' do delete api("/projects/#{project.id}/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when project does not exist' do delete api("/projects/123/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1350,7 +1350,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to match('at least one parameter must be provided') end @@ -1360,7 +1360,7 @@ describe API::Projects do put api("/projects/#{project.id}"), project_param - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1370,7 +1370,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1382,7 +1382,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1395,7 +1395,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1409,7 +1409,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['name']).to eq(['has already been taken']) end @@ -1418,7 +1418,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['request_access_enabled']).to eq(false) end @@ -1427,7 +1427,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1439,7 +1439,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1451,7 +1451,7 @@ describe API::Projects do it 'updates path' do project_param = { path: 'bar' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1465,7 +1465,7 @@ describe API::Projects do description: 'new description' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1474,20 +1474,20 @@ describe API::Projects do it 'does not update path to existing path' do project_param = { path: project.path } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['path']).to eq(['has already been taken']) end it 'does not update name' do project_param = { name: 'bar' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not update visibility_level' do project_param = { visibility: 'public' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1501,7 +1501,7 @@ describe API::Projects do description: 'new description', request_access_enabled: true } put api("/projects/#{project.id}", user3), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1511,7 +1511,7 @@ describe API::Projects do it 'archives the project' do post api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1524,7 +1524,7 @@ describe API::Projects do it 'remains archived' do post api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1537,7 +1537,7 @@ describe API::Projects do it 'rejects the action' do post api("/projects/#{project.id}/archive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1547,7 +1547,7 @@ describe API::Projects do it 'remains unarchived' do post api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1560,7 +1560,7 @@ describe API::Projects do it 'unarchives the project' do post api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1573,7 +1573,7 @@ describe API::Projects do it 'rejects the action' do post api("/projects/#{project.id}/unarchive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1583,7 +1583,7 @@ describe API::Projects do it 'stars the project' do expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['star_count']).to eq(1) end end @@ -1597,7 +1597,7 @@ describe API::Projects do it 'does not modify the star count' do expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1612,7 +1612,7 @@ describe API::Projects do it 'unstars the project' do expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['star_count']).to eq(0) end end @@ -1621,7 +1621,7 @@ describe API::Projects do it 'does not modify the star count' do expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1631,7 +1631,7 @@ describe API::Projects do it 'removes project' do delete api("/projects/#{project.id}", user) - expect(response).to have_http_status(202) + expect(response).to have_gitlab_http_status(202) expect(json_response['message']).to eql('202 Accepted') end @@ -1644,17 +1644,17 @@ describe API::Projects do user3 = create(:user) project.team << [user3, :developer] delete api("/projects/#{project.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not remove a non existing project' do delete api('/projects/1328', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not remove a project not attached to user' do delete api("/projects/#{project.id}", user2) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1662,13 +1662,13 @@ describe API::Projects do it 'removes any existing project' do delete api("/projects/#{project.id}", admin) - expect(response).to have_http_status(202) + expect(response).to have_gitlab_http_status(202) expect(json_response['message']).to eql('202 Accepted') end it 'does not remove a non existing project' do delete api('/projects/1328', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -1697,7 +1697,7 @@ describe API::Projects do it 'forks if user has sufficient access to project' do post api("/projects/#{project.id}/fork", user2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(project.name) expect(json_response['path']).to eq(project.path) expect(json_response['owner']['id']).to eq(user2.id) @@ -1710,7 +1710,7 @@ describe API::Projects do it 'forks if user is admin' do post api("/projects/#{project.id}/fork", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(project.name) expect(json_response['path']).to eq(project.path) expect(json_response['owner']['id']).to eq(admin.id) @@ -1724,14 +1724,14 @@ describe API::Projects do new_user = create(:user) post api("/projects/#{project.id}/fork", new_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'fails if forked project exists in the user namespace' do post api("/projects/#{project.id}/fork", user) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']['name']).to eq(['has already been taken']) expect(json_response['message']['path']).to eq(['has already been taken']) end @@ -1739,61 +1739,61 @@ describe API::Projects do it 'fails if project to fork from does not exist' do post api('/projects/424242/fork', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'forks with explicit own user namespace id' do post api("/projects/#{project.id}/fork", user2), namespace: user2.namespace.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'forks with explicit own user name as namespace' do post api("/projects/#{project.id}/fork", user2), namespace: user2.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'forks to another user when admin' do post api("/projects/#{project.id}/fork", admin), namespace: user2.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'fails if trying to fork to another user when not admin' do post api("/projects/#{project.id}/fork", user2), namespace: admin.namespace.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'fails if trying to fork to non-existent namespace' do post api("/projects/#{project.id}/fork", user2), namespace: 42424242 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Target Namespace Not Found') end it 'forks to owned group' do post api("/projects/#{project.id}/fork", user2), namespace: group2.name - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['namespace']['name']).to eq(group2.name) end it 'fails to fork to not owned group' do post api("/projects/#{project.id}/fork", user2), namespace: group.name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'forks to not owned group when admin' do post api("/projects/#{project.id}/fork", admin), namespace: group.name - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['namespace']['name']).to eq(group.name) end end @@ -1802,7 +1802,7 @@ describe API::Projects do it 'returns authentication error' do post api("/projects/#{project.id}/fork") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['message']).to eq('401 Unauthorized') end end @@ -1821,7 +1821,7 @@ describe API::Projects do post api("/projects/#{project.id}/housekeeping", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when housekeeping lease is taken' do @@ -1830,7 +1830,7 @@ describe API::Projects do post api("/projects/#{project.id}/housekeeping", user) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to match(/Somebody already triggered housekeeping for this project/) end end @@ -1844,7 +1844,7 @@ describe API::Projects do it 'returns forbidden error' do post api("/projects/#{project.id}/housekeeping", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1852,7 +1852,7 @@ describe API::Projects do it 'returns authentication error' do post api("/projects/#{project.id}/housekeeping") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index 1a0695615e3..9f2ff3b5af6 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -17,7 +17,7 @@ describe API::Repositories do it 'returns the repository tree' do get api(route, current_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 @@ -106,7 +106,7 @@ describe API::Repositories do it 'returns blob attributes as json' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['size']).to eq(111) expect(json_response['encoding']).to eq("base64") expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n") @@ -165,7 +165,7 @@ describe API::Repositories do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when sha does not exist' do @@ -218,7 +218,7 @@ describe API::Repositories do it 'returns the repository archive' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data @@ -230,7 +230,7 @@ describe API::Repositories do it 'returns the repository archive archive.zip' do get api("/projects/#{project.id}/repository/archive.zip", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data @@ -242,7 +242,7 @@ describe API::Repositories do it 'returns the repository archive archive.tar.bz2' do get api("/projects/#{project.id}/repository/archive.tar.bz2", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data @@ -293,7 +293,7 @@ describe API::Repositories do it "compares branches" do get api(route, current_user), from: 'master', to: 'feature' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -301,7 +301,7 @@ describe API::Repositories do it "compares tags" do get api(route, current_user), from: 'v1.0.0', to: 'v1.1.0' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -309,7 +309,7 @@ describe API::Repositories do it "compares commits" do get api(route, current_user), from: sample_commit.id, to: sample_commit.parent_id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_falsey @@ -318,7 +318,7 @@ describe API::Repositories do it "compares commits in reverse order" do get api(route, current_user), from: sample_commit.parent_id, to: sample_commit.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -326,7 +326,7 @@ describe API::Repositories do it "compares same refs" do get api(route, current_user), from: 'master', to: 'master' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_truthy @@ -367,7 +367,7 @@ describe API::Repositories do it 'returns valid data' do get api(route, current_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 diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 5068df5b43a..5fd76fce7df 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -16,7 +16,7 @@ describe API::Runner do it 'returns 400 error' do post api('/runners') - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 end end @@ -24,7 +24,7 @@ describe API::Runner do it 'returns 403 error' do post api('/runners'), token: 'invalid' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -34,7 +34,7 @@ describe API::Runner do runner = Ci::Runner.first - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(json_response['id']).to eq(runner.id) expect(json_response['token']).to eq(runner.token) expect(runner.run_untagged).to be true @@ -47,7 +47,7 @@ describe API::Runner do it 'creates runner' do post api('/runners'), token: project.runners_token - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(project.runners.size).to eq(1) expect(Ci::Runner.first.token).not_to eq(registration_token) expect(Ci::Runner.first.token).not_to eq(project.runners_token) @@ -60,7 +60,7 @@ describe API::Runner do post api('/runners'), token: registration_token, description: 'server.hostname' - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.description).to eq('server.hostname') end end @@ -70,7 +70,7 @@ describe API::Runner do post api('/runners'), token: registration_token, tag_list: 'tag1, tag2' - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2)) end end @@ -82,7 +82,7 @@ describe API::Runner do run_untagged: false, tag_list: ['tag'] - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.run_untagged).to be false expect(Ci::Runner.first.tag_list.sort).to eq(['tag']) end @@ -93,7 +93,7 @@ describe API::Runner do post api('/runners'), token: registration_token, run_untagged: false - expect(response).to have_http_status 404 + expect(response).to have_gitlab_http_status 404 end end end @@ -103,7 +103,7 @@ describe API::Runner do post api('/runners'), token: registration_token, locked: true - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.locked).to be true end end @@ -116,7 +116,7 @@ describe API::Runner do post api('/runners'), token: registration_token, info: { param => value } - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.read_attribute(param.to_sym)).to eq(value) end end @@ -128,7 +128,7 @@ describe API::Runner do it 'returns 400 error' do delete api('/runners') - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 end end @@ -136,7 +136,7 @@ describe API::Runner do it 'returns 403 error' do delete api('/runners'), token: 'invalid' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -146,7 +146,7 @@ describe API::Runner do it 'deletes Runner' do delete api('/runners'), token: runner.token - expect(response).to have_http_status 204 + expect(response).to have_gitlab_http_status 204 expect(Ci::Runner.count).to eq(0) end @@ -164,7 +164,7 @@ describe API::Runner do it 'returns 400 error' do post api('/runners/verify') - expect(response).to have_http_status :bad_request + expect(response).to have_gitlab_http_status :bad_request end end @@ -172,7 +172,7 @@ describe API::Runner do it 'returns 403 error' do post api('/runners/verify'), token: 'invalid-token' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -180,7 +180,7 @@ describe API::Runner do it 'verifies Runner credentials' do post api('/runners/verify'), token: runner.token - expect(response).to have_http_status 200 + expect(response).to have_gitlab_http_status 200 end end end @@ -216,7 +216,7 @@ describe API::Runner do context 'when runner sends version in User-Agent' do context 'for stable version' do it 'gives 204 and set X-GitLab-Last-Update' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.header).to have_key('X-GitLab-Last-Update') end end @@ -225,7 +225,7 @@ describe API::Runner do let(:last_update) { runner.ensure_runner_queue_value } it 'gives 204 and set the same X-GitLab-Last-Update' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.header['X-GitLab-Last-Update']).to eq(last_update) end end @@ -235,7 +235,7 @@ describe API::Runner do let(:new_update) { runner.tick_runner_queue } it 'gives 204 and set a new X-GitLab-Last-Update' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.header['X-GitLab-Last-Update']).to eq(new_update) end end @@ -243,19 +243,19 @@ describe API::Runner do context 'when beta version is sent' do let(:user_agent) { 'gitlab-runner 9.0.0~beta.167.g2b2bacc (master; go1.7.4; linux/amd64)' } - it { expect(response).to have_http_status(204) } + it { expect(response).to have_gitlab_http_status(204) } end context 'when pre-9-0 version is sent' do let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0 (1-6-stable; go1.6.3; linux/amd64)' } - it { expect(response).to have_http_status(204) } + it { expect(response).to have_gitlab_http_status(204) } end context 'when pre-9-0 beta version is sent' do let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0~beta.167.g2b2bacc (master; go1.6.3; linux/amd64)' } - it { expect(response).to have_http_status(204) } + it { expect(response).to have_gitlab_http_status(204) } end end end @@ -264,7 +264,7 @@ describe API::Runner do it 'returns 400 error' do post api('/jobs/request') - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 end end @@ -272,7 +272,7 @@ describe API::Runner do it 'returns 403 error' do post api('/jobs/request'), token: 'invalid' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -283,7 +283,7 @@ describe API::Runner do it 'returns 204 error' do request_job - expect(response).to have_http_status 204 + expect(response).to have_gitlab_http_status 204 end end @@ -365,7 +365,7 @@ describe API::Runner do it 'picks a job' do request_job info: { platform: :darwin } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(response.headers).not_to have_key('X-GitLab-Last-Update') expect(runner.reload.platform).to eq('darwin') expect(json_response['id']).to eq(job.id) @@ -390,7 +390,7 @@ describe API::Runner do it 'sets branch as ref_type' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['git_info']['ref_type']).to eq('tag') end end @@ -399,7 +399,7 @@ describe API::Runner do it 'sets tag as ref_type' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['git_info']['ref_type']).to eq('branch') end end @@ -415,7 +415,7 @@ describe API::Runner do it "updates provided Runner's parameter" do request_job info: { param => value } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(runner.reload.read_attribute(param.to_sym)).to eq(value) end end @@ -430,7 +430,7 @@ describe API::Runner do it 'returns a conflict' do request_job - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(response.headers).not_to have_key('X-GitLab-Last-Update') end end @@ -448,7 +448,7 @@ describe API::Runner do it 'returns dependent jobs' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(2) expect(json_response['dependencies']).to include( @@ -468,7 +468,7 @@ describe API::Runner do it 'returns dependent jobs' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies']).to include( @@ -494,7 +494,7 @@ describe API::Runner do it 'returns dependent jobs' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token) @@ -518,7 +518,7 @@ describe API::Runner do it 'returns an empty array' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(empty_dependencies_job.id) expect(json_response['dependencies'].count).to eq(0) end @@ -537,7 +537,7 @@ describe API::Runner do it 'picks job' do request_job - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 end end @@ -571,7 +571,7 @@ describe API::Runner do it 'returns variables for triggers' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['variables']).to include(*expected_variables) end end @@ -683,7 +683,7 @@ describe API::Runner do it 'updates a running build' do update_job(trace: 'BUILD TRACE UPDATED') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(job.reload.trace.raw).to eq 'BUILD TRACE UPDATED' end end @@ -702,7 +702,7 @@ describe API::Runner do it 'responds with forbidden' do update_job - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -871,7 +871,7 @@ describe API::Runner do it 'authorizes posting artifacts to running job' do authorize_artifacts_with_token_in_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(json_response['TempPath']).not_to be_nil end @@ -881,7 +881,7 @@ describe API::Runner do authorize_artifacts_with_token_in_params(filesize: 100) - expect(response).to have_http_status(413) + expect(response).to have_gitlab_http_status(413) end end @@ -889,7 +889,7 @@ describe API::Runner do it 'authorizes posting artifacts to running job' do authorize_artifacts_with_token_in_headers - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(json_response['TempPath']).not_to be_nil end @@ -899,7 +899,7 @@ describe API::Runner do authorize_artifacts_with_token_in_headers(filesize: 100) - expect(response).to have_http_status(413) + expect(response).to have_gitlab_http_status(413) end end @@ -907,7 +907,7 @@ describe API::Runner do it 'fails to authorize artifacts posting' do authorize_artifacts(token: job.project.runners_token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -916,14 +916,14 @@ describe API::Runner do authorize_artifacts - expect(response).to have_http_status(500) + expect(response).to have_gitlab_http_status(500) end context 'authorization token is invalid' do it 'responds with forbidden' do authorize_artifacts(token: 'invalid', filesize: 100 ) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -958,14 +958,14 @@ describe API::Runner do it 'responds with forbidden' do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when job is running' do shared_examples 'successful artifacts upload' do it 'updates successfully' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -998,7 +998,7 @@ describe API::Runner do it 'responds with forbidden' do upload_artifacts(file_upload, headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.project.runners_token)) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1009,7 +1009,7 @@ describe API::Runner do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_http_status(413) + expect(response).to have_gitlab_http_status(413) end end @@ -1017,7 +1017,7 @@ describe API::Runner do it 'fails to post artifacts without file' do post api("/jobs/#{job.id}/artifacts"), {}, headers_with_token - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1025,7 +1025,7 @@ describe API::Runner do it 'fails to post artifacts without GitLab-Workhorse' do post api("/jobs/#{job.id}/artifacts"), { token: job.token }, {} - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1047,7 +1047,7 @@ describe API::Runner do let(:expire_in) { '7 days' } it 'updates when specified' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(7.days.from_now) end end @@ -1056,7 +1056,7 @@ describe API::Runner do let(:expire_in) { nil } it 'ignores if not specified' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_nil end @@ -1065,7 +1065,7 @@ describe API::Runner do let(:default_artifacts_expire_in) { '5 days' } it 'sets to application default' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(5.days.from_now) end end @@ -1074,7 +1074,7 @@ describe API::Runner do let(:default_artifacts_expire_in) { '0' } it 'does not set expire_in' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_nil end end @@ -1103,7 +1103,7 @@ describe API::Runner do end it 'stores artifacts and artifacts metadata' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(stored_artifacts_file.original_filename).to eq(artifacts.original_filename) expect(stored_metadata_file.original_filename).to eq(metadata.original_filename) expect(stored_artifacts_size).to eq(71759) @@ -1116,7 +1116,7 @@ describe API::Runner do end it 'is expected to respond with bad request' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'does not store metadata' do @@ -1141,7 +1141,7 @@ describe API::Runner do it' "fails to post artifacts for outside of tmp path"' do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1171,7 +1171,7 @@ describe API::Runner do context 'when using job token' do it 'download artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers).to include download_headers end end @@ -1180,14 +1180,14 @@ describe API::Runner do let(:token) { job.project.runners_token } it 'responds with forbidden' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end context 'when job does not has artifacts' do it 'responds with not found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 67907579225..fe38a7b3251 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -37,7 +37,7 @@ describe API::Runners do get api('/runners', user) shared = json_response.any? { |r| r['is_shared'] } - 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(shared).to be_falsey @@ -47,7 +47,7 @@ describe API::Runners do get api('/runners?scope=active', user) shared = json_response.any? { |r| r['is_shared'] } - 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(shared).to be_falsey @@ -55,7 +55,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners?scope=unknown', user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -63,7 +63,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -75,7 +75,7 @@ describe API::Runners do get api('/runners/all', admin) shared = json_response.any? { |r| r['is_shared'] } - 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(shared).to be_truthy @@ -86,7 +86,7 @@ describe API::Runners do it 'does not return runners list' do get api('/runners/all', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -94,7 +94,7 @@ describe API::Runners do get api('/runners/all?scope=specific', admin) shared = json_response.any? { |r| r['is_shared'] } - 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(shared).to be_falsey @@ -102,7 +102,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners?scope=unknown', admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -110,7 +110,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -121,7 +121,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(shared_runner.description) end end @@ -130,7 +130,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{specific_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(specific_runner.description) end end @@ -138,7 +138,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do get api('/runners/9999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -147,7 +147,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{specific_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(specific_runner.description) end end @@ -156,7 +156,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(shared_runner.description) end end @@ -166,7 +166,7 @@ describe API::Runners do it "does not return runner's details" do get api("/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -174,7 +174,7 @@ describe API::Runners do it "does not return runner's details" do get api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -195,7 +195,7 @@ describe API::Runners do access_level: 'ref_protected') shared_runner.reload - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(shared_runner.description).to eq("#{description}_updated") expect(shared_runner.active).to eq(!active) expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql') @@ -215,7 +215,7 @@ describe API::Runners do update_runner(specific_runner.id, admin, description: 'test') specific_runner.reload - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(specific_runner.description).to eq('test') expect(specific_runner.description).not_to eq(description) expect(specific_runner.ensure_runner_queue_value) @@ -226,7 +226,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do update_runner(9999, admin, description: 'test') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end def update_runner(id, user, args) @@ -239,7 +239,7 @@ describe API::Runners do it 'does not update runner' do put api("/runners/#{shared_runner.id}", user), description: 'test' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -247,7 +247,7 @@ describe API::Runners do it 'does not update runner without access to it' do put api("/runners/#{specific_runner.id}", user2), description: 'test' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'updates runner with access to it' do @@ -255,7 +255,7 @@ describe API::Runners do put api("/runners/#{specific_runner.id}", admin), description: 'test' specific_runner.reload - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(specific_runner.description).to eq('test') expect(specific_runner.description).not_to eq(description) end @@ -266,7 +266,7 @@ describe API::Runners do it 'does not delete runner' do put api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -278,7 +278,7 @@ describe API::Runners do expect do delete api("/runners/#{shared_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.shared.count }.by(-1) end @@ -292,7 +292,7 @@ describe API::Runners do expect do delete api("/runners/#{unused_specific_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.specific.count }.by(-1) end @@ -300,7 +300,7 @@ describe API::Runners do expect do delete api("/runners/#{specific_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.specific.count }.by(-1) end end @@ -308,7 +308,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do delete api('/runners/9999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -316,26 +316,26 @@ describe API::Runners do context 'when runner is shared' do it 'does not delete runner' do delete api("/runners/#{shared_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when runner is not shared' do it 'does not delete runner without access to it' do delete api("/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not delete runner with more than one associated project' do delete api("/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'deletes runner for one owned project' do expect do delete api("/runners/#{specific_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.specific.count }.by(-1) end @@ -349,7 +349,7 @@ describe API::Runners do it 'does not delete runner' do delete api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -360,7 +360,7 @@ describe API::Runners do get api("/projects/#{project.id}/runners", user) shared = json_response.any? { |r| r['is_shared'] } - 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(shared).to be_truthy @@ -371,7 +371,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -379,7 +379,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -396,14 +396,14 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id end.to change { project.runners.count }.by(+1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'avoids changes when enabling already enabled runner' do expect do post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) end it 'does not enable locked runner' do @@ -413,13 +413,13 @@ describe API::Runners do post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not enable shared runner' do post api("/projects/#{project.id}/runners", user), runner_id: shared_runner.id - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'user is admin' do @@ -427,7 +427,7 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", admin), runner_id: unused_specific_runner.id end.to change { project.runners.count }.by(+1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -435,14 +435,14 @@ describe API::Runners do it 'does not enable runner without access to' do post api("/projects/#{project.id}/runners", user), runner_id: unused_specific_runner.id - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'raises an error when no runner_id param is provided' do post api("/projects/#{project.id}/runners", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -450,7 +450,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -458,7 +458,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -470,7 +470,7 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { project.runners.count }.by(-1) end @@ -484,14 +484,14 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user) end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'returns 404 is runner is not found' do delete api("/projects/#{project.id}/runners/9999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -499,7 +499,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -507,7 +507,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index 7e174903918..dfe48e45d49 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -16,7 +16,7 @@ describe API::Services do it "updates #{service} settings" do put api("/projects/#{project.id}/services/#{dashed_service}", user), service_attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) current_service = project.services.first event = current_service.event_names.empty? ? "foo" : current_service.event_names.first @@ -24,7 +24,7 @@ describe API::Services do put api("/projects/#{project.id}/services/#{dashed_service}?#{event}=#{!state}", user), service_attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(project.services.first[event]).not_to eq(state) unless event == "foo" end @@ -56,7 +56,7 @@ describe API::Services do it "deletes #{service}" do delete api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) project.send(service_method).reload expect(project.send(service_method).activated?).to be_falsey end @@ -74,20 +74,20 @@ describe API::Services do it 'returns authentication error when unauthenticated' do get api("/projects/#{project.id}/services/#{dashed_service}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns all properties of service #{service} when authenticated as admin" do get api("/projects/#{project.id}/services/#{dashed_service}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list.map) end it "returns properties of service #{service} other than passwords when authenticated as project owner" do get api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list_without_passwords) end @@ -95,7 +95,7 @@ describe API::Services do project.team << [user2, :developer] get api("/projects/#{project.id}/services/#{dashed_service}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -108,7 +108,7 @@ describe API::Services do it 'returns a not found message' do post api("/projects/#{project.id}/services/idonotexist/trigger") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["error"]).to eq("404 Not Found") end end @@ -127,7 +127,7 @@ describe API::Services do it 'when the service is inactive' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -142,7 +142,7 @@ describe API::Services do it 'returns status 200' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -150,7 +150,7 @@ describe API::Services do it 'returns a generic 404' do post api("/projects/404/services/#{service_name}/trigger"), params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to eq("404 Service Not Found") end end @@ -170,7 +170,7 @@ describe API::Services do it 'returns status 200' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), token: 'token', text: 'help' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['response_type']).to eq("ephemeral") end end diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb index 5e77519c867..83d09878813 100644 --- a/spec/requests/api/session_spec.rb +++ b/spec/requests/api/session_spec.rb @@ -7,7 +7,7 @@ describe API::Session do context "when valid password" do it "returns private token" do post api("/session"), email: user.email, password: '12345678' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['email']).to eq(user.email) expect(json_response['private_token']).to eq(user.private_token) @@ -22,7 +22,7 @@ describe API::Session do post api('/session'), email: user.email, password: user.password - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).to include('You have 2FA enabled.') end end @@ -57,7 +57,7 @@ describe API::Session do context "when invalid password" do it "returns authentication error" do post api("/session"), email: user.email, password: '123' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['email']).to be_nil expect(json_response['private_token']).to be_nil @@ -68,13 +68,13 @@ describe API::Session do it "returns authentication error with email" do post api("/session"), email: user.email - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns authentication error with username" do post api("/session"), email: user.username - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -82,7 +82,7 @@ describe API::Session do it "returns authentication error" do post api("/session"), password: user.password - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -91,7 +91,7 @@ describe API::Session do user.block post api("/session"), email: user.username, password: user.password - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -100,7 +100,7 @@ describe API::Session do user.ldap_block post api("/session"), email: user.username, password: user.password - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index c24de58ee9d..5d3e78dd7c8 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -7,7 +7,7 @@ describe API::Settings, 'Settings' do describe "GET /application/settings" do it "returns application settings" do get api("/application/settings", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Hash expect(json_response['default_projects_limit']).to eq(42) expect(json_response['password_authentication_enabled']).to be_truthy @@ -56,7 +56,7 @@ describe API::Settings, 'Settings' do ed25519_key_restriction: 256, circuitbreaker_failure_wait_time: 2 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['default_projects_limit']).to eq(3) expect(json_response['password_authentication_enabled']).to be_falsey expect(json_response['repository_storages']).to eq(['custom']) @@ -83,7 +83,7 @@ describe API::Settings, 'Settings' do it "returns a blank parameter error message" do put api("/application/settings", admin), koding_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('koding_url is missing') end end @@ -92,7 +92,7 @@ describe API::Settings, 'Settings' do it "returns a blank parameter error message" do put api("/application/settings", admin), plantuml_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('plantuml_url is missing') end end diff --git a/spec/requests/api/sidekiq_metrics_spec.rb b/spec/requests/api/sidekiq_metrics_spec.rb index 83042d0cb12..fff9adb7f57 100644 --- a/spec/requests/api/sidekiq_metrics_spec.rb +++ b/spec/requests/api/sidekiq_metrics_spec.rb @@ -7,28 +7,28 @@ describe API::SidekiqMetrics do it 'defines the `queue_metrics` endpoint' do get api('/sidekiq/queue_metrics', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash end it 'defines the `process_metrics` endpoint' do get api('/sidekiq/process_metrics', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['processes']).to be_an Array end it 'defines the `job_stats` endpoint' do get api('/sidekiq/job_stats', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash end it 'defines the `compound_metrics` endpoint' do get api('/sidekiq/compound_metrics', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['queues']).to be_a Hash expect(json_response['processes']).to be_an Array diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index d3905f698bd..74198c8eb4f 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -11,7 +11,7 @@ describe API::Snippets do get api("/snippets/", 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.map { |snippet| snippet['id']} ).to contain_exactly( @@ -27,7 +27,7 @@ describe API::Snippets do get api("/snippets/", 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(0) @@ -46,7 +46,7 @@ describe API::Snippets do it 'returns all snippets with public visibility from all users' do get api("/snippets/public", 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.map { |snippet| snippet['id']} ).to contain_exactly( @@ -67,7 +67,7 @@ describe API::Snippets do it 'returns raw text' do get api("/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -75,7 +75,7 @@ describe API::Snippets do it 'returns 404 for invalid snippet id' do get api("/snippets/1234/raw", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end @@ -86,7 +86,7 @@ describe API::Snippets do it 'returns snippet json' do get api("/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) expect(json_response['description']).to eq(snippet.description) @@ -96,7 +96,7 @@ describe API::Snippets do it 'returns 404 for invalid snippet id' do get api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -117,7 +117,7 @@ describe API::Snippets do post api("/snippets/", user), params end.to change { PersonalSnippet.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(params[:title]) expect(json_response['description']).to eq(params[:description]) expect(json_response['file_name']).to eq(params[:file_name]) @@ -128,7 +128,7 @@ describe API::Snippets do post api("/snippets/", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -152,7 +152,7 @@ describe API::Snippets do expect { create_snippet(visibility: 'public') } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -177,7 +177,7 @@ describe API::Snippets do put api("/snippets/#{snippet.id}", user), content: new_content, description: new_description - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) snippet.reload expect(snippet.content).to eq(new_content) expect(snippet.description).to eq(new_description) @@ -186,21 +186,21 @@ describe API::Snippets do it 'returns 404 for invalid snippet id' do put api("/snippets/1234", user), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it "returns 404 for another user's snippet" do put api("/snippets/#{snippet.id}", other_user), title: 'fubar' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put api("/snippets/1234", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -228,7 +228,7 @@ describe API::Snippets do expect { update_snippet(title: 'Foo') } .not_to change { snippet.reload.title } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -260,14 +260,14 @@ describe API::Snippets do expect do delete api("/snippets/#{public_snippet.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { PersonalSnippet.count }.by(-1) end it 'returns 404 for invalid snippet id' do delete api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end @@ -284,7 +284,7 @@ describe API::Snippets do it 'exposes known attributes' do get api("/snippets/#{snippet.id}/user_agent_detail", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -293,7 +293,7 @@ describe API::Snippets do it "returns unautorized for non-admin users" do get api("/snippets/#{snippet.id}/user_agent_detail", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index 216d278ad21..c7a009e999e 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -14,7 +14,7 @@ describe API::SystemHooks do it "returns authentication error" do get api("/hooks") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -22,7 +22,7 @@ describe API::SystemHooks do it "returns forbidden error" do get api("/hooks", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -30,7 +30,7 @@ describe API::SystemHooks do it "returns an array of hooks" do get api("/hooks", admin) - 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['url']).to eq(hook.url) @@ -51,13 +51,13 @@ describe API::SystemHooks do it "responds with 400 if url not given" do post api("/hooks", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "responds with 400 if url is invalid" do post api("/hooks", admin), url: 'hp://mep.mep' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "does not create new hook without url" do @@ -69,7 +69,7 @@ describe API::SystemHooks do it 'sets default values for events' do post api('/hooks', admin), url: 'http://mep.mep', enable_ssl_verification: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['enable_ssl_verification']).to be true expect(json_response['tag_push_events']).to be false end @@ -78,13 +78,13 @@ describe API::SystemHooks do describe "GET /hooks/:id" do it "returns hook by id" do get api("/hooks/#{hook.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['event_name']).to eq('project_create') end it "returns 404 on failure" do get api("/hooks/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -93,14 +93,14 @@ describe API::SystemHooks do expect do delete api("/hooks/#{hook.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { SystemHook.count }.by(-1) end it 'returns 404 if the system hook does not exist' do delete api('/hooks/12345', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do diff --git a/spec/requests/api/templates_spec.rb b/spec/requests/api/templates_spec.rb index f8af9295842..de1619f33c1 100644 --- a/spec/requests/api/templates_spec.rb +++ b/spec/requests/api/templates_spec.rb @@ -23,7 +23,7 @@ describe API::Templates do it 'returns a list of available gitignore templates' do get api('/templates/gitignores') - 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 be > 15 @@ -34,7 +34,7 @@ describe API::Templates do it 'returns a list of available gitlab_ci_ymls' do get api('/templates/gitlab_ci_ymls') - 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['name']).not_to be_nil @@ -45,7 +45,7 @@ describe API::Templates do it 'adds a disclaimer on the top' do get api('/templates/gitlab_ci_ymls/Ruby') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['content']).to start_with("# This file is a template,") end end @@ -74,7 +74,7 @@ describe API::Templates do it 'returns a list of available license templates' do get api('/templates/licenses') - 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(12) @@ -86,7 +86,7 @@ describe API::Templates do it 'returns a list of available popular license templates' do get api('/templates/licenses?popular=1') - 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(3) @@ -169,7 +169,7 @@ describe API::Templates do let(:license_type) { 'muth-over9000' } it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb index 25d7f6dffcf..c6063a2e089 100644 --- a/spec/requests/api/todos_spec.rb +++ b/spec/requests/api/todos_spec.rb @@ -110,7 +110,7 @@ describe API::Todos do it 'returns authentication error' do post api("/todos/#{pending_1.id}/mark_as_done") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -118,7 +118,7 @@ describe API::Todos do it 'marks a todo as done' do post api("/todos/#{pending_1.id}/mark_as_done", john_doe) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(pending_1.id) expect(json_response['state']).to eq('done') expect(pending_1.reload).to be_done @@ -137,7 +137,7 @@ describe API::Todos do it 'returns authentication error' do post api('/todos/mark_as_done') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -145,7 +145,7 @@ describe API::Todos do it 'marks all todos as done' do post api('/todos/mark_as_done', john_doe) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(pending_1.reload).to be_done expect(pending_2.reload).to be_done expect(pending_3.reload).to be_done @@ -196,9 +196,9 @@ describe API::Todos do post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", guest) if issuable_type == 'merge_requests' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) else - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 922b99a6cba..b2c56f7af2c 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -28,13 +28,13 @@ describe API::Triggers do it 'returns bad request if token is missing' do post api("/projects/#{project.id}/trigger/pipeline"), ref: 'master' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns not found if project is not found' do post api('/projects/0/trigger/pipeline'), options.merge(ref: 'master') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -44,7 +44,7 @@ describe API::Triggers do it 'creates pipeline' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to include('id' => pipeline.id) pipeline.builds.reload expect(pipeline.builds.pending.size).to eq(2) @@ -54,7 +54,7 @@ describe API::Triggers do it 'returns bad request with no pipeline created if there\'s no commit for that ref' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'other-branch') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('base' => ["Reference not found"]) end @@ -66,21 +66,21 @@ describe API::Triggers do it 'validates variables to be a hash' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: 'value', ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('variables is invalid') end it 'validates variables needs to be a map of key-valued strings' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: { key: %w(1 2) }, ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end it 'creates trigger request with variables' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: variables, ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables) end end @@ -93,7 +93,7 @@ describe API::Triggers do it 'creates pipeline' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to include('id' => pipeline.id) pipeline.builds.reload expect(pipeline.builds.pending.size).to eq(2) @@ -106,7 +106,7 @@ describe API::Triggers do it 'does not leak the presence of project when token is for different project' do post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'creates builds from the ref given in the URL, not in the body' do @@ -114,7 +114,7 @@ describe API::Triggers do post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(5) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when ref contains a dot' do @@ -125,7 +125,7 @@ describe API::Triggers do post api("/projects/#{project.id}/ref/v.1-branch/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(4) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -136,7 +136,7 @@ describe API::Triggers do it 'returns list of triggers' do get api("/projects/#{project.id}/triggers", 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_a(Array) expect(json_response[0]).to have_key('token') @@ -147,7 +147,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -155,7 +155,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -165,14 +165,14 @@ describe API::Triggers do it 'returns trigger details' do get api("/projects/#{project.id}/triggers/#{trigger.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Hash) end it 'responds with 404 Not Found if requesting non-existing trigger' do get api("/projects/#{project.id}/triggers/-5", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -180,7 +180,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers/#{trigger.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -188,7 +188,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers/#{trigger.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -202,7 +202,7 @@ describe API::Triggers do description: 'trigger' end.to change {project.triggers.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to include('description' => 'trigger') end end @@ -211,7 +211,7 @@ describe API::Triggers do it 'does not create trigger' do post api("/projects/#{project.id}/triggers", user) - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -221,7 +221,7 @@ describe API::Triggers do post api("/projects/#{project.id}/triggers", user2), description: 'trigger' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -230,7 +230,7 @@ describe API::Triggers do post api("/projects/#{project.id}/triggers"), description: 'trigger' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -243,7 +243,7 @@ describe API::Triggers do put api("/projects/#{project.id}/triggers/#{trigger.id}", user), description: new_description - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include('description' => new_description) expect(trigger.reload.description).to eq(new_description) end @@ -253,7 +253,7 @@ describe API::Triggers do it 'does not update trigger' do put api("/projects/#{project.id}/triggers/#{trigger.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -261,7 +261,7 @@ describe API::Triggers do it 'does not update trigger' do put api("/projects/#{project.id}/triggers/#{trigger.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -271,7 +271,7 @@ describe API::Triggers do it 'updates owner' do post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include('owner') expect(trigger.reload.owner).to eq(user) end @@ -281,7 +281,7 @@ describe API::Triggers do it 'does not update owner' do post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -289,7 +289,7 @@ describe API::Triggers do it 'does not update owner' do post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -300,14 +300,14 @@ describe API::Triggers do expect do delete api("/projects/#{project.id}/triggers/#{trigger.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {project.triggers.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing trigger' do delete api("/projects/#{project.id}/triggers/-5", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -319,7 +319,7 @@ describe API::Triggers do it 'does not delete trigger' do delete api("/projects/#{project.id}/triggers/#{trigger.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -327,7 +327,7 @@ describe API::Triggers do it 'does not delete trigger' do delete api("/projects/#{project.id}/triggers/#{trigger.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 69c8aa4482a..4737f034f21 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -113,7 +113,7 @@ describe API::Users do it "returns a 403 when non-admin user searches by external UID" do get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}&provider=#{omniauth_user.identities.first.provider}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not reveal the `is_admin` flag of the user' do @@ -130,7 +130,7 @@ describe API::Users do admin_personal_access_token = create(:personal_access_token, user: admin).token get api("/users?private_token=#{admin_personal_access_token}&sudo=#{user.id}", admin) - expect(response).to have_http_status(:success) + expect(response).to have_gitlab_http_status(:success) end end @@ -162,13 +162,13 @@ describe API::Users do it "returns 400 error if provider with no extern_uid" do get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 error if provider with no extern_uid" do get api("/users?provider=#{omniauth_user.identities.first.provider}", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a user created before a specific date" do @@ -240,21 +240,21 @@ describe API::Users do get api("/users/#{user.id}") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end it "returns a 404 error if user id not found" do get api("/users/9999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do get api("/users/1ASDF", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -271,7 +271,7 @@ describe API::Users do it "creates user with correct attributes" do post api('/users', admin), attributes_for(:user, admin: true, can_create_group: true) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) expect(new_user).not_to eq(nil) @@ -285,12 +285,12 @@ describe API::Users do post api('/users', admin), attributes - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it "creates non-admin user" do post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) expect(new_user).not_to eq(nil) @@ -300,7 +300,7 @@ describe API::Users do it "creates non-admin users by default" do post api('/users', admin), attributes_for(:user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) expect(new_user).not_to eq(nil) @@ -309,12 +309,12 @@ describe API::Users do it "returns 201 Created on success" do post api("/users", admin), attributes_for(:user, projects_limit: 3) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'creates non-external users by default' do post api("/users", admin), attributes_for(:user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -324,7 +324,7 @@ describe API::Users do it 'allows an external user to be created' do post api("/users", admin), attributes_for(:user, external: true) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -335,7 +335,7 @@ describe API::Users do it "creates user with reset password" do post api('/users', admin), attributes_for(:user, reset_password: true).except(:password) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -349,27 +349,27 @@ describe API::Users do email: 'invalid email', password: 'password', name: 'test' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if name not given' do post api('/users', admin), attributes_for(:user).except(:name) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if password not given' do post api('/users', admin), attributes_for(:user).except(:password) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if email not given' do post api('/users', admin), attributes_for(:user).except(:email) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if username not given' do post api('/users', admin), attributes_for(:user).except(:username) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if user does not validate' do @@ -380,7 +380,7 @@ describe API::Users do name: 'test', bio: 'g' * 256, projects_limit: -1 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['password']) .to eq(['is too short (minimum is 8 characters)']) expect(json_response['message']['bio']) @@ -393,7 +393,7 @@ describe API::Users do it "is not available for non admin users" do post api("/users", user), attributes_for(:user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'with existing user' do @@ -413,7 +413,7 @@ describe API::Users do password: 'password', username: 'foo' end.to change { User.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Email has already been taken') end @@ -425,14 +425,14 @@ describe API::Users do password: 'password', username: 'test' end.to change { User.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Username has already been taken') end it 'creates user with new identity' do post api("/users", admin), attributes_for(:user, provider: 'github', extern_uid: '67890') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['identities'].first['extern_uid']).to eq('67890') expect(json_response['identities'].first['provider']).to eq('github') end @@ -450,7 +450,7 @@ describe API::Users do describe "GET /users/sign_up" do it "redirects to sign in page" do get "/users/sign_up" - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(response).to redirect_to(new_user_session_path) end end @@ -465,7 +465,7 @@ describe API::Users do it "updates user with new bio" do put api("/users/#{user.id}", admin), { bio: 'new test bio' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['bio']).to eq('new test bio') expect(user.reload.bio).to eq('new test bio') end @@ -473,14 +473,14 @@ describe API::Users do it "updates user with new password and forces reset on next login" do put api("/users/#{user.id}", admin), password: '12345678' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.password_expires_at).to be <= Time.now end it "updates user with organization" do put api("/users/#{user.id}", admin), { organization: 'GitLab' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['organization']).to eq('GitLab') expect(user.reload.organization).to eq('GitLab') end @@ -491,14 +491,14 @@ describe API::Users do user.reload expect(user.avatar).to be_present - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['avatar_url']).to include(user.avatar_path) end it 'updates user with his own email' do put api("/users/#{user.id}", admin), email: user.email - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['email']).to eq(user.email) expect(user.reload.email).to eq(user.email) end @@ -506,14 +506,14 @@ describe API::Users do it 'updates user with a new email' do put api("/users/#{user.id}", admin), email: 'new@email.com' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.notification_email).to eq('new@email.com') end it 'updates user with his own username' do put api("/users/#{user.id}", admin), username: user.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['username']).to eq(user.username) expect(user.reload.username).to eq(user.username) end @@ -521,14 +521,14 @@ describe API::Users do it "updates user's existing identity" do put api("/users/#{omniauth_user.id}", admin), provider: 'ldapmain', extern_uid: '654321' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321') end it 'updates user with new identity' do put api("/users/#{user.id}", admin), provider: 'github', extern_uid: 'john' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.identities.first.extern_uid).to eq('john') expect(user.reload.identities.first.provider).to eq('github') end @@ -536,7 +536,7 @@ describe API::Users do it "updates admin status" do put api("/users/#{user.id}", admin), { admin: true } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.admin).to eq(true) end @@ -551,7 +551,7 @@ describe API::Users do it "does not update admin status" do put api("/users/#{admin_user.id}", admin), { can_create_group: false } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(admin_user.reload.admin).to eq(true) expect(admin_user.can_create_group).to eq(false) end @@ -559,7 +559,7 @@ describe API::Users do it "does not allow invalid update" do put api("/users/#{user.id}", admin), { email: 'invalid email' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(user.reload.email).not_to eq('invalid email') end @@ -569,21 +569,21 @@ describe API::Users do put api("/users/#{user.id}", user), attributes_for(:user) end.not_to change { user.reload.attributes } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it "returns 404 for non-existing user" do put api("/users/999999", admin), { bio: 'update should fail' } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 if invalid ID" do put api("/users/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 error if user does not validate' do @@ -594,7 +594,7 @@ describe API::Users do name: 'test', bio: 'g' * 256, projects_limit: -1 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['password']) .to eq(['is too short (minimum is 8 characters)']) expect(json_response['message']['bio']) @@ -608,13 +608,13 @@ describe API::Users do it 'returns 400 if provider is missing for identity update' do put api("/users/#{omniauth_user.id}", admin), extern_uid: '654321' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 if external UID is missing for identity update' do put api("/users/#{omniauth_user.id}", admin), provider: 'ldap' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "with existing user" do @@ -627,7 +627,7 @@ describe API::Users do it 'returns 409 conflict error if email address exists' do put api("/users/#{@user.id}", admin), email: 'test@example.com' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(@user.reload.email).to eq(@user.email) end @@ -635,7 +635,7 @@ describe API::Users do @user_id = User.all.last.id put api("/users/#{@user.id}", admin), username: 'test' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(@user.reload.username).to eq(@user.username) end end @@ -649,14 +649,14 @@ describe API::Users do it "does not create invalid ssh key" do post api("/users/#{user.id}/keys", admin), { title: "invalid key" } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create key without title' do post api("/users/#{user.id}/keys", admin), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end @@ -669,7 +669,7 @@ describe API::Users do it "returns 400 for invalid ID" do post api("/users/999999/keys", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -681,14 +681,14 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do get api("/users/#{user.id}/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get api('/users/999999/keys', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -698,7 +698,7 @@ describe API::Users do get api("/users/#{user.id}/keys", admin) - 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(key.title) @@ -714,7 +714,7 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do delete api("/users/#{user.id}/keys/42") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -726,7 +726,7 @@ describe API::Users do expect do delete api("/users/#{user.id}/keys/#{key.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.keys.count }.by(-1) end @@ -738,13 +738,13 @@ describe API::Users do user.keys << key user.save delete api("/users/999999/keys/#{key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do delete api("/users/#{user.id}/keys/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end end @@ -758,7 +758,7 @@ describe API::Users do it 'does not create invalid GPG key' do post api("/users/#{user.id}/gpg_keys", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end @@ -767,14 +767,14 @@ describe API::Users do expect do post api("/users/#{user.id}/gpg_keys", admin), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { user.gpg_keys.count }.by(1) end it 'returns 400 for invalid ID' do post api('/users/999999/gpg_keys', admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -787,7 +787,7 @@ describe API::Users do it 'returns authentication error' do get api("/users/#{user.id}/gpg_keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -795,14 +795,14 @@ describe API::Users do it 'returns 404 for non-existing user' do get api('/users/999999/gpg_keys', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do delete api("/users/#{user.id}/gpg_keys/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -812,7 +812,7 @@ describe API::Users do get api("/users/#{user.id}/gpg_keys", admin) - 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['key']).to eq(gpg_key.key) @@ -829,7 +829,7 @@ describe API::Users do it 'returns authentication error' do delete api("/users/#{user.id}/keys/42") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -841,7 +841,7 @@ describe API::Users do expect do delete api("/users/#{user.id}/gpg_keys/#{gpg_key.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.gpg_keys.count }.by(-1) end @@ -851,14 +851,14 @@ describe API::Users do delete api("/users/999999/gpg_keys/#{gpg_key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do delete api("/users/#{user.id}/gpg_keys/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end end @@ -873,7 +873,7 @@ describe API::Users do it 'returns authentication error' do post api("/users/#{user.id}/gpg_keys/42/revoke") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -885,7 +885,7 @@ describe API::Users do expect do post api("/users/#{user.id}/gpg_keys/#{gpg_key.id}/revoke", admin) - expect(response).to have_http_status(:accepted) + expect(response).to have_gitlab_http_status(:accepted) end.to change { user.gpg_keys.count }.by(-1) end @@ -895,14 +895,14 @@ describe API::Users do post api("/users/999999/gpg_keys/#{gpg_key.id}/revoke", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do post api("/users/#{user.id}/gpg_keys/42/revoke", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end end @@ -916,7 +916,7 @@ describe API::Users do it "does not create invalid email" do post api("/users/#{user.id}/emails", admin), {} - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('email is missing') end @@ -930,7 +930,7 @@ describe API::Users do it "returns a 400 for invalid ID" do post api("/users/999999/emails", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -942,14 +942,14 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do get api("/users/#{user.id}/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get api('/users/999999/emails', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -959,7 +959,7 @@ describe API::Users do get api("/users/#{user.id}/emails", admin) - 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['email']).to eq(email.email) @@ -968,7 +968,7 @@ describe API::Users do it "returns a 404 for invalid ID" do get api("/users/ASDF/emails", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -981,7 +981,7 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do delete api("/users/#{user.id}/emails/42") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -993,7 +993,7 @@ describe API::Users do expect do delete api("/users/#{user.id}/emails/#{email.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.emails.count }.by(-1) end @@ -1005,20 +1005,20 @@ describe API::Users do user.emails << email user.save delete api("/users/999999/emails/#{email.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if email not foud' do delete api("/users/#{user.id}/emails/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end it "returns a 404 for invalid ID" do delete api("/users/ASDF/emails/bar", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1034,7 +1034,7 @@ describe API::Users do it "deletes user" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}", admin) } - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound expect { Namespace.find(namespace.id) }.to raise_error ActiveRecord::RecordNotFound end @@ -1045,31 +1045,31 @@ describe API::Users do it "does not delete for unauthenticated user" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}") } - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "is not available for non admin users" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}", user) } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 404 for non-existing user" do Sidekiq::Testing.inline! { delete api("/users/999999", admin) } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do Sidekiq::Testing.inline! { delete api("/users/ASDF", admin) } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "hard delete disabled" do it "moves contributions to the ghost user" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}", admin) } - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(issue.reload).to be_persisted expect(issue.author.ghost?).to be_truthy end @@ -1079,7 +1079,7 @@ describe API::Users do it "removes contributions" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}?hard_delete=true", admin) } - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(Issue.exists?(issue.id)).to be_falsy end end @@ -1093,7 +1093,7 @@ describe API::Users do it 'returns 403 without private token when sudo is defined' do get api("/user?private_token=#{personal_access_token}&sudo=123") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1101,14 +1101,14 @@ describe API::Users do it 'returns 403 without private token when sudo defined' do get api("/user?private_token=#{user.private_token}&sudo=123") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'returns current user without private token when sudo not defined' do get api("/user", 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/user/public') expect(json_response['id']).to eq(user.id) end @@ -1128,13 +1128,13 @@ describe API::Users do it 'returns 403 without private token when sudo defined' do get api("/user?private_token=#{admin_personal_access_token}&sudo=#{user.id}") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns initial current user without private token but with is_admin when sudo not defined' do get api("/user?private_token=#{admin_personal_access_token}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/user/admin') expect(json_response['id']).to eq(admin.id) end @@ -1144,7 +1144,7 @@ describe API::Users do it 'returns sudoed user with private token when sudo defined' do get api("/user?private_token=#{admin.private_token}&sudo=#{user.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/user/login') expect(json_response['id']).to eq(user.id) end @@ -1152,7 +1152,7 @@ describe API::Users do it 'returns initial current user without private token but with is_admin when sudo not defined' do get api("/user?private_token=#{admin.private_token}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/user/admin') expect(json_response['id']).to eq(admin.id) end @@ -1163,7 +1163,7 @@ describe API::Users do it "returns 401 error if user is unauthenticated" do get api("/user") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -1172,7 +1172,7 @@ describe API::Users do context "when unauthenticated" do it "returns authentication error" do get api("/user/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1183,7 +1183,7 @@ describe API::Users do get api("/user/keys", 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(key.title) @@ -1203,14 +1203,14 @@ describe API::Users do user.keys << key user.save get api("/user/keys/#{key.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["title"]).to eq(key.title) end it "returns 404 Not Found within invalid ID" do get api("/user/keys/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end @@ -1219,14 +1219,14 @@ describe API::Users do user.save admin get api("/user/keys/#{key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end it "returns 404 for invalid ID" do get api("/users/keys/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "scopes" do @@ -1243,31 +1243,31 @@ describe API::Users do expect do post api("/user/keys", user), key_attrs end.to change { user.keys.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it "returns a 401 error if unauthorized" do post api("/user/keys"), title: 'some title', key: 'some key' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "does not create ssh key without key" do post api("/user/keys", user), title: 'title' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create ssh key without title' do post api('/user/keys', user), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end it "does not create ssh key without title" do post api("/user/keys", user), key: "somekey" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1279,7 +1279,7 @@ describe API::Users do expect do delete api("/user/keys/#{key.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.keys.count}.by(-1) end @@ -1290,7 +1290,7 @@ describe API::Users do it "returns 404 if key ID not found" do delete api("/user/keys/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end @@ -1298,13 +1298,13 @@ describe API::Users do user.keys << key user.save delete api("/user/keys/#{key.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns a 404 for invalid ID" do delete api("/users/keys/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1313,7 +1313,7 @@ describe API::Users do it 'returns authentication error' do get api('/user/gpg_keys') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1324,7 +1324,7 @@ describe API::Users do get api('/user/gpg_keys', 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['key']).to eq(gpg_key.key) @@ -1346,14 +1346,14 @@ describe API::Users do get api("/user/gpg_keys/#{gpg_key.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['key']).to eq(gpg_key.key) end it 'returns 404 Not Found within invalid ID' do get api('/user/gpg_keys/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -1363,14 +1363,14 @@ describe API::Users do get api("/user/gpg_keys/#{gpg_key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end it 'returns 404 for invalid ID' do get api('/users/gpg_keys/ASDF', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'scopes' do @@ -1387,20 +1387,20 @@ describe API::Users do expect do post api('/user/gpg_keys', user), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { user.gpg_keys.count }.by(1) end it 'returns a 401 error if unauthorized' do post api('/user/gpg_keys'), key: 'some key' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'does not create GPG key without key' do post api('/user/gpg_keys', user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end end @@ -1413,14 +1413,14 @@ describe API::Users do expect do post api("/user/gpg_keys/#{gpg_key.id}/revoke", user) - expect(response).to have_http_status(:accepted) + expect(response).to have_gitlab_http_status(:accepted) end.to change { user.gpg_keys.count}.by(-1) end it 'returns 404 if key ID not found' do post api('/user/gpg_keys/42/revoke', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -1430,13 +1430,13 @@ describe API::Users do post api("/user/gpg_keys/#{gpg_key.id}/revoke") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 404 for invalid ID' do post api('/users/gpg_keys/ASDF/revoke', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1448,14 +1448,14 @@ describe API::Users do expect do delete api("/user/gpg_keys/#{gpg_key.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.gpg_keys.count}.by(-1) end it 'returns 404 if key ID not found' do delete api('/user/gpg_keys/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -1465,13 +1465,13 @@ describe API::Users do delete api("/user/gpg_keys/#{gpg_key.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 404 for invalid ID' do delete api('/users/gpg_keys/ASDF', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1479,7 +1479,7 @@ describe API::Users do context "when unauthenticated" do it "returns authentication error" do get api("/user/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1490,7 +1490,7 @@ describe API::Users do get api("/user/emails", 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["email"]).to eq(email.email) @@ -1510,13 +1510,13 @@ describe API::Users do user.emails << email user.save get api("/user/emails/#{email.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["email"]).to eq(email.email) end it "returns 404 Not Found within invalid ID" do get api("/user/emails/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end @@ -1525,14 +1525,14 @@ describe API::Users do user.save admin get api("/user/emails/#{email.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end it "returns 404 for invalid ID" do get api("/users/emails/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "scopes" do @@ -1549,18 +1549,18 @@ describe API::Users do expect do post api("/user/emails", user), email_attrs end.to change { user.emails.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it "returns a 401 error if unauthorized" do post api("/user/emails"), email: 'some email' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "does not create email with invalid email" do post api("/user/emails", user), {} - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('email is missing') end end @@ -1573,7 +1573,7 @@ describe API::Users do expect do delete api("/user/emails/#{email.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.emails.count}.by(-1) end @@ -1584,7 +1584,7 @@ describe API::Users do it "returns 404 if email ID not found" do delete api("/user/emails/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end @@ -1592,13 +1592,13 @@ describe API::Users do user.emails << email user.save delete api("/user/emails/#{email.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns 400 for invalid ID" do delete api("/user/emails/ASDF", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1609,25 +1609,25 @@ describe API::Users do it 'blocks existing user' do post api("/users/#{user.id}/block", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(user.reload.state).to eq('blocked') end it 'does not re-block ldap blocked users' do post api("/users/#{ldap_blocked_user.id}/block", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do post api("/users/#{user.id}/block", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do post api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end @@ -1641,38 +1641,38 @@ describe API::Users do it 'unblocks existing user' do post api("/users/#{user.id}/unblock", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(user.reload.state).to eq('active') end it 'unblocks a blocked user' do post api("/users/#{blocked_user.id}/unblock", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(blocked_user.reload.state).to eq('active') end it 'does not unblock ldap blocked users' do post api("/users/#{ldap_blocked_user.id}/unblock", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do post api("/users/#{user.id}/unblock", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do post api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do post api("/users/ASDF/block", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1684,7 +1684,7 @@ describe API::Users do it 'has no permission' do get api("/user/activities", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1729,21 +1729,21 @@ describe API::Users do it 'returns a 404 error if user not found' do get api("/users/#{not_existing_user_id}/impersonation_tokens", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns a 403 error when authenticated as normal user' do get api("/users/#{not_existing_user_id}/impersonation_tokens", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end it 'returns an array of all impersonated tokens' do get api("/users/#{user.id}/impersonation_tokens", admin) - 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) @@ -1752,7 +1752,7 @@ describe API::Users do it 'returns an array of active impersonation tokens if state active' do get api("/users/#{user.id}/impersonation_tokens?state=active", admin) - 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) @@ -1762,7 +1762,7 @@ describe API::Users do it 'returns an array of inactive personal access tokens if active is set to false' do get api("/users/#{user.id}/impersonation_tokens?state=inactive", admin) - 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).to all(include('active' => false)) @@ -1778,7 +1778,7 @@ describe API::Users do it 'returns validation error if impersonation token misses some attributes' do post api("/users/#{user.id}/impersonation_tokens", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end @@ -1787,7 +1787,7 @@ describe API::Users do name: name, expires_at: expires_at - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -1796,7 +1796,7 @@ describe API::Users do name: name, expires_at: expires_at - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end @@ -1807,7 +1807,7 @@ describe API::Users do scopes: scopes, impersonation: impersonation - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(name) expect(json_response['scopes']).to eq(scopes) expect(json_response['expires_at']).to eq(expires_at) @@ -1827,35 +1827,35 @@ describe API::Users do it 'returns 404 error if user not found' do get api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns a 404 error if impersonation token not found' do get api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 404 error if token is not impersonation token' do get api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 403 error when authenticated as normal user' do get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end it 'returns a personal access token' do get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['token']).to be_present expect(json_response['impersonation']).to be_truthy end @@ -1868,28 +1868,28 @@ describe API::Users do it 'returns a 404 error if user not found' do delete api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns a 404 error if impersonation token not found' do delete api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 404 error if token is not impersonation token' do delete api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 403 error when authenticated as normal user' do delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end @@ -1900,7 +1900,7 @@ describe API::Users do it 'revokes a impersonation token' do delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(impersonation_token.revoked).to be_falsey expect(impersonation_token.reload.revoked).to be_truthy end diff --git a/spec/requests/api/v3/award_emoji_spec.rb b/spec/requests/api/v3/award_emoji_spec.rb index 36d793f505d..0cd8b70007f 100644 --- a/spec/requests/api/v3/award_emoji_spec.rb +++ b/spec/requests/api/v3/award_emoji_spec.rb @@ -16,7 +16,7 @@ describe API::V3::AwardEmoji do it "returns an array of award_emoji" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", 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.first['name']).to eq(award_emoji.name) end @@ -24,7 +24,7 @@ describe API::V3::AwardEmoji do it "returns a 404 error when issue id not found" do get v3_api("/projects/#{project.id}/issues/12345/award_emoji", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -32,7 +32,7 @@ describe API::V3::AwardEmoji do it "returns an array of award_emoji" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", 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['name']).to eq(downvote.name) @@ -46,7 +46,7 @@ describe API::V3::AwardEmoji do it 'returns the awarded emoji' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", 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.first['name']).to eq(award.name) end @@ -58,7 +58,7 @@ describe API::V3::AwardEmoji do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -69,7 +69,7 @@ describe API::V3::AwardEmoji do it 'returns an array of award emoji' do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", 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.first['name']).to eq(rocket.name) end @@ -80,7 +80,7 @@ describe API::V3::AwardEmoji do it "returns the award emoji" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award_emoji.name) expect(json_response['awardable_id']).to eq(issue.id) expect(json_response['awardable_type']).to eq("Issue") @@ -89,7 +89,7 @@ describe API::V3::AwardEmoji do it "returns a 404 error if the award is not found" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -97,7 +97,7 @@ describe API::V3::AwardEmoji do it 'returns the award emoji' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(downvote.name) expect(json_response['awardable_id']).to eq(merge_request.id) expect(json_response['awardable_type']).to eq("MergeRequest") @@ -111,7 +111,7 @@ describe API::V3::AwardEmoji do it 'returns the awarded emoji' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award.name) expect(json_response['awardable_id']).to eq(snippet.id) expect(json_response['awardable_type']).to eq("Snippet") @@ -124,7 +124,7 @@ describe API::V3::AwardEmoji do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -135,7 +135,7 @@ describe API::V3::AwardEmoji do it 'returns an award emoji' do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to be_an Array expect(json_response['name']).to eq(rocket.name) end @@ -148,7 +148,7 @@ describe API::V3::AwardEmoji do it "creates a new award emoji" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -156,19 +156,19 @@ describe API::V3::AwardEmoji do it "returns a 400 bad request error if the name is not given" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if the user is not authenticated" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji"), name: 'thumbsup' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns a 404 error if the user authored issue" do post v3_api("/projects/#{project.id}/issues/#{issue2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -182,7 +182,7 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'thumbsup' post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -194,7 +194,7 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -209,14 +209,14 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket' end.to change { note.award_emoji.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['user']['username']).to eq(user.username) end it "it returns 404 error when user authored note" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -230,7 +230,7 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket' post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -242,14 +242,14 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { issue.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when the award emoji can not be found' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -258,14 +258,14 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { merge_request.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -277,7 +277,7 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { snippet.award_emoji.count }.from(1).to(0) end end @@ -290,7 +290,7 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { note.award_emoji.count }.from(1).to(0) end end diff --git a/spec/requests/api/v3/boards_spec.rb b/spec/requests/api/v3/boards_spec.rb index ea2627142bf..14409d25544 100644 --- a/spec/requests/api/v3/boards_spec.rb +++ b/spec/requests/api/v3/boards_spec.rb @@ -38,7 +38,7 @@ describe API::V3::Boards do it "returns authentication error" do get v3_api(base_url) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -46,7 +46,7 @@ describe API::V3::Boards do it "returns the project issue board" do get v3_api(base_url, 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.length).to eq(1) expect(json_response.first['id']).to eq(board.id) @@ -63,7 +63,7 @@ describe API::V3::Boards do it 'returns issue board lists' do get v3_api(base_url, 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.length).to eq(2) expect(json_response.first['label']['name']).to eq(dev_label.title) @@ -72,7 +72,7 @@ describe API::V3::Boards do it 'returns 404 if board not found' do get v3_api("/projects/#{project.id}/boards/22343/lists", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -82,19 +82,19 @@ describe API::V3::Boards do it "rejects a non member from deleting a list" do delete v3_api("#{base_url}/#{dev_list.id}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a user with guest role from deleting a list" do delete v3_api("#{base_url}/#{dev_list.id}", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 404 error if list id not found" do delete v3_api("#{base_url}/44444", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when the user is project owner" do @@ -107,7 +107,7 @@ describe API::V3::Boards do it "deletes the list if an admin requests it" do delete v3_api("#{base_url}/#{dev_list.id}", owner) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/requests/api/v3/branches_spec.rb b/spec/requests/api/v3/branches_spec.rb index 9cd11a67712..1e038595a1f 100644 --- a/spec/requests/api/v3/branches_spec.rb +++ b/spec/requests/api/v3/branches_spec.rb @@ -17,7 +17,7 @@ describe API::V3::Branches do get v3_api("/projects/#{project.id}/repository/branches", user), per_page: 100 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array branch_names = json_response.map { |x| x['name'] } expect(branch_names).to match_array(project.repository.branch_names) @@ -32,20 +32,20 @@ describe API::V3::Branches do it "removes branch" do delete v3_api("/projects/#{project.id}/repository/branches/#{branch_name}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['branch_name']).to eq(branch_name) end it "removes a branch with dots in the branch name" do delete v3_api("/projects/#{project.id}/repository/branches/with.1.2.3", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['branch_name']).to eq("with.1.2.3") end it 'returns 404 if branch not exists' do delete v3_api("/projects/#{project.id}/repository/branches/foobar", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -57,13 +57,13 @@ describe API::V3::Branches do it 'returns 200' do delete v3_api("/projects/#{project.id}/repository/merged_branches", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 403 error if guest' do delete v3_api("/projects/#{project.id}/repository/merged_branches", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -73,7 +73,7 @@ describe API::V3::Branches do branch_name: 'feature1', ref: branch_sha - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('feature1') expect(json_response['commit']['id']).to eq(branch_sha) @@ -83,14 +83,14 @@ describe API::V3::Branches do post v3_api("/projects/#{project.id}/repository/branches", user2), branch_name: branch_name, ref: branch_sha - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns 400 if branch name is invalid' do post v3_api("/projects/#{project.id}/repository/branches", user), branch_name: 'new design', ref: branch_sha - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch name is invalid') end @@ -98,13 +98,13 @@ describe API::V3::Branches do post v3_api("/projects/#{project.id}/repository/branches", user), branch_name: 'new_design1', ref: branch_sha - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) post v3_api("/projects/#{project.id}/repository/branches", user), branch_name: 'new_design1', ref: branch_sha - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch already exists') end @@ -113,7 +113,7 @@ describe API::V3::Branches do branch_name: 'new_design3', ref: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Invalid reference name') end end diff --git a/spec/requests/api/v3/broadcast_messages_spec.rb b/spec/requests/api/v3/broadcast_messages_spec.rb index d04b1c72004..d9641011491 100644 --- a/spec/requests/api/v3/broadcast_messages_spec.rb +++ b/spec/requests/api/v3/broadcast_messages_spec.rb @@ -11,21 +11,21 @@ describe API::V3::BroadcastMessages do delete v3_api("/broadcast_messages/#{message.id}"), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do delete v3_api("/broadcast_messages/#{message.id}", user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'deletes the broadcast message for admins' do expect do delete v3_api("/broadcast_messages/#{message.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { BroadcastMessage.count }.by(-1) end end diff --git a/spec/requests/api/v3/builds_spec.rb b/spec/requests/api/v3/builds_spec.rb index 0a2ff1058e3..3f58b7ef384 100644 --- a/spec/requests/api/v3/builds_spec.rb +++ b/spec/requests/api/v3/builds_spec.rb @@ -21,7 +21,7 @@ describe API::V3::Builds do context 'authorized user' do it 'returns project builds' do - 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 end @@ -44,7 +44,7 @@ describe API::V3::Builds do let(:query) { 'scope=pending' } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -54,7 +54,7 @@ describe API::V3::Builds do let(:json_build) { json_response.first } it 'return builds with status skipped' do - 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 1 expect(json_build['status']).to eq 'skipped' @@ -65,7 +65,7 @@ describe API::V3::Builds do let(:query) { 'scope[0]=pending&scope[1]=running' } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -73,7 +73,7 @@ describe API::V3::Builds do context 'respond 400 when scope contains invalid state' do let(:query) { 'scope[0]=pending&scope[1]=unknown_status' } - it { expect(response).to have_http_status(400) } + it { expect(response).to have_gitlab_http_status(400) } end end @@ -81,7 +81,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return project builds' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -93,7 +93,7 @@ describe API::V3::Builds do end it 'responds with 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -109,7 +109,7 @@ describe API::V3::Builds do end it 'returns project jobs for specific commit' do - 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 @@ -132,7 +132,7 @@ describe API::V3::Builds do end it 'returns an empty array' do - 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).to be_empty end @@ -148,7 +148,7 @@ describe API::V3::Builds do end it 'does not return project jobs' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response.except('message')).to be_empty end end @@ -162,7 +162,7 @@ describe API::V3::Builds do context 'authorized user' do it 'returns specific job data' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('test') end @@ -180,7 +180,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return specific job data' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -200,7 +200,7 @@ describe API::V3::Builds do end it 'returns specific job artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers).to include(download_headers) expect(response.body).to match_file(build.artifacts_file.file.file) end @@ -210,13 +210,13 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return specific job artifacts' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end it 'does not return job artifacts if not uploaded' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -240,7 +240,7 @@ describe API::V3::Builds do end it 'gives 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -252,13 +252,13 @@ describe API::V3::Builds do end it 'gives 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'non-existing job' do shared_examples 'not found' do - it { expect(response).to have_http_status(:not_found) } + it { expect(response).to have_gitlab_http_status(:not_found) } end context 'has no such ref' do @@ -286,7 +286,7 @@ describe API::V3::Builds do "attachment; filename=#{build.artifacts_file.filename}" } end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } it { expect(response.headers).to include(download_headers) } end @@ -327,7 +327,7 @@ describe API::V3::Builds do context 'authorized user' do it 'returns specific job trace' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq(build.trace.raw) end end @@ -336,7 +336,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return specific job trace' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -349,7 +349,7 @@ describe API::V3::Builds do context 'authorized user' do context 'user with :update_build persmission' do it 'cancels running or pending job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') end end @@ -358,7 +358,7 @@ describe API::V3::Builds do let(:api_user) { reporter.user } it 'does not cancel job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -367,7 +367,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not cancel job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -382,7 +382,7 @@ describe API::V3::Builds do context 'authorized user' do context 'user with :update_build permission' do it 'retries non-running job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') expect(json_response['status']).to eq('pending') end @@ -392,7 +392,7 @@ describe API::V3::Builds do let(:api_user) { reporter.user } it 'does not retry job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -401,7 +401,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not retry job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -471,7 +471,7 @@ describe API::V3::Builds do let(:build) { create(:ci_build, :manual, project: project, pipeline: pipeline) } it 'plays the job' do - expect(response).to have_http_status 200 + expect(response).to have_gitlab_http_status 200 expect(json_response['user']['id']).to eq(user.id) expect(json_response['id']).to eq(build.id) end @@ -479,7 +479,7 @@ describe API::V3::Builds do context 'on a non-playable job' do it 'returns a status code 400, Bad Request' do - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 expect(response.body).to match("Unplayable Job") end end diff --git a/spec/requests/api/v3/commits_spec.rb b/spec/requests/api/v3/commits_spec.rb index 6d0ca33a6fa..d31c94ddd2c 100644 --- a/spec/requests/api/v3/commits_spec.rb +++ b/spec/requests/api/v3/commits_spec.rb @@ -19,7 +19,7 @@ describe API::V3::Commits do commit = project.repository.commit get v3_api("/projects/#{project.id}/repository/commits", 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.first['id']).to eq(commit.id) expect(json_response.first['committer_name']).to eq(commit.committer_name) @@ -30,7 +30,7 @@ describe API::V3::Commits do context "unauthorized user" do it "does not return project commits" do get v3_api("/projects/#{project.id}/repository/commits") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -69,7 +69,7 @@ describe API::V3::Commits do it "returns an invalid parameter error message" do get v3_api("/projects/#{project.id}/repository/commits?since=invalid-date", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('since is invalid') end end @@ -92,13 +92,13 @@ describe API::V3::Commits do it 'returns a 403 unauthorized for user without permissions' do post v3_api(url, user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns a 400 bad request if no params are given' do post v3_api(url, user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end describe 'create' do @@ -133,7 +133,7 @@ describe API::V3::Commits do it 'a new file in project repo' do post v3_api(url, user), valid_c_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) expect(json_response['committer_name']).to eq(user.name) expect(json_response['committer_email']).to eq(user.email) @@ -142,7 +142,7 @@ describe API::V3::Commits do it 'returns a 400 bad request if file exists' do post v3_api(url, user), invalid_c_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'with project path containing a dot in URL' do @@ -152,7 +152,7 @@ describe API::V3::Commits do it 'a new file in project repo' do post v3_api(url, user), valid_c_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -187,14 +187,14 @@ describe API::V3::Commits do it 'an existing file in project repo' do post v3_api(url, user), valid_d_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post v3_api(url, user), invalid_d_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -232,14 +232,14 @@ describe API::V3::Commits do it 'an existing file in project repo' do post v3_api(url, user), valid_m_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post v3_api(url, user), invalid_m_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -275,14 +275,14 @@ describe API::V3::Commits do it 'an existing file in project repo' do post v3_api(url, user), valid_u_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post v3_api(url, user), invalid_u_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -348,14 +348,14 @@ describe API::V3::Commits do it 'are commited as one in project repo' do post v3_api(url, user), valid_mo_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'return a 400 bad request if there are any issues' do post v3_api(url, user), invalid_mo_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -365,7 +365,7 @@ describe API::V3::Commits do it "returns a commit by sha" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(project.repository.commit.id) expect(json_response['title']).to eq(project.repository.commit.title) expect(json_response['stats']['additions']).to eq(project.repository.commit.stats.additions) @@ -375,13 +375,13 @@ describe API::V3::Commits do it "returns a 404 error if not found" do get v3_api("/projects/#{project.id}/repository/commits/invalid_sha", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns nil for commit without CI" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to be_nil end @@ -391,7 +391,7 @@ describe API::V3::Commits do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq(pipeline.status) end @@ -400,7 +400,7 @@ describe API::V3::Commits do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq("created") end end @@ -408,7 +408,7 @@ describe API::V3::Commits do context "unauthorized user" do it "does not return the selected commit" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -419,7 +419,7 @@ describe API::V3::Commits do it "returns the diff of the selected commit" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", 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.length).to be >= 1 @@ -428,14 +428,14 @@ describe API::V3::Commits do it "returns a 404 error if invalid commit" do get v3_api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context "unauthorized user" do it "does not return the diff of the selected commit" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -444,7 +444,7 @@ describe API::V3::Commits do context 'authorized user' do it 'returns merge_request comments' do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", 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.length).to eq(2) expect(json_response.first['note']).to eq('a comment on a commit') @@ -453,14 +453,14 @@ describe API::V3::Commits do it 'returns a 404 error if merge_request_id not found' do get v3_api("/projects/#{project.id}/repository/commits/1234ab/comments", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context 'unauthorized user' do it 'does not return the diff of the selected commit' do get v3_api("/projects/#{project.id}/repository/commits/1234ab/comments") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -472,7 +472,7 @@ describe API::V3::Commits do it 'cherry picks a commit' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user), branch: 'master' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(master_pickable_commit.title) expect(json_response['message']).to eq(master_pickable_commit.cherry_pick_message(user)) expect(json_response['author_name']).to eq(master_pickable_commit.author_name) @@ -482,7 +482,7 @@ describe API::V3::Commits do it 'returns 400 if commit is already included in the target branch' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user), branch: 'markdown' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to include('Sorry, we cannot cherry-pick this commit automatically.') end @@ -492,35 +492,35 @@ describe API::V3::Commits do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user2), branch: protected_branch.name - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('You are not allowed to push into this branch') end it 'returns 400 for missing parameters' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('branch is missing') end it 'returns 404 if commit is not found' do post v3_api("/projects/#{project.id}/repository/commits/abcd0123/cherry_pick", user), branch: 'master' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Commit Not Found') end it 'returns 404 if branch is not found' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user), branch: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Branch Not Found') end it 'returns 400 for missing parameters' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('branch is missing') end end @@ -529,7 +529,7 @@ describe API::V3::Commits do it 'does not cherry pick the commit' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick"), branch: 'master' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -538,7 +538,7 @@ describe API::V3::Commits do context 'authorized user' do it 'returns comment' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['note']).to eq('My comment') expect(json_response['path']).to be_nil expect(json_response['line']).to be_nil @@ -548,7 +548,7 @@ describe API::V3::Commits do it 'returns the inline comment' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 1, line_type: 'new' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['note']).to eq('My comment') expect(json_response['path']).to eq(project.repository.commit.raw_diffs.first.new_path) expect(json_response['line']).to eq(1) @@ -557,19 +557,19 @@ describe API::V3::Commits do it 'returns 400 if note is missing' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 404 if note is attached to non existent commit' do post v3_api("/projects/#{project.id}/repository/commits/1234ab/comments", user), note: 'My comment' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context 'unauthorized user' do it 'does not return the diff of the selected commit' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/v3/deploy_keys_spec.rb b/spec/requests/api/v3/deploy_keys_spec.rb index 2affd0cfa51..785bc1eb4ba 100644 --- a/spec/requests/api/v3/deploy_keys_spec.rb +++ b/spec/requests/api/v3/deploy_keys_spec.rb @@ -46,7 +46,7 @@ describe API::V3::DeployKeys do it 'should return array of ssh keys' do get v3_api("/projects/#{project.id}/#{path}", admin) - 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.first['title']).to eq(deploy_key.title) end @@ -56,14 +56,14 @@ describe API::V3::DeployKeys do it 'should return a single key' do get v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(deploy_key.title) end it 'should return 404 Not Found with invalid ID' do get v3_api("/projects/#{project.id}/#{path}/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -71,14 +71,14 @@ describe API::V3::DeployKeys do it 'should not create an invalid ssh key' do post v3_api("/projects/#{project.id}/#{path}", admin), { title: 'invalid key' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'should not create a key without title' do post v3_api("/projects/#{project.id}/#{path}", admin), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end @@ -95,7 +95,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project.id}/#{path}", admin), { key: deploy_key.key, title: deploy_key.title } end.not_to change { project.deploy_keys.count } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'joins an existing ssh key to a new project' do @@ -103,7 +103,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project2.id}/#{path}", admin), { key: deploy_key.key, title: deploy_key.title } end.to change { project2.deploy_keys.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'accepts can_push parameter' do @@ -111,7 +111,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project.id}/#{path}", admin), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['can_push']).to eq(true) end end @@ -128,7 +128,7 @@ describe API::V3::DeployKeys do it 'should return 404 Not Found with invalid ID' do delete v3_api("/projects/#{project.id}/#{path}/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -141,7 +141,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project2.id}/#{path}/#{deploy_key.id}/enable", admin) end.to change { project2.deploy_keys.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(deploy_key.id) end end @@ -150,7 +150,7 @@ describe API::V3::DeployKeys do it 'should return a 404 error' do post v3_api("/projects/#{project2.id}/#{path}/#{deploy_key.id}/enable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -162,7 +162,7 @@ describe API::V3::DeployKeys do delete v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}/disable", admin) end.to change { project.deploy_keys.count }.from(1).to(0) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(deploy_key.id) end end @@ -171,7 +171,7 @@ describe API::V3::DeployKeys do it 'should return a 404 error' do delete v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}/disable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/deployments_spec.rb b/spec/requests/api/v3/deployments_spec.rb index 0389a264781..90eabda4dac 100644 --- a/spec/requests/api/v3/deployments_spec.rb +++ b/spec/requests/api/v3/deployments_spec.rb @@ -30,7 +30,7 @@ describe API::V3::Deployments do it 'returns projects deployments' do get v3_api("/projects/#{project.id}/deployments", 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['iid']).to eq(deployment.iid) @@ -42,7 +42,7 @@ describe API::V3::Deployments do it 'returns a 404 status code' do get v3_api("/projects/#{project.id}/deployments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -52,7 +52,7 @@ describe API::V3::Deployments do it 'returns the projects deployment' do get v3_api("/projects/#{project.id}/deployments/#{deployment.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ expect(json_response['id']).to eq(deployment.id) end @@ -62,7 +62,7 @@ describe API::V3::Deployments do it 'returns a 404 status code' do get v3_api("/projects/#{project.id}/deployments/#{deployment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/environments_spec.rb b/spec/requests/api/v3/environments_spec.rb index 39264e819a3..937250b5219 100644 --- a/spec/requests/api/v3/environments_spec.rb +++ b/spec/requests/api/v3/environments_spec.rb @@ -36,7 +36,7 @@ describe API::V3::Environments do it 'returns project environments' do get v3_api("/projects/#{project.id}/environments", 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['name']).to eq(environment.name) @@ -50,7 +50,7 @@ describe API::V3::Environments do it 'returns a 404 status code' do get v3_api("/projects/#{project.id}/environments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -60,7 +60,7 @@ describe API::V3::Environments do it 'creates a environment with valid params' do post v3_api("/projects/#{project.id}/environments", user), name: "mepmep" - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('mepmep') expect(json_response['slug']).to eq('mepmep') expect(json_response['external']).to be nil @@ -69,19 +69,19 @@ describe API::V3::Environments do it 'requires name to be passed' do post v3_api("/projects/#{project.id}/environments", user), external_url: 'test.gitlab.com' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if environment already exists' do post v3_api("/projects/#{project.id}/environments", user), name: environment.name - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if slug is specified' do post v3_api("/projects/#{project.id}/environments", user), name: "foo", slug: "foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end end @@ -90,7 +90,7 @@ describe API::V3::Environments do it 'rejects the request' do post v3_api("/projects/#{project.id}/environments", non_member), name: 'gitlab.com' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 when the required params are missing' do @@ -105,7 +105,7 @@ describe API::V3::Environments do put v3_api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep', external_url: url - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -115,7 +115,7 @@ describe API::V3::Environments do api_url = v3_api("/projects/#{project.id}/environments/#{environment.id}", user) put api_url, slug: slug + "-foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end @@ -124,7 +124,7 @@ describe API::V3::Environments do put v3_api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -132,7 +132,7 @@ describe API::V3::Environments do it 'returns a 404 if the environment does not exist' do put v3_api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -141,13 +141,13 @@ describe API::V3::Environments do it 'returns a 200 for an existing environment' do delete v3_api("/projects/#{project.id}/environments/#{environment.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 404 for non existing id' do delete v3_api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -156,7 +156,7 @@ describe API::V3::Environments do it 'rejects the request' do delete v3_api("/projects/#{project.id}/environments/#{environment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/files_spec.rb b/spec/requests/api/v3/files_spec.rb index dc7f0eefd16..5500c1cf770 100644 --- a/spec/requests/api/v3/files_spec.rb +++ b/spec/requests/api/v3/files_spec.rb @@ -36,7 +36,7 @@ describe API::V3::Files do it "returns file info" do get v3_api(route, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) expect(json_response['file_name']).to eq('popen.rb') expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') @@ -112,7 +112,7 @@ describe API::V3::Files do it "creates a new file in project repo" do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['file_path']).to eq('newfile.rb') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -122,7 +122,7 @@ describe API::V3::Files do it "returns a 400 bad request if no params given" do post v3_api("/projects/#{project.id}/repository/files", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if editor fails to create file" do @@ -131,7 +131,7 @@ describe API::V3::Files do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -140,7 +140,7 @@ describe API::V3::Files do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -153,7 +153,7 @@ describe API::V3::Files do it "creates a new file in project repo" do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['file_path']).to eq('newfile.rb') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -175,7 +175,7 @@ describe API::V3::Files do it "updates existing file in project repo" do put v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -185,7 +185,7 @@ describe API::V3::Files do it "returns a 400 bad request if no params given" do put v3_api("/projects/#{project.id}/repository/files", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -194,7 +194,7 @@ describe API::V3::Files do put v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -214,7 +214,7 @@ describe API::V3::Files do it "deletes existing file in project repo" do delete v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -224,7 +224,7 @@ describe API::V3::Files do it "returns a 400 bad request if no params given" do delete v3_api("/projects/#{project.id}/repository/files", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if fails to delete file" do @@ -232,7 +232,7 @@ describe API::V3::Files do delete v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -241,7 +241,7 @@ describe API::V3::Files do delete v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -274,7 +274,7 @@ describe API::V3::Files do it "remains unchanged" do get v3_api("/projects/#{project.id}/repository/files", user), get_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) expect(json_response['file_name']).to eq(file_path) expect(json_response['content']).to eq(put_params[:content]) diff --git a/spec/requests/api/v3/groups_spec.rb b/spec/requests/api/v3/groups_spec.rb index 778fcc73c30..498cb42fad1 100644 --- a/spec/requests/api/v3/groups_spec.rb +++ b/spec/requests/api/v3/groups_spec.rb @@ -23,7 +23,7 @@ describe API::V3::Groups do it "returns authentication error" do get v3_api("/groups") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -31,7 +31,7 @@ describe API::V3::Groups do it "normal user: returns an array of groups of user1" do get v3_api("/groups", user1) - 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(1) expect(json_response) @@ -41,7 +41,7 @@ describe API::V3::Groups do it "does not include statistics" do get v3_api("/groups", user1), statistics: true - 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.first).not_to include 'statistics' end @@ -51,7 +51,7 @@ describe API::V3::Groups do it "admin: returns an array of all groups" do get v3_api("/groups", admin) - 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) end @@ -59,7 +59,7 @@ describe API::V3::Groups do it "does not include statistics by default" do get v3_api("/groups", admin) - 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.first).not_to include('statistics') end @@ -76,7 +76,7 @@ describe API::V3::Groups do get v3_api("/groups", admin), statistics: true - 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) .to satisfy_one { |group| group['statistics'] == attributes } @@ -87,7 +87,7 @@ describe API::V3::Groups do it "returns all groups excluding skipped groups" do get v3_api("/groups", admin), skip_groups: [group2.id] - 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(1) end @@ -101,7 +101,7 @@ describe API::V3::Groups do get v3_api("/groups", user1), all_available: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to contain_exactly(public_group.name, group1.name) end @@ -118,7 +118,7 @@ describe API::V3::Groups do it "sorts by name ascending by default" do get v3_api("/groups", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to eq([group3.name, group1.name]) end @@ -126,7 +126,7 @@ describe API::V3::Groups do it "sorts in descending order when passed" do get v3_api("/groups", user1), sort: "desc" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to eq([group1.name, group3.name]) end @@ -134,7 +134,7 @@ describe API::V3::Groups do it "sorts by the order_by param" do get v3_api("/groups", user1), order_by: "path" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to eq([group1.name, group3.name]) end @@ -146,7 +146,7 @@ describe API::V3::Groups do it 'returns authentication error' do get v3_api('/groups/owned') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -154,7 +154,7 @@ describe API::V3::Groups do it 'returns an array of groups the user owns' do get v3_api('/groups/owned', user2) - 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['name']).to eq(group2.name) @@ -170,7 +170,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(group1.id) expect(json_response['name']).to eq(group1.name) expect(json_response['path']).to eq(group1.path) @@ -192,13 +192,13 @@ describe API::V3::Groups do it "does not return a non existing group" do get v3_api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get v3_api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -206,14 +206,14 @@ describe API::V3::Groups do it "returns any existing group" do get v3_api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group2.name) end it "does not return a non existing group" do get v3_api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -221,20 +221,20 @@ describe API::V3::Groups do it 'returns any existing group' do get v3_api("/groups/#{group1.path}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group1.name) end it 'does not return a non existing group' do get v3_api('/groups/unknown', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get v3_api("/groups/#{group2.path}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -246,7 +246,7 @@ describe API::V3::Groups do it 'updates the group' do put v3_api("/groups/#{group1.id}", user1), name: new_group_name, request_access_enabled: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) expect(json_response['request_access_enabled']).to eq(true) end @@ -254,7 +254,7 @@ describe API::V3::Groups do it 'returns 404 for a non existing group' do put v3_api('/groups/1328', user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -262,7 +262,7 @@ describe API::V3::Groups do it 'updates the group' do put v3_api("/groups/#{group1.id}", admin), name: new_group_name - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) end end @@ -271,7 +271,7 @@ describe API::V3::Groups do it 'does not updates the group' do put v3_api("/groups/#{group1.id}", user2), name: new_group_name - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -279,7 +279,7 @@ describe API::V3::Groups do it 'returns 404 when trying to update the group' do put v3_api("/groups/#{group2.id}", user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -289,7 +289,7 @@ describe API::V3::Groups do it "returns the group's projects" do get v3_api("/groups/#{group1.id}/projects", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) @@ -299,7 +299,7 @@ describe API::V3::Groups do it "returns the group's projects with simple representation" do get v3_api("/groups/#{group1.id}/projects", user1), simple: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) @@ -311,7 +311,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}/projects", user1), visibility: 'public' - 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(1) expect(json_response.first['name']).to eq(public_project.name) @@ -320,13 +320,13 @@ describe API::V3::Groups do it "does not return a non existing group" do get v3_api("/groups/1328/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get v3_api("/groups/#{group2.id}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "only returns projects to which user has access" do @@ -334,7 +334,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}/projects", user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project3.name) end @@ -344,7 +344,7 @@ describe API::V3::Groups do get v3_api("/groups/#{project2.group.id}/projects", user3), owned: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) end @@ -354,7 +354,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}/projects", user1), starred: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project1.name) end @@ -364,7 +364,7 @@ describe API::V3::Groups do it "returns any existing group" do get v3_api("/groups/#{group2.id}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) end @@ -372,7 +372,7 @@ describe API::V3::Groups do it "does not return a non existing group" do get v3_api("/groups/1328/projects", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -380,7 +380,7 @@ describe API::V3::Groups do it 'returns any existing group' do get v3_api("/groups/#{group1.path}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) end @@ -388,13 +388,13 @@ describe API::V3::Groups do it 'does not return a non existing group' do get v3_api('/groups/unknown/projects', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get v3_api("/groups/#{group2.path}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -404,7 +404,7 @@ describe API::V3::Groups do it "does not create group" do post v3_api("/groups", user1), attributes_for(:group) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -414,7 +414,7 @@ describe API::V3::Groups do post v3_api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(group[:name]) expect(json_response["path"]).to eq(group[:path]) @@ -428,7 +428,7 @@ describe API::V3::Groups do post v3_api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["full_path"]).to eq("#{parent.path}/#{group[:path]}") expect(json_response["parent_id"]).to eq(parent.id) @@ -437,20 +437,20 @@ describe API::V3::Groups do it "does not create group, duplicate" do post v3_api("/groups", user3), { name: 'Duplicate Test', path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(response.message).to eq("Bad Request") end it "returns 400 bad request error if name not given" do post v3_api("/groups", user3), { path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 bad request error if path not given" do post v3_api("/groups", user3), { name: 'test' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -460,7 +460,7 @@ describe API::V3::Groups do it "removes group" do delete v3_api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "does not remove a group if not an owner" do @@ -469,19 +469,19 @@ describe API::V3::Groups do delete v3_api("/groups/#{group1.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "does not remove a non existing group" do delete v3_api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not remove a group not attached to user1" do delete v3_api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -489,13 +489,13 @@ describe API::V3::Groups do it "removes any existing group" do delete v3_api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "does not remove a non existing group" do delete v3_api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -513,7 +513,7 @@ describe API::V3::Groups do it "does not transfer project to group" do post v3_api("/groups/#{group1.id}/projects/#{project.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -521,7 +521,7 @@ describe API::V3::Groups do it "transfers project to group" do post v3_api("/groups/#{group1.id}/projects/#{project.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when using project path in URL' do @@ -529,7 +529,7 @@ describe API::V3::Groups do it "transfers project to group" do post v3_api("/groups/#{group1.id}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -537,7 +537,7 @@ describe API::V3::Groups do it "does not transfer project to group" do post v3_api("/groups/#{group1.id}/projects/nogroup%2Fnoproject", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -547,7 +547,7 @@ describe API::V3::Groups do it "transfers project to group" do post v3_api("/groups/#{group1.path}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -555,7 +555,7 @@ describe API::V3::Groups do it "does not transfer project to group" do post v3_api("/groups/noexist/projects/#{project_path}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb index 86768d7397a..39a47a62f16 100644 --- a/spec/requests/api/v3/issues_spec.rb +++ b/spec/requests/api/v3/issues_spec.rb @@ -59,7 +59,7 @@ describe API::V3::Issues, :mailer do it "returns authentication error" do get v3_api("/issues") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -67,7 +67,7 @@ describe API::V3::Issues, :mailer do it "returns an array of issues" do get v3_api("/issues", 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.first['title']).to eq(issue.title) expect(json_response.last).to have_key('web_url') @@ -76,7 +76,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of closed issues' do get v3_api('/issues?state=closed', 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.length).to eq(1) expect(json_response.first['id']).to eq(closed_issue.id) @@ -85,7 +85,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of opened issues' do get v3_api('/issues?state=opened', 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.length).to eq(1) expect(json_response.first['id']).to eq(issue.id) @@ -94,7 +94,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of all issues' do get v3_api('/issues?state=all', 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.length).to eq(2) expect(json_response.first['id']).to eq(issue.id) @@ -104,7 +104,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled issues' do get v3_api("/issues?labels=#{label.title}", 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.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -113,7 +113,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled issues when at least one label matches' do get v3_api("/issues?labels=#{label.title},foo,bar", 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.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -122,7 +122,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches labels' do get v3_api('/issues?labels=foo,bar', 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.length).to eq(0) end @@ -130,7 +130,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled issues matching given state' do get v3_api("/issues?labels=#{label.title}&state=opened", 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.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -140,7 +140,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches labels and state filters' do get v3_api("/issues?labels=#{label.title}&state=closed", 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.length).to eq(0) end @@ -148,7 +148,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches milestone' do get v3_api("/issues?milestone=#{empty_milestone.title}", 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.length).to eq(0) end @@ -156,7 +156,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if milestone does not exist' do get v3_api("/issues?milestone=foo", 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.length).to eq(0) end @@ -164,7 +164,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues in given milestone' do get v3_api("/issues?milestone=#{milestone.title}", 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.length).to eq(2) expect(json_response.first['id']).to eq(issue.id) @@ -175,7 +175,7 @@ describe API::V3::Issues, :mailer do get v3_api("/issues?milestone=#{milestone.title}", user), '&state=closed' - 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(1) expect(json_response.first['id']).to eq(closed_issue.id) @@ -184,7 +184,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues with no milestone' do get v3_api("/issues?milestone=#{no_milestone_title}", author) - 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(1) expect(json_response.first['id']).to eq(confidential_issue.id) @@ -195,7 +195,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -205,7 +205,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -215,7 +215,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -225,7 +225,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -233,7 +233,7 @@ describe API::V3::Issues, :mailer do it 'matches V3 response schema' do get v3_api('/issues', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v3/issues') end end @@ -285,7 +285,7 @@ describe API::V3::Issues, :mailer do it 'returns all group issues (including opened and closed)' do get v3_api(base_url, admin) - 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(3) end @@ -293,7 +293,7 @@ describe API::V3::Issues, :mailer do it 'returns group issues without confidential issues for non project members' do get v3_api("#{base_url}?state=opened", non_member) - 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(1) expect(json_response.first['title']).to eq(group_issue.title) @@ -302,7 +302,7 @@ describe API::V3::Issues, :mailer do it 'returns group confidential issues for author' do get v3_api("#{base_url}?state=opened", author) - 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) end @@ -310,7 +310,7 @@ describe API::V3::Issues, :mailer do it 'returns group confidential issues for assignee' do get v3_api("#{base_url}?state=opened", assignee) - 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) end @@ -318,7 +318,7 @@ describe API::V3::Issues, :mailer do it 'returns group issues with confidential issues for project members' do get v3_api("#{base_url}?state=opened", 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.length).to eq(2) end @@ -326,7 +326,7 @@ describe API::V3::Issues, :mailer do it 'returns group confidential issues for admin' do get v3_api("#{base_url}?state=opened", admin) - 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) end @@ -334,7 +334,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled group issues' do get v3_api("#{base_url}?labels=#{group_label.title}", 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.length).to eq(1) expect(json_response.first['labels']).to eq([group_label.title]) @@ -343,7 +343,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled group issues where all labels match' do get v3_api("#{base_url}?labels=#{group_label.title},foo,bar", 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.length).to eq(0) end @@ -351,7 +351,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no group issue matches labels' do get v3_api("#{base_url}?labels=foo,bar", 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.length).to eq(0) end @@ -359,7 +359,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches milestone' do get v3_api("#{base_url}?milestone=#{group_empty_milestone.title}", 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.length).to eq(0) end @@ -367,7 +367,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if milestone does not exist' do get v3_api("#{base_url}?milestone=foo", 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.length).to eq(0) end @@ -375,7 +375,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues in given milestone' do get v3_api("#{base_url}?state=opened&milestone=#{group_milestone.title}", 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.length).to eq(1) expect(json_response.first['id']).to eq(group_issue.id) @@ -385,7 +385,7 @@ describe API::V3::Issues, :mailer do get v3_api("#{base_url}?milestone=#{group_milestone.title}", user), '&state=closed' - 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(1) expect(json_response.first['id']).to eq(group_closed_issue.id) @@ -394,7 +394,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues with no milestone' do get v3_api("#{base_url}?milestone=#{no_milestone_title}", 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.length).to eq(1) expect(json_response.first['id']).to eq(group_confidential_issue.id) @@ -405,7 +405,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -415,7 +415,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -425,7 +425,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -435,7 +435,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -447,7 +447,7 @@ describe API::V3::Issues, :mailer do it 'returns 404 when project does not exist' do get v3_api('/projects/1000/issues', non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 on private projects for other users" do @@ -456,7 +456,7 @@ describe API::V3::Issues, :mailer do get v3_api("/projects/#{private_project.id}/issues", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns no issues when user has access to project but not issues' do @@ -471,7 +471,7 @@ describe API::V3::Issues, :mailer do it 'returns project issues without confidential issues for non project members' do get v3_api("#{base_url}/issues", non_member) - 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.first['title']).to eq(issue.title) @@ -480,7 +480,7 @@ describe API::V3::Issues, :mailer do it 'returns project issues without confidential issues for project members with guest role' do get v3_api("#{base_url}/issues", guest) - 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.first['title']).to eq(issue.title) @@ -489,7 +489,7 @@ describe API::V3::Issues, :mailer do it 'returns project confidential issues for author' do get v3_api("#{base_url}/issues", author) - 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(3) expect(json_response.first['title']).to eq(issue.title) @@ -498,7 +498,7 @@ describe API::V3::Issues, :mailer do it 'returns project confidential issues for assignee' do get v3_api("#{base_url}/issues", assignee) - 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(3) expect(json_response.first['title']).to eq(issue.title) @@ -507,7 +507,7 @@ describe API::V3::Issues, :mailer do it 'returns project issues with confidential issues for project members' do get v3_api("#{base_url}/issues", 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.length).to eq(3) expect(json_response.first['title']).to eq(issue.title) @@ -516,7 +516,7 @@ describe API::V3::Issues, :mailer do it 'returns project confidential issues for admin' do get v3_api("#{base_url}/issues", admin) - 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(3) expect(json_response.first['title']).to eq(issue.title) @@ -525,7 +525,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled project issues' do get v3_api("#{base_url}/issues?labels=#{label.title}", 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.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -534,7 +534,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled project issues where all labels match' do get v3_api("#{base_url}/issues?labels=#{label.title},foo,bar", 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.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -543,7 +543,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no project issue matches labels' do get v3_api("#{base_url}/issues?labels=foo,bar", 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.length).to eq(0) end @@ -551,7 +551,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches milestone' do get v3_api("#{base_url}/issues?milestone=#{empty_milestone.title}", 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.length).to eq(0) end @@ -559,7 +559,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if milestone does not exist' do get v3_api("#{base_url}/issues?milestone=foo", 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.length).to eq(0) end @@ -567,7 +567,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues in given milestone' do get v3_api("#{base_url}/issues?milestone=#{milestone.title}", 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.length).to eq(2) expect(json_response.first['id']).to eq(issue.id) @@ -578,7 +578,7 @@ describe API::V3::Issues, :mailer do get v3_api("#{base_url}/issues?milestone=#{milestone.title}", user), '&state=closed' - 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(1) expect(json_response.first['id']).to eq(closed_issue.id) @@ -587,7 +587,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues with no milestone' do get v3_api("#{base_url}/issues?milestone=#{no_milestone_title}", 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.length).to eq(1) expect(json_response.first['id']).to eq(confidential_issue.id) @@ -598,7 +598,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -608,7 +608,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -618,7 +618,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -628,7 +628,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -638,7 +638,7 @@ describe API::V3::Issues, :mailer do it 'exposes known attributes' do get v3_api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(issue.id) expect(json_response['iid']).to eq(issue.iid) expect(json_response['project_id']).to eq(issue.project.id) @@ -657,7 +657,7 @@ describe API::V3::Issues, :mailer do it "returns a project issue by id" do get v3_api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(issue.title) expect(json_response['iid']).to eq(issue.iid) end @@ -682,26 +682,26 @@ describe API::V3::Issues, :mailer do it "returns 404 if issue id not found" do get v3_api("/projects/#{project.id}/issues/54321", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'confidential issues' do it "returns 404 for non project members" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 for project members with guest role" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns confidential issue for project members" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -709,7 +709,7 @@ describe API::V3::Issues, :mailer do it "returns confidential issue for author" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", author) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -717,7 +717,7 @@ describe API::V3::Issues, :mailer do it "returns confidential issue for assignee" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", assignee) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -725,7 +725,7 @@ describe API::V3::Issues, :mailer do it "returns confidential issue for admin" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -737,7 +737,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', labels: 'label, label2', assignee_id: assignee.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['labels']).to eq(%w(label label2)) @@ -749,7 +749,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -758,7 +758,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'y' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -767,7 +767,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: false - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_falsy end @@ -776,7 +776,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end @@ -795,7 +795,7 @@ describe API::V3::Issues, :mailer do it "returns a 400 bad request if title not given" do post v3_api("/projects/#{project.id}/issues", user), labels: 'label, label2' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do @@ -815,7 +815,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -834,7 +834,7 @@ describe API::V3::Issues, :mailer do end 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 @@ -855,7 +855,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', due_date: due_date - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['due_date']).to eq(due_date) @@ -868,7 +868,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', labels: 'label, label2', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) end end @@ -899,7 +899,7 @@ describe API::V3::Issues, :mailer do it "does not create a new project issue" do expect { post v3_api("/projects/#{project.id}/issues", user), params }.not_to change(Issue, :count) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -917,7 +917,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", 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 @@ -925,7 +925,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/44444", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'allows special label names' do @@ -946,21 +946,21 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 403 for project members with guest role" do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "updates a confidential issue for project members" do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", 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 @@ -968,7 +968,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", author), 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 @@ -976,7 +976,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin), 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 @@ -984,7 +984,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), confidential: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_truthy end @@ -992,7 +992,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", user), confidential: false - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_falsy end @@ -1000,7 +1000,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", user), confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end end @@ -1021,7 +1021,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -1041,7 +1041,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([label.title]) end @@ -1060,7 +1060,7 @@ describe API::V3::Issues, :mailer do it 'removes all labels' do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: '' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([]) end @@ -1068,7 +1068,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: 'foo,bar' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'foo' expect(json_response['labels']).to include 'bar' end @@ -1092,7 +1092,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -1104,7 +1104,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: 'label2', state_event: "close" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label2' expect(json_response['state']).to eq "closed" end @@ -1112,7 +1112,7 @@ describe API::V3::Issues, :mailer do it 'reopens a project isssue' do put v3_api("/projects/#{project.id}/issues/#{closed_issue.id}", user), state_event: 'reopen' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq 'opened' end @@ -1122,7 +1122,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: 'label3', state_event: 'close', updated_at: update_time - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label3' expect(Time.parse(json_response['updated_at'])).to be_like_time(update_time) end @@ -1135,7 +1135,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), due_date: due_date - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to eq(due_date) end end @@ -1144,14 +1144,14 @@ describe API::V3::Issues, :mailer do it 'updates an issue with no assignee' do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), assignee_id: 0 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']).to eq(nil) end it 'updates an issue with assignee' do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), assignee_id: user2.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']['name']).to eq(user2.name) end end @@ -1160,13 +1160,13 @@ describe API::V3::Issues, :mailer do it "rejects a non member from deleting an issue" do delete v3_api("/projects/#{project.id}/issues/#{issue.id}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a developer from deleting an issue" do delete v3_api("/projects/#{project.id}/issues/#{issue.id}", author) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context "when the user is project owner" do @@ -1176,7 +1176,7 @@ describe API::V3::Issues, :mailer do it "deletes the issue if an admin requests it" do delete v3_api("/projects/#{project.id}/issues/#{issue.id}", owner) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq 'opened' end end @@ -1185,7 +1185,7 @@ describe API::V3::Issues, :mailer do it 'returns 404 when trying to move an issue' do delete v3_api("/projects/#{project.id}/issues/123", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1198,7 +1198,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project.id) end @@ -1207,7 +1207,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: project.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue to project it originates from!') end end @@ -1217,7 +1217,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: target_project2.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!') end end @@ -1226,7 +1226,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", admin), to_project_id: target_project2.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project2.id) end @@ -1235,7 +1235,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/123/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') end end @@ -1245,7 +1245,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/123/issues/#{issue.id}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end end @@ -1255,7 +1255,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: 123 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1264,26 +1264,26 @@ describe API::V3::Issues, :mailer do it 'subscribes to an issue' do post v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do post v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do post v3_api("/projects/#{project.id}/issues/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do post v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}/subscription", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1291,26 +1291,26 @@ describe API::V3::Issues, :mailer do it 'unsubscribes from an issue' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user2) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do delete v3_api("/projects/#{project.id}/issues/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do delete v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}/subscription", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/v3/labels_spec.rb b/spec/requests/api/v3/labels_spec.rb index 32f37a08024..1d31213d5ca 100644 --- a/spec/requests/api/v3/labels_spec.rb +++ b/spec/requests/api/v3/labels_spec.rb @@ -27,7 +27,7 @@ describe API::V3::Labels do get v3_api("/projects/#{project.id}/labels", 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(3) expect(json_response.first.keys).to match_array expected_keys @@ -71,7 +71,7 @@ describe API::V3::Labels do it "subscribes to the label" do post v3_api("/projects/#{project.id}/labels/#{label1.title}/subscription", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -81,7 +81,7 @@ describe API::V3::Labels do it "subscribes to the label" do post v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -93,7 +93,7 @@ describe API::V3::Labels do it "returns 304" do post v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -101,7 +101,7 @@ describe API::V3::Labels do it "returns 404 error" do post v3_api("/projects/#{project.id}/labels/1234/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -113,7 +113,7 @@ describe API::V3::Labels do it "unsubscribes from the label" do delete v3_api("/projects/#{project.id}/labels/#{label1.title}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -123,7 +123,7 @@ describe API::V3::Labels do it "unsubscribes from the label" do delete v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -135,7 +135,7 @@ describe API::V3::Labels do it "returns 304" do delete v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -143,7 +143,7 @@ describe API::V3::Labels do it "returns 404 error" do delete v3_api("/projects/#{project.id}/labels/1234/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -152,18 +152,18 @@ describe API::V3::Labels do it 'returns 200 for existing label' do delete v3_api("/projects/#{project.id}/labels", user), name: 'label1' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns 404 for non existing label' do delete v3_api("/projects/#{project.id}/labels", user), name: 'label2' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Label Not Found') end it 'returns 400 for wrong parameters' do delete v3_api("/projects/#{project.id}/labels", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end diff --git a/spec/requests/api/v3/members_spec.rb b/spec/requests/api/v3/members_spec.rb index bc918a8eb02..68be3d24c26 100644 --- a/spec/requests/api/v3/members_spec.rb +++ b/spec/requests/api/v3/members_spec.rb @@ -34,7 +34,7 @@ describe API::V3::Members do user = public_send(type) get v3_api("/#{source_type.pluralize}/#{source.id}/members", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) expect(json_response.map { |u| u['id'] }).to match_array [master.id, developer.id] end @@ -46,7 +46,7 @@ describe API::V3::Members do get v3_api("/#{source_type.pluralize}/#{source.id}/members", developer) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) expect(json_response.map { |u| u['id'] }).to match_array [master.id, developer.id] end @@ -54,7 +54,7 @@ describe API::V3::Members do it 'finds members with query string' do get v3_api("/#{source_type.pluralize}/#{source.id}/members", developer), query: master.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.count).to eq(1) expect(json_response.first['username']).to eq(master.username) end @@ -74,7 +74,7 @@ describe API::V3::Members do user = public_send(type) get v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # User attributes expect(json_response['id']).to eq(developer.id) expect(json_response['name']).to eq(developer.name) @@ -109,7 +109,7 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", user), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -122,7 +122,7 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(source.requesters.count).to eq(0) expect(json_response['id']).to eq(access_requester.id) @@ -135,7 +135,7 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: '2016-08-05' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(json_response['id']).to eq(stranger.id) expect(json_response['access_level']).to eq(Member::DEVELOPER) @@ -147,28 +147,28 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: master.id, access_level: Member::MASTER - expect(response).to have_http_status(source_type == 'project' ? 201 : 409) + expect(response).to have_gitlab_http_status(source_type == 'project' ? 201 : 409) end it 'returns 400 when user_id is not given' do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), access_level: Member::MASTER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not given' do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 422 when access_level is not valid' do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: 1234 - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end end @@ -190,7 +190,7 @@ describe API::V3::Members do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user), access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -201,7 +201,7 @@ describe API::V3::Members do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: Member::MASTER, expires_at: '2016-08-05' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(developer.id) expect(json_response['access_level']).to eq(Member::MASTER) expect(json_response['expires_at']).to eq('2016-08-05') @@ -212,20 +212,20 @@ describe API::V3::Members do put v3_api("/#{source_type.pluralize}/#{source.id}/members/123", master), access_level: Member::MASTER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 when access_level is not given' do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 422 when access level is not valid' do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: 1234 - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end end @@ -243,7 +243,7 @@ describe API::V3::Members do user = public_send(type) delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -254,7 +254,7 @@ describe API::V3::Members do expect do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", developer) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { source.members.count }.by(-1) end end @@ -265,7 +265,7 @@ describe API::V3::Members do expect do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{access_requester.id}", master) - expect(response).to have_http_status(source_type == 'project' ? 200 : 404) + expect(response).to have_gitlab_http_status(source_type == 'project' ? 200 : 404) end.not_to change { source.requesters.count } end end @@ -274,7 +274,7 @@ describe API::V3::Members do expect do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { source.members.count }.by(-1) end end @@ -282,7 +282,7 @@ describe API::V3::Members do it "returns #{source_type == 'project' ? 200 : 404} if member does not exist" do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/123", master) - expect(response).to have_http_status(source_type == 'project' ? 200 : 404) + expect(response).to have_gitlab_http_status(source_type == 'project' ? 200 : 404) end end end @@ -333,7 +333,7 @@ describe API::V3::Members do post v3_api("/projects/#{project.id}/members", master), user_id: stranger.id, access_level: Member::OWNER - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end.to change { project.members.count }.by(0) end end diff --git a/spec/requests/api/v3/merge_request_diffs_spec.rb b/spec/requests/api/v3/merge_request_diffs_spec.rb index 3f21ff40726..e613036a88d 100644 --- a/spec/requests/api/v3/merge_request_diffs_spec.rb +++ b/spec/requests/api/v3/merge_request_diffs_spec.rb @@ -24,7 +24,7 @@ describe API::V3::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/999/versions", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -42,7 +42,7 @@ describe API::V3::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions/999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/merge_requests_spec.rb b/spec/requests/api/v3/merge_requests_spec.rb index df73c731c96..26251b95680 100644 --- a/spec/requests/api/v3/merge_requests_spec.rb +++ b/spec/requests/api/v3/merge_requests_spec.rb @@ -21,14 +21,14 @@ describe API::MergeRequests do context "when unauthenticated" do it "returns authentication error" do get v3_api("/projects/#{project.id}/merge_requests") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context "when authenticated" do it "returns an array of all merge_requests" do get v3_api("/projects/#{project.id}/merge_requests", 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.length).to eq(3) expect(json_response.last['title']).to eq(merge_request.title) @@ -44,7 +44,7 @@ describe API::MergeRequests do it "returns an array of all merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state", 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.length).to eq(3) expect(json_response.last['title']).to eq(merge_request.title) @@ -52,7 +52,7 @@ describe API::MergeRequests do it "returns an array of open merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state=opened", 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.length).to eq(1) expect(json_response.last['title']).to eq(merge_request.title) @@ -60,7 +60,7 @@ describe API::MergeRequests do it "returns an array of closed merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state=closed", 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.length).to eq(1) expect(json_response.first['title']).to eq(merge_request_closed.title) @@ -68,7 +68,7 @@ describe API::MergeRequests do it "returns an array of merged merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state=merged", 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.length).to eq(1) expect(json_response.first['title']).to eq(merge_request_merged.title) @@ -77,7 +77,7 @@ describe API::MergeRequests do it 'matches V3 response schema' do get v3_api("/projects/#{project.id}/merge_requests", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v3/merge_requests') end @@ -89,7 +89,7 @@ describe API::MergeRequests do it "returns an array of merge_requests in ascending order" do get v3_api("/projects/#{project.id}/merge_requests?sort=asc", 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.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['created_at'] } @@ -98,7 +98,7 @@ describe API::MergeRequests do it "returns an array of merge_requests in descending order" do get v3_api("/projects/#{project.id}/merge_requests?sort=desc", 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.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['created_at'] } @@ -107,7 +107,7 @@ describe API::MergeRequests do it "returns an array of merge_requests ordered by updated_at" do get v3_api("/projects/#{project.id}/merge_requests?order_by=updated_at", 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.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['updated_at'] } @@ -116,7 +116,7 @@ describe API::MergeRequests do it "returns an array of merge_requests ordered by created_at" do get v3_api("/projects/#{project.id}/merge_requests?order_by=created_at&sort=asc", 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.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['created_at'] } @@ -130,7 +130,7 @@ describe API::MergeRequests do it 'exposes known attributes' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(merge_request.id) expect(json_response['iid']).to eq(merge_request.iid) expect(json_response['project_id']).to eq(merge_request.project.id) @@ -158,7 +158,7 @@ describe API::MergeRequests do it "returns merge_request" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(merge_request.title) expect(json_response['iid']).to eq(merge_request.iid) expect(json_response['work_in_progress']).to eq(false) @@ -178,7 +178,7 @@ describe API::MergeRequests do it 'returns merge_request by iid array' do get v3_api("/projects/#{project.id}/merge_requests", user), iid: [merge_request.iid, merge_request_closed.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.first['title']).to eq merge_request_closed.title @@ -187,7 +187,7 @@ describe API::MergeRequests do it "returns a 404 error if merge_request_id not found" do get v3_api("/projects/#{project.id}/merge_requests/999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'Work in Progress' do @@ -195,7 +195,7 @@ describe API::MergeRequests do it "returns merge_request" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request_wip.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['work_in_progress']).to eq(true) end end @@ -214,7 +214,7 @@ describe API::MergeRequests do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/999/commits", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -227,7 +227,7 @@ describe API::MergeRequests do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/999/changes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -243,7 +243,7 @@ describe API::MergeRequests do milestone_id: milestone.id, remove_source_branch: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('Test merge_request') expect(json_response['labels']).to eq(%w(label label2)) expect(json_response['milestone']['id']).to eq(milestone.id) @@ -253,25 +253,25 @@ describe API::MergeRequests do it "returns 422 when source_branch equals target_branch" do post v3_api("/projects/#{project.id}/merge_requests", user), title: "Test merge_request", source_branch: "master", target_branch: "master", author: user - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end it "returns 400 when source_branch is missing" do post v3_api("/projects/#{project.id}/merge_requests", user), title: "Test merge_request", target_branch: "master", author: user - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 when target_branch is missing" do post v3_api("/projects/#{project.id}/merge_requests", user), title: "Test merge_request", source_branch: "markdown", author: user - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 when title is missing" do post v3_api("/projects/#{project.id}/merge_requests", user), target_branch: 'master', source_branch: 'markdown' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do @@ -307,7 +307,7 @@ describe API::MergeRequests do target_branch: 'master', author: user end.to change { MergeRequest.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) end end end @@ -403,7 +403,7 @@ describe API::MergeRequests do it "denies the deletion of the merge request" do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", developer) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -411,7 +411,7 @@ describe API::MergeRequests do it "destroys the merge request owners can destroy" do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -422,7 +422,7 @@ describe API::MergeRequests do it "returns merge_request in case of success" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns 406 if branch can't be merged" do @@ -431,21 +431,21 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(406) + expect(response).to have_gitlab_http_status(406) expect(json_response['message']).to eq('Branch cannot be merged') end it "returns 405 if merge_request is not open" do merge_request.close put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(405) + expect(response).to have_gitlab_http_status(405) expect(json_response['message']).to eq('405 Method Not Allowed') end it "returns 405 if merge_request is a work in progress" do merge_request.update_attribute(:title, "WIP: #{merge_request.title}") put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(405) + expect(response).to have_gitlab_http_status(405) expect(json_response['message']).to eq('405 Method Not Allowed') end @@ -454,7 +454,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(405) + expect(response).to have_gitlab_http_status(405) expect(json_response['message']).to eq('405 Method Not Allowed') end @@ -462,21 +462,21 @@ describe API::MergeRequests do user2 = create(:user) project.team << [user2, :reporter] put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user2) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['message']).to eq('401 Unauthorized') end it "returns 409 if the SHA parameter doesn't match" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), sha: merge_request.diff_head_sha.reverse - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to start_with('SHA does not match HEAD of source branch') end it "succeeds if the SHA parameter matches" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), sha: merge_request.diff_head_sha - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "enables merge when pipeline succeeds if the pipeline is active" do @@ -485,7 +485,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), merge_when_build_succeeds: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('Test') expect(json_response['merge_when_build_succeeds']).to eq(true) end @@ -496,39 +496,39 @@ describe API::MergeRequests do it "returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", 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 end it "updates title and returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), title: "New title" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('New title') end it "updates description and returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), description: "New description" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq('New description') end it "updates milestone_id and returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), milestone_id: milestone.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['milestone']['id']).to eq(milestone.id) end it "returns merge_request with renamed target_branch" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), target_branch: "wiki" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['target_branch']).to eq('wiki') end it "returns merge_request that removes the source branch" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), remove_source_branch: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['force_remove_source_branch']).to be_truthy end @@ -549,7 +549,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: 'close', title: nil merge_request.reload - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(merge_request.state).to eq('opened') end @@ -557,7 +557,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: 'close', target_branch: nil merge_request.reload - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(merge_request.state).to eq('opened') end end @@ -568,7 +568,7 @@ describe API::MergeRequests do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user), note: "My comment" - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['note']).to eq('My comment') expect(json_response['author']['name']).to eq(user.name) expect(json_response['author']['username']).to eq(user.username) @@ -577,13 +577,13 @@ describe API::MergeRequests do it "returns 400 if note is missing" do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 404 if note is attached to non existent merge request" do post v3_api("/projects/#{project.id}/merge_requests/404/comments", user), note: 'My comment' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -593,7 +593,7 @@ describe API::MergeRequests do it "returns merge_request comments ordered by created_at" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", 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.length).to eq(2) expect(json_response.first['note']).to eq("a comment on a MR") @@ -603,7 +603,7 @@ describe API::MergeRequests do it "returns a 404 error if merge_request_id not found" do get v3_api("/projects/#{project.id}/merge_requests/999/comments", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -615,7 +615,7 @@ describe API::MergeRequests do end get v3_api("/projects/#{project.id}/merge_requests/#{mr.id}/closes_issues", 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.length).to eq(1) expect(json_response.first['id']).to eq(issue.id) @@ -623,7 +623,7 @@ describe API::MergeRequests do it 'returns an empty array when there are no issues to be closed' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/closes_issues", 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.length).to eq(0) end @@ -636,7 +636,7 @@ describe API::MergeRequests do get v3_api("/projects/#{jira_project.id}/merge_requests/#{merge_request.id}/closes_issues", 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.length).to eq(1) expect(json_response.first['title']).to eq(issue.title) @@ -651,7 +651,7 @@ describe API::MergeRequests do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/closes_issues", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -659,20 +659,20 @@ describe API::MergeRequests do it 'subscribes to a merge request' do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the merge request is not found' do post v3_api("/projects/#{project.id}/merge_requests/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 403 if user has no access to read code' do @@ -681,7 +681,7 @@ describe API::MergeRequests do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -689,20 +689,20 @@ describe API::MergeRequests do it 'unsubscribes from a merge request' do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", admin) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the merge request is not found' do post v3_api("/projects/#{project.id}/merge_requests/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 403 if user has no access to read code' do @@ -711,7 +711,7 @@ describe API::MergeRequests do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end diff --git a/spec/requests/api/v3/milestones_spec.rb b/spec/requests/api/v3/milestones_spec.rb index feaa87faec7..e82f35598a6 100644 --- a/spec/requests/api/v3/milestones_spec.rb +++ b/spec/requests/api/v3/milestones_spec.rb @@ -12,7 +12,7 @@ describe API::V3::Milestones do it 'returns project milestones' do get v3_api("/projects/#{project.id}/milestones", 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.first['title']).to eq(milestone.title) end @@ -20,13 +20,13 @@ describe API::V3::Milestones do it 'returns a 401 error if user not authenticated' do get v3_api("/projects/#{project.id}/milestones") - 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 v3_api("/projects/#{project.id}/milestones?state=active", 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.length).to eq(1) expect(json_response.first['id']).to eq(milestone.id) @@ -35,7 +35,7 @@ describe API::V3::Milestones do it 'returns an array of closed milestones' do get v3_api("/projects/#{project.id}/milestones?state=closed", 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.length).to eq(1) expect(json_response.first['id']).to eq(closed_milestone.id) @@ -46,7 +46,7 @@ describe API::V3::Milestones do it 'returns a project milestone by id' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}", 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 @@ -63,7 +63,7 @@ describe API::V3::Milestones do it 'returns a project milestone by iid array' do get v3_api("/projects/#{project.id}/milestones", user), iid: [milestone.iid, closed_milestone.iid] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) expect(json_response.first['title']).to eq milestone.title expect(json_response.first['id']).to eq milestone.id @@ -72,13 +72,13 @@ describe API::V3::Milestones do it 'returns 401 error if user not authenticated' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}") - 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 v3_api("/projects/#{project.id}/milestones/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -86,7 +86,7 @@ describe API::V3::Milestones do it 'creates a new project milestone' do post v3_api("/projects/#{project.id}/milestones", 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 @@ -95,7 +95,7 @@ describe API::V3::Milestones do post v3_api("/projects/#{project.id}/milestones", 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') @@ -104,20 +104,20 @@ describe API::V3::Milestones do it 'returns a 400 error if title is missing' do post v3_api("/projects/#{project.id}/milestones", 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 v3_api("/projects/#{project.id}/milestones", 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 project with reserved html characters' do post v3_api("/projects/#{project.id}/milestones", 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 @@ -128,7 +128,7 @@ describe API::V3::Milestones do put v3_api("/projects/#{project.id}/milestones/#{milestone.id}", 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 @@ -137,7 +137,7 @@ describe API::V3::Milestones do put v3_api("/projects/#{project.id}/milestones/#{milestone.id}", 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 @@ -145,7 +145,7 @@ describe API::V3::Milestones do put v3_api("/projects/#{project.id}/milestones/1234", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -153,7 +153,7 @@ describe API::V3::Milestones do it 'updates a project milestone' do put v3_api("/projects/#{project.id}/milestones/#{milestone.id}", 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 @@ -175,7 +175,7 @@ describe API::V3::Milestones do it 'returns project issues for a particular milestone' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}/issues", 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.first['milestone']['title']).to eq(milestone.title) end @@ -183,14 +183,14 @@ describe API::V3::Milestones do it 'matches V3 response schema for a list of issues' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v3/issues') end it 'returns a 401 error if user not authenticated' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}/issues") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end describe 'confidential issues' do @@ -207,7 +207,7 @@ describe API::V3::Milestones do it 'returns confidential issues to team members' do get v3_api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", 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(2) expect(json_response.map { |issue| issue['id'] }).to include(issue.id, confidential_issue.id) @@ -219,7 +219,7 @@ describe API::V3::Milestones do get v3_api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", member) - 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.map { |issue| issue['id'] }).to include(issue.id) @@ -228,7 +228,7 @@ describe API::V3::Milestones do it 'does not return confidential issues to regular users' do get v3_api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", create(: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.map { |issue| issue['id'] }).to include(issue.id) diff --git a/spec/requests/api/v3/notes_spec.rb b/spec/requests/api/v3/notes_spec.rb index 56729692eed..d3455a4bba4 100644 --- a/spec/requests/api/v3/notes_spec.rb +++ b/spec/requests/api/v3/notes_spec.rb @@ -35,7 +35,7 @@ describe API::V3::Notes do it "returns an array of issue notes" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", 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['body']).to eq(issue_note.note) @@ -46,14 +46,14 @@ describe API::V3::Notes do it "returns a 404 error when issue id not found" do get v3_api("/projects/#{project.id}/issues/12345/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the notes" do it "returns an empty array" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", 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).to be_empty @@ -65,7 +65,7 @@ describe API::V3::Notes do it "returns 404" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -73,7 +73,7 @@ describe API::V3::Notes do it "returns an empty array" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", private_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['body']).to eq(cross_reference_note.note) @@ -86,7 +86,7 @@ describe API::V3::Notes do it "returns an array of snippet notes" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", 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['body']).to eq(snippet_note.note) @@ -95,13 +95,13 @@ describe API::V3::Notes do it "returns a 404 error when snippet id not found" do get v3_api("/projects/#{project.id}/snippets/42/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -109,7 +109,7 @@ describe API::V3::Notes do it "returns an array of merge_requests notes" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes", 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['body']).to eq(merge_request_note.note) @@ -118,13 +118,13 @@ describe API::V3::Notes do it "returns a 404 error if merge request id not found" do get v3_api("/projects/#{project.id}/merge_requests/4444/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get v3_api("/projects/#{project.id}/merge_requests/4444/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -134,21 +134,21 @@ describe API::V3::Notes do it "returns an issue note by id" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{issue_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(issue_note.note) end it "returns a 404 error if issue note not found" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the note" do it "returns a 404 error" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when issue is confidential" do @@ -157,7 +157,7 @@ describe API::V3::Notes do it "returns 404" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{issue_note.id}", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -165,7 +165,7 @@ describe API::V3::Notes do it "returns an issue note by id" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", private_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(cross_reference_note.note) end end @@ -176,14 +176,14 @@ describe API::V3::Notes do it "returns a snippet note by id" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(snippet_note.note) end it "returns a 404 error if snippet note not found" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -193,7 +193,7 @@ describe API::V3::Notes do it "creates a new issue note" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -201,13 +201,13 @@ describe API::V3::Notes do it "returns a 400 bad request error if body not given" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end context 'when an admin or owner makes the request' do @@ -216,7 +216,7 @@ describe API::V3::Notes do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) @@ -229,7 +229,7 @@ describe API::V3::Notes do it 'creates a new issue note' do post v3_api("/projects/#{project.id}/issues/#{issue2.id}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -238,7 +238,7 @@ describe API::V3::Notes do it 'creates a new issue note' do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -248,7 +248,7 @@ describe API::V3::Notes do it "creates a new snippet note" do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -256,13 +256,13 @@ describe API::V3::Notes do it "returns a 400 bad request error if body not given" do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -274,7 +274,7 @@ describe API::V3::Notes do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'Foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -314,7 +314,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -322,14 +322,14 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user), body: 'Hello!' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 bad request error if body not given' do put v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -338,7 +338,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -346,7 +346,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -355,7 +355,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\ "notes/#{merge_request_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -363,7 +363,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -374,17 +374,17 @@ describe API::V3::Notes do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # Check if note is really deleted delete v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -393,18 +393,18 @@ describe API::V3::Notes do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # Check if note is really deleted delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -413,18 +413,18 @@ describe API::V3::Notes do delete v3_api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.id}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # Check if note is really deleted delete v3_api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.id}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/pipelines_spec.rb b/spec/requests/api/v3/pipelines_spec.rb index e1d036ff365..1c7d9fe32bb 100644 --- a/spec/requests/api/v3/pipelines_spec.rb +++ b/spec/requests/api/v3/pipelines_spec.rb @@ -32,7 +32,7 @@ describe API::V3::Pipelines do it 'returns project pipelines' do get v3_api("/projects/#{project.id}/pipelines", 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.first['sha']).to match(/\A\h{40}\z/) expect(json_response.first['id']).to eq pipeline.id @@ -44,7 +44,7 @@ describe API::V3::Pipelines do it 'does not return project pipelines' do get v3_api("/projects/#{project.id}/pipelines", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -61,7 +61,7 @@ describe API::V3::Pipelines do post v3_api("/projects/#{project.id}/pipeline", user), ref: project.default_branch end.to change { Ci::Pipeline.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to be_a Hash expect(json_response['sha']).to eq project.commit.id end @@ -69,7 +69,7 @@ describe API::V3::Pipelines do it 'fails when using an invalid ref' do post v3_api("/projects/#{project.id}/pipeline", user), ref: 'invalid_ref' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Reference not found' expect(json_response).not_to be_an Array end @@ -79,7 +79,7 @@ describe API::V3::Pipelines do it 'fails to create pipeline' do post v3_api("/projects/#{project.id}/pipeline", user), ref: project.default_branch - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Missing .gitlab-ci.yml file' expect(json_response).not_to be_an Array end @@ -90,7 +90,7 @@ describe API::V3::Pipelines do it 'does not create pipeline' do post v3_api("/projects/#{project.id}/pipeline", non_member), ref: project.default_branch - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -102,14 +102,14 @@ describe API::V3::Pipelines do it 'returns project pipelines' do get v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ end it 'returns 404 when it does not exist' do get v3_api("/projects/#{project.id}/pipelines/123456", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Not found' expect(json_response['id']).to be nil end @@ -131,7 +131,7 @@ describe API::V3::Pipelines do it 'should not return a project pipeline' do get v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -152,7 +152,7 @@ describe API::V3::Pipelines do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user) end.to change { pipeline.builds.count }.from(1).to(2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(build.reload.retried?).to be true end end @@ -161,7 +161,7 @@ describe API::V3::Pipelines do it 'should not return a project pipeline' do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -180,7 +180,7 @@ describe API::V3::Pipelines do it 'retries failed builds' do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('canceled') end end @@ -193,7 +193,7 @@ describe API::V3::Pipelines do it 'rejects the action' do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(pipeline.reload.status).to eq('pending') end end diff --git a/spec/requests/api/v3/project_hooks_spec.rb b/spec/requests/api/v3/project_hooks_spec.rb index b0eddbb5dd2..00f59744a31 100644 --- a/spec/requests/api/v3/project_hooks_spec.rb +++ b/spec/requests/api/v3/project_hooks_spec.rb @@ -22,7 +22,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns project hooks" do get v3_api("/projects/#{project.id}/hooks", 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.count).to eq(1) expect(json_response.first['url']).to eq("http://example.com") @@ -42,7 +42,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "does not access project hooks" do get v3_api("/projects/#{project.id}/hooks", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -51,7 +51,7 @@ describe API::ProjectHooks, 'ProjectHooks' do context "authorized user" do it "returns a project hook" do get v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq(hook.url) expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(hook.push_events) @@ -66,20 +66,20 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 404 error if hook id is not available" do get v3_api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context "unauthorized user" do it "does not access an existing hook" do get v3_api("/projects/#{project.id}/hooks/#{hook.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it "returns a 404 error if hook id is not available" do get v3_api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -90,7 +90,7 @@ describe API::ProjectHooks, 'ProjectHooks' do url: "http://example.com", issues_events: true, wiki_page_events: true, build_events: true end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['url']).to eq('http://example.com') expect(json_response['issues_events']).to eq(true) expect(json_response['push_events']).to eq(true) @@ -111,7 +111,7 @@ describe API::ProjectHooks, 'ProjectHooks' do post v3_api("/projects/#{project.id}/hooks", user), url: "http://example.com", token: token end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["url"]).to eq("http://example.com") expect(json_response).not_to include("token") @@ -123,12 +123,12 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 400 error if url not given" do post v3_api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url not valid" do post v3_api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com" - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -136,7 +136,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "updates an existing project hook" do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'http://example.org', push_events: false, build_events: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq('http://example.org') expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(false) @@ -154,7 +154,7 @@ describe API::ProjectHooks, 'ProjectHooks' do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: "http://example.org", token: token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["url"]).to eq("http://example.org") expect(json_response).not_to include("token") @@ -164,17 +164,17 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns 404 error if hook id not found" do put v3_api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 400 error if url is not given" do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url is not valid" do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -183,23 +183,23 @@ describe API::ProjectHooks, 'ProjectHooks' do expect do delete v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) end.to change {project.hooks.count}.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns success when deleting hook" do delete v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns a 404 error when deleting non existent hook" do delete v3_api("/projects/#{project.id}/hooks/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 error if hook id not given" do delete v3_api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 if a user attempts to delete project hooks he/she does not own" do @@ -208,7 +208,7 @@ describe API::ProjectHooks, 'ProjectHooks' do other_project.team << [test_user, :master] delete v3_api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(WebHook.exists?(hook.id)).to be_truthy end end diff --git a/spec/requests/api/v3/project_snippets_spec.rb b/spec/requests/api/v3/project_snippets_spec.rb index 7e88489082a..2ed31b99516 100644 --- a/spec/requests/api/v3/project_snippets_spec.rb +++ b/spec/requests/api/v3/project_snippets_spec.rb @@ -28,7 +28,7 @@ describe API::ProjectSnippets do get v3_api("/projects/#{project.id}/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(3) expect(json_response.map { |snippet| snippet['id']} ).to include(public_snippet.id, internal_snippet.id, private_snippet.id) expect(json_response.last).to have_key('web_url') @@ -38,7 +38,7 @@ describe API::ProjectSnippets do create(:project_snippet, :private, project: project) get v3_api("/projects/#{project.id}/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(0) end end @@ -56,7 +56,7 @@ describe API::ProjectSnippets do it 'creates a new snippet' do post v3_api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) snippet = ProjectSnippet.find(json_response['id']) expect(snippet.content).to eq(params[:code]) expect(snippet.title).to eq(params[:title]) @@ -69,7 +69,7 @@ describe API::ProjectSnippets do post v3_api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -95,7 +95,7 @@ describe API::ProjectSnippets do expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -116,7 +116,7 @@ describe API::ProjectSnippets do put v3_api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) snippet.reload expect(snippet.content).to eq(new_content) end @@ -124,14 +124,14 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do put v3_api("/projects/#{snippet.project.id}/snippets/1234", admin), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put v3_api("/projects/#{project.id}/snippets/1234", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -173,7 +173,7 @@ describe API::ProjectSnippets do expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } .not_to change { snippet.reload.title } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -194,13 +194,13 @@ describe API::ProjectSnippets do delete v3_api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns 404 for invalid snippet id' do delete v3_api("/projects/#{snippet.project.id}/snippets/1234", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end @@ -211,7 +211,7 @@ describe API::ProjectSnippets do it 'returns raw text' do get v3_api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -219,7 +219,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do delete v3_api("/projects/#{snippet.project.id}/snippets/1234", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index e5282c3311f..f62ad747c73 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -44,14 +44,14 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as regular user' do it 'returns an array of projects' do get v3_api('/projects', 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.first['name']).to eq(project.name) expect(json_response.first['owner']['username']).to eq(user.username) @@ -94,7 +94,7 @@ describe API::V3::Projects do get v3_api('/projects?simple=true', 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.first.keys).to match_array expected_keys end @@ -103,7 +103,7 @@ describe API::V3::Projects do context 'and using search' do it 'returns searched project' do get v3_api('/projects', user), { search: project.name } - 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(1) end @@ -112,21 +112,21 @@ describe API::V3::Projects do context 'and using the visibility filter' do it 'filters based on private visibility param' do get v3_api('/projects', user), { visibility: 'private' } - 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(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PRIVATE).count) end it 'filters based on internal visibility param' do get v3_api('/projects', user), { visibility: 'internal' } - 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(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::INTERNAL).count) end it 'filters based on public visibility param' do get v3_api('/projects', user), { visibility: 'public' } - 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(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PUBLIC).count) end @@ -138,7 +138,7 @@ describe API::V3::Projects do it 'returns archived project' do get v3_api('/projects?archived=true', 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.length).to eq(1) expect(json_response.first['id']).to eq(archived_project.id) @@ -147,7 +147,7 @@ describe API::V3::Projects do it 'returns non-archived project' do get v3_api('/projects?archived=false', 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.length).to eq(1) expect(json_response.first['id']).to eq(project.id) @@ -156,7 +156,7 @@ describe API::V3::Projects do it 'returns all project' do get v3_api('/projects', 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.length).to eq(2) end @@ -170,7 +170,7 @@ describe API::V3::Projects do it 'returns the correct order when sorted by id' do get v3_api('/projects', user), { order_by: 'id', sort: 'desc' } - 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.first['id']).to eq(project3.id) end @@ -184,21 +184,21 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects/all') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as regular user' do it 'returns authentication error' do get v3_api('/projects/all', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when authenticated as admin' do it 'returns an array of all projects' do get v3_api('/projects/all', admin) - 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).to satisfy do |response| @@ -213,7 +213,7 @@ describe API::V3::Projects do it "does not include statistics by default" do get v3_api('/projects/all', admin) - 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.first).not_to include('statistics') end @@ -221,7 +221,7 @@ describe API::V3::Projects do it "includes statistics if requested" do get v3_api('/projects/all', admin), statistics: true - 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.first).to include 'statistics' end @@ -237,14 +237,14 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects/owned') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as project owner' do it 'returns an array of projects the user owns' do get v3_api('/projects/owned', user4) - 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.first['name']).to eq(project4.name) expect(json_response.first['owner']['username']).to eq(user4.username) @@ -253,7 +253,7 @@ describe API::V3::Projects do it "does not include statistics by default" do get v3_api('/projects/owned', user4) - 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.first).not_to include('statistics') end @@ -271,7 +271,7 @@ describe API::V3::Projects do get v3_api('/projects/owned', user4), statistics: true - 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.first['statistics']).to eq attributes.stringify_keys end @@ -283,7 +283,7 @@ describe API::V3::Projects do it 'returns the visible projects' do get v3_api('/projects/visible', current_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.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id)) end @@ -329,7 +329,7 @@ describe API::V3::Projects do it 'returns the starred projects viewable by the user' do get v3_api('/projects/starred', user3) - 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.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id) end @@ -341,14 +341,14 @@ describe API::V3::Projects do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) expect { post v3_api('/projects', user2), name: 'foo' } .to change {Project.count}.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'creates new project without path but with name and returns 201' do expect { post v3_api('/projects', user), name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -359,7 +359,7 @@ describe API::V3::Projects do it 'creates new project without name but with path and returns 201' do expect { post v3_api('/projects', user), path: 'foo_project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -370,7 +370,7 @@ describe API::V3::Projects do it 'creates new project name and path and returns 201' do expect { post v3_api('/projects', user), path: 'foo-Project', name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -381,12 +381,12 @@ describe API::V3::Projects do it 'creates last project before reaching project limit' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) post v3_api('/projects', user2), name: 'foo' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'does not create new project without name or path and return 400' do expect { post v3_api('/projects', user) }.not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "assigns attributes to project" do @@ -501,7 +501,7 @@ describe API::V3::Projects do it 'does not allow a non-admin to use a restricted visibility level' do post v3_api('/projects', user), @project - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['visibility_level'].first).to( match('restricted by your GitLab administrator') ) @@ -523,14 +523,14 @@ describe API::V3::Projects do it 'should create new project without path and return 201' do expect { post v3_api("/projects/user/#{user.id}", admin), name: 'foo' }.to change {Project.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'responds with 400 on failure and not project' do expect { post v3_api("/projects/user/#{user.id}", admin) } .not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end @@ -544,7 +544,7 @@ describe API::V3::Projects do post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| next if %i[has_external_issue_tracker path].include?(k) expect(json_response[k.to_s]).to eq(v) @@ -555,7 +555,7 @@ describe API::V3::Projects do project = attributes_for(:project, :public) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_truthy expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC) end @@ -564,7 +564,7 @@ describe API::V3::Projects do project = attributes_for(:project, { public: true }) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_truthy expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC) end @@ -573,7 +573,7 @@ describe API::V3::Projects do project = attributes_for(:project, :internal) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_falsey expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL) end @@ -581,7 +581,7 @@ describe API::V3::Projects do it 'sets a project as internal overriding :public' do project = attributes_for(:project, :internal, { public: true }) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_falsey expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL) end @@ -635,7 +635,7 @@ describe API::V3::Projects do it "uploads the file and returns its info" do post v3_api("/projects/#{project.id}/uploads", user), file: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['alt']).to eq("dk") expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to end_with("/dk.png") @@ -649,7 +649,7 @@ describe API::V3::Projects do get v3_api("/projects/#{public_project.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(public_project.id) expect(json_response['description']).to eq(public_project.description) expect(json_response['default_branch']).to eq(public_project.default_branch) @@ -668,7 +668,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) @@ -710,20 +710,20 @@ describe API::V3::Projects do it 'returns a project by path name' do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'returns a 404 error if not found' do get v3_api('/projects/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'returns a 404 error if user is not a member' do other_user = create(:user) get v3_api("/projects/#{project.id}", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'handles users with dots' do @@ -731,14 +731,14 @@ describe API::V3::Projects do project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) get v3_api("/projects/#{CGI.escape(project.full_path)}", dot_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'exposes namespace fields' do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['namespace']).to eq({ 'id' => user.namespace.id, 'name' => user.namespace.name, @@ -756,7 +756,7 @@ describe API::V3::Projects do it 'contains permission information' do get v3_api("/projects", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.first['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil @@ -768,7 +768,7 @@ describe API::V3::Projects do project.team << [user, :master] get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil @@ -783,7 +783,7 @@ describe API::V3::Projects do it 'sets the owner and return 200' do get v3_api("/projects/#{project2.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -803,7 +803,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/events", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) first_event = json_response.first @@ -836,7 +836,7 @@ describe API::V3::Projects do it 'returns a 404 error if not found' do get v3_api('/projects/42/events', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -845,7 +845,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/events", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -857,7 +857,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/users", current_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) @@ -886,7 +886,7 @@ describe API::V3::Projects do it 'returns a 404 error if not found' do get v3_api('/projects/42/users', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -895,7 +895,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/users", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -905,7 +905,7 @@ describe API::V3::Projects do it 'returns an array of project snippets' do get v3_api("/projects/#{project.id}/snippets", 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.first['title']).to eq(snippet.title) end @@ -914,13 +914,13 @@ describe API::V3::Projects do describe 'GET /projects/:id/snippets/:snippet_id' do it 'returns a project snippet' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) end it 'returns a 404 error if snippet id not found' do get v3_api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -929,7 +929,7 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/snippets", user), title: 'v3_api test', file_name: 'sample.rb', code: 'test', visibility_level: '0' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('v3_api test') end @@ -943,7 +943,7 @@ describe API::V3::Projects do it 'updates an existing project snippet' do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user), code: 'updated code' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('example') expect(snippet.reload.content).to eq('updated code') end @@ -951,7 +951,7 @@ describe API::V3::Projects do it 'updates an existing project snippet with new title' do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user), title: 'other v3_api test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('other v3_api test') end end @@ -963,24 +963,24 @@ describe API::V3::Projects do expect do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user) end.to change { Snippet.count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns 404 when deleting unknown snippet id' do delete v3_api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end describe 'GET /projects/:id/snippets/:snippet_id/raw' do it 'gets a raw project snippet' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 404 error if raw project snippet not found' do get v3_api("/projects/#{project.id}/snippets/5555/raw", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -993,13 +993,13 @@ describe API::V3::Projects do it "is not available for non admin users" do post v3_api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'allows project to be forked from an existing project' do expect(project_fork_target.forked?).not_to be_truthy post v3_api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked_project_link).not_to be_nil @@ -1016,7 +1016,7 @@ describe API::V3::Projects do it 'fails if forked_from project which does not exist' do post v3_api("/projects/#{project_fork_target.id}/fork/9999", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'fails with 409 if already forked' do @@ -1024,7 +1024,7 @@ describe API::V3::Projects do project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) post v3_api("/projects/#{project_fork_target.id}/fork/#{new_project_fork_source.id}", admin) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked?).to be_truthy @@ -1034,7 +1034,7 @@ describe API::V3::Projects do describe 'DELETE /projects/:id/fork' do it "is not visible to users outside group" do delete v3_api("/projects/#{project_fork_target.id}/fork", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'when users belong to project group' do @@ -1047,7 +1047,7 @@ describe API::V3::Projects do it 'is forbidden to non-owner users' do delete v3_api("/projects/#{project_fork_target.id}/fork", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'makes forked project unforked' do @@ -1056,7 +1056,7 @@ describe API::V3::Projects do expect(project_fork_target.forked_from_project).not_to be_nil expect(project_fork_target.forked?).to be_truthy delete v3_api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_fork_target.reload expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target.forked?).not_to be_truthy @@ -1065,7 +1065,7 @@ describe API::V3::Projects do it 'is idempotent if not forked' do expect(project_fork_target.forked_from_project).to be_nil delete v3_api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) expect(project_fork_target.reload.forked_from_project).to be_nil end end @@ -1082,7 +1082,7 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at end.to change { ProjectGroupLink.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['group_id']).to eq(group.id) expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['expires_at']).to eq(expires_at.to_s) @@ -1090,18 +1090,18 @@ describe API::V3::Projects do it "returns a 400 error when group id is not given" do post v3_api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when access level is not given" do post v3_api("/projects/#{project.id}/share", user), group_id: group.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when sharing is disabled" do project.namespace.update(share_with_group_lock: true) post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when user cannot read group' do @@ -1109,19 +1109,19 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/share", user), group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when group does not exist' do post v3_api("/projects/#{project.id}/share", user), group_id: 1234, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 400 error when wrong params passed" do post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'group_access does not have a valid value' end end @@ -1133,26 +1133,26 @@ describe API::V3::Projects do delete v3_api("/projects/#{project.id}/share/#{group.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(project.project_group_links).to be_empty end it 'returns a 400 when group id is not an integer' do delete v3_api("/projects/#{project.id}/share/foo", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when group link does not exist' do delete v3_api("/projects/#{project.id}/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when project does not exist' do delete v3_api("/projects/123/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1173,7 +1173,7 @@ describe API::V3::Projects do it 'returns project search responses' do get v3_api("/projects/search/#{args[:query]}", current_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(args[:results]) json_response.each { |project| expect(project['name']).to match(args[:match_regex] || /.*#{args[:query]}.*/) } @@ -1216,7 +1216,7 @@ describe API::V3::Projects do it 'returns authentication error' do project_param = { name: 'bar' } put v3_api("/projects/#{project.id}"), project_param - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1224,7 +1224,7 @@ describe API::V3::Projects do it 'updates name' do project_param = { name: 'bar' } put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1233,7 +1233,7 @@ describe API::V3::Projects do it 'updates visibility_level' do project_param = { visibility_level: 20 } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1243,7 +1243,7 @@ describe API::V3::Projects do project3.update_attributes({ visibility_level: Gitlab::VisibilityLevel::PUBLIC }) project_param = { public: false } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1253,7 +1253,7 @@ describe API::V3::Projects do it 'does not update name to existing name' do project_param = { name: project3.name } put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['name']).to eq(['has already been taken']) end @@ -1262,14 +1262,14 @@ describe API::V3::Projects do put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['request_access_enabled']).to eq(false) end it 'updates path & name to existing path & name in different namespace' do project_param = { path: project4.path, name: project4.name } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1280,7 +1280,7 @@ describe API::V3::Projects do it 'updates path' do project_param = { path: 'bar' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1294,7 +1294,7 @@ describe API::V3::Projects do description: 'new description' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1303,20 +1303,20 @@ describe API::V3::Projects do it 'does not update path to existing path' do project_param = { path: project.path } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['path']).to eq(['has already been taken']) end it 'does not update name' do project_param = { name: 'bar' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not update visibility_level' do project_param = { visibility_level: 20 } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1330,7 +1330,7 @@ describe API::V3::Projects do description: 'new description', request_access_enabled: true } put v3_api("/projects/#{project.id}", user3), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1340,7 +1340,7 @@ describe API::V3::Projects do it 'archives the project' do post v3_api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1353,7 +1353,7 @@ describe API::V3::Projects do it 'remains archived' do post v3_api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1366,7 +1366,7 @@ describe API::V3::Projects do it 'rejects the action' do post v3_api("/projects/#{project.id}/archive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1376,7 +1376,7 @@ describe API::V3::Projects do it 'remains unarchived' do post v3_api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1389,7 +1389,7 @@ describe API::V3::Projects do it 'unarchives the project' do post v3_api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1402,7 +1402,7 @@ describe API::V3::Projects do it 'rejects the action' do post v3_api("/projects/#{project.id}/unarchive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1412,7 +1412,7 @@ describe API::V3::Projects do it 'stars the project' do expect { post v3_api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['star_count']).to eq(1) end end @@ -1426,7 +1426,7 @@ describe API::V3::Projects do it 'does not modify the star count' do expect { post v3_api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1441,7 +1441,7 @@ describe API::V3::Projects do it 'unstars the project' do expect { delete v3_api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['star_count']).to eq(0) end end @@ -1450,7 +1450,7 @@ describe API::V3::Projects do it 'does not modify the star count' do expect { delete v3_api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1459,36 +1459,36 @@ describe API::V3::Projects do context 'when authenticated as user' do it 'removes project' do delete v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not remove a project if not an owner' do user3 = create(:user) project.team << [user3, :developer] delete v3_api("/projects/#{project.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not remove a non existing project' do delete v3_api('/projects/1328', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not remove a project not attached to user' do delete v3_api("/projects/#{project.id}", user2) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context 'when authenticated as admin' do it 'removes any existing project' do delete v3_api("/projects/#{project.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not remove a non existing project' do delete v3_api('/projects/1328', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/repositories_spec.rb b/spec/requests/api/v3/repositories_spec.rb index 67624a0bbea..0167eb2c4f6 100644 --- a/spec/requests/api/v3/repositories_spec.rb +++ b/spec/requests/api/v3/repositories_spec.rb @@ -17,7 +17,7 @@ describe API::V3::Repositories do it 'returns the repository tree' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array first_commit = json_response.first @@ -107,7 +107,7 @@ describe API::V3::Repositories do shared_examples_for 'repository blob' do it 'returns the repository blob' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when sha does not exist' do it_behaves_like '404 response' do @@ -162,7 +162,7 @@ describe API::V3::Repositories do shared_examples_for 'repository raw blob' do it 'returns the repository raw blob' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when sha does not exist' do it_behaves_like '404 response' do @@ -205,7 +205,7 @@ describe API::V3::Repositories do shared_examples_for 'repository archive' do it 'returns the repository archive' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data expect(type).to eq('git-archive') @@ -213,7 +213,7 @@ describe API::V3::Repositories do end it 'returns the repository archive archive.zip' do get v3_api("/projects/#{project.id}/repository/archive.zip", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data expect(type).to eq('git-archive') @@ -221,7 +221,7 @@ describe API::V3::Repositories do end it 'returns the repository archive archive.tar.bz2' do get v3_api("/projects/#{project.id}/repository/archive.tar.bz2", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data expect(type).to eq('git-archive') @@ -263,32 +263,32 @@ describe API::V3::Repositories do shared_examples_for 'repository compare' do it "compares branches" do get v3_api(route, current_user), from: 'master', to: 'feature' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end it "compares tags" do get v3_api(route, current_user), from: 'v1.0.0', to: 'v1.1.0' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end it "compares commits" do get v3_api(route, current_user), from: sample_commit.id, to: sample_commit.parent_id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_falsey end it "compares commits in reverse order" do get v3_api(route, current_user), from: sample_commit.parent_id, to: sample_commit.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end it "compares same refs" do get v3_api(route, current_user), from: 'master', to: 'master' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_truthy @@ -325,7 +325,7 @@ describe API::V3::Repositories do it 'returns valid data' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array first_contributor = json_response.first diff --git a/spec/requests/api/v3/runners_spec.rb b/spec/requests/api/v3/runners_spec.rb index a31eb3f1d43..c91b097a3c7 100644 --- a/spec/requests/api/v3/runners_spec.rb +++ b/spec/requests/api/v3/runners_spec.rb @@ -37,7 +37,7 @@ describe API::V3::Runners do expect do delete v3_api("/runners/#{shared_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.shared.count }.by(-1) end end @@ -47,7 +47,7 @@ describe API::V3::Runners do expect do delete v3_api("/runners/#{unused_specific_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.specific.count }.by(-1) end @@ -55,7 +55,7 @@ describe API::V3::Runners do expect do delete v3_api("/runners/#{specific_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.specific.count }.by(-1) end end @@ -63,7 +63,7 @@ describe API::V3::Runners do it 'returns 404 if runner does not exists' do delete v3_api('/runners/9999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -71,26 +71,26 @@ describe API::V3::Runners do context 'when runner is shared' do it 'does not delete runner' do delete v3_api("/runners/#{shared_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when runner is not shared' do it 'does not delete runner without access to it' do delete v3_api("/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not delete runner with more than one associated project' do delete v3_api("/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'deletes runner for one owned project' do expect do delete v3_api("/runners/#{specific_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.specific.count }.by(-1) end end @@ -100,7 +100,7 @@ describe API::V3::Runners do it 'does not delete runner' do delete v3_api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -112,7 +112,7 @@ describe API::V3::Runners do expect do delete v3_api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { project.runners.count }.by(-1) end end @@ -122,14 +122,14 @@ describe API::V3::Runners do expect do delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user) end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'returns 404 is runner is not found' do delete v3_api("/projects/#{project.id}/runners/9999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -137,7 +137,7 @@ describe API::V3::Runners do it "does not disable project's runner" do delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -145,7 +145,7 @@ describe API::V3::Runners do it "does not disable project's runner" do delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/v3/services_spec.rb b/spec/requests/api/v3/services_spec.rb index f0fa48e22df..8f212ab6be6 100644 --- a/spec/requests/api/v3/services_spec.rb +++ b/spec/requests/api/v3/services_spec.rb @@ -13,7 +13,7 @@ describe API::V3::Services do it "deletes #{service}" do delete v3_api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project.send(service_method).reload expect(project.send(service_method).activated?).to be_falsey end diff --git a/spec/requests/api/v3/settings_spec.rb b/spec/requests/api/v3/settings_spec.rb index 291f6dcc2aa..25fa0a8aabd 100644 --- a/spec/requests/api/v3/settings_spec.rb +++ b/spec/requests/api/v3/settings_spec.rb @@ -7,7 +7,7 @@ describe API::V3::Settings, 'Settings' do describe "GET /application/settings" do it "returns application settings" do get v3_api("/application/settings", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Hash expect(json_response['default_projects_limit']).to eq(42) expect(json_response['password_authentication_enabled']).to be_truthy @@ -30,7 +30,7 @@ describe API::V3::Settings, 'Settings' do put v3_api("/application/settings", admin), default_projects_limit: 3, password_authentication_enabled: false, repository_storage: 'custom', koding_enabled: true, koding_url: 'http://koding.example.com', plantuml_enabled: true, plantuml_url: 'http://plantuml.example.com' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['default_projects_limit']).to eq(3) expect(json_response['password_authentication_enabled']).to be_falsey expect(json_response['repository_storage']).to eq('custom') @@ -46,7 +46,7 @@ describe API::V3::Settings, 'Settings' do it "returns a blank parameter error message" do put v3_api("/application/settings", admin), koding_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('koding_url is missing') end end @@ -55,7 +55,7 @@ describe API::V3::Settings, 'Settings' do it "returns a blank parameter error message" do put v3_api("/application/settings", admin), plantuml_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('plantuml_url is missing') end end diff --git a/spec/requests/api/v3/snippets_spec.rb b/spec/requests/api/v3/snippets_spec.rb index 79860725634..e8913039194 100644 --- a/spec/requests/api/v3/snippets_spec.rb +++ b/spec/requests/api/v3/snippets_spec.rb @@ -11,7 +11,7 @@ describe API::V3::Snippets do get v3_api("/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( public_snippet.id, internal_snippet.id, @@ -24,7 +24,7 @@ describe API::V3::Snippets do create(:personal_snippet, :private) get v3_api("/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(0) end end @@ -41,7 +41,7 @@ describe API::V3::Snippets do it 'returns all snippets with public visibility from all users' do get v3_api("/snippets/public", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( public_snippet.id, public_snippet_other.id) @@ -60,7 +60,7 @@ describe API::V3::Snippets do it 'returns raw text' do get v3_api("/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -68,7 +68,7 @@ describe API::V3::Snippets do it 'returns 404 for invalid snippet id' do delete v3_api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end @@ -88,7 +88,7 @@ describe API::V3::Snippets do post v3_api("/snippets/", user), params end.to change { PersonalSnippet.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(params[:title]) expect(json_response['file_name']).to eq(params[:file_name]) end @@ -98,7 +98,7 @@ describe API::V3::Snippets do post v3_api("/snippets/", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -121,7 +121,7 @@ describe API::V3::Snippets do it 'rejects the shippet' do expect { create_snippet(visibility_level: Snippet::PUBLIC) } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'creates a spam log' do @@ -140,7 +140,7 @@ describe API::V3::Snippets do put v3_api("/snippets/#{public_snippet.id}", user), content: new_content - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) public_snippet.reload expect(public_snippet.content).to eq(new_content) end @@ -148,21 +148,21 @@ describe API::V3::Snippets do it 'returns 404 for invalid snippet id' do put v3_api("/snippets/1234", user), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it "returns 404 for another user's snippet" do put v3_api("/snippets/#{public_snippet.id}", other_user), title: 'fubar' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put v3_api("/snippets/1234", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -172,14 +172,14 @@ describe API::V3::Snippets do expect do delete v3_api("/snippets/#{public_snippet.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { PersonalSnippet.count }.by(-1) end it 'returns 404 for invalid snippet id' do delete v3_api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end diff --git a/spec/requests/api/v3/system_hooks_spec.rb b/spec/requests/api/v3/system_hooks_spec.rb index ae427541abb..30711c60faa 100644 --- a/spec/requests/api/v3/system_hooks_spec.rb +++ b/spec/requests/api/v3/system_hooks_spec.rb @@ -12,7 +12,7 @@ describe API::V3::SystemHooks do it "returns authentication error" do get v3_api("/hooks") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -20,7 +20,7 @@ describe API::V3::SystemHooks do it "returns forbidden error" do get v3_api("/hooks", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -28,7 +28,7 @@ describe API::V3::SystemHooks do it "returns an array of hooks" do get v3_api("/hooks", admin) - 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.first['url']).to eq(hook.url) expect(json_response.first['push_events']).to be false @@ -43,14 +43,14 @@ describe API::V3::SystemHooks do expect do delete v3_api("/hooks/#{hook.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { SystemHook.count }.by(-1) end it 'returns 404 if the system hook does not exist' do delete v3_api('/hooks/12345', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/tags_spec.rb b/spec/requests/api/v3/tags_spec.rb index 1c4b25c47c3..e6ad005fa87 100644 --- a/spec/requests/api/v3/tags_spec.rb +++ b/spec/requests/api/v3/tags_spec.rb @@ -17,7 +17,7 @@ describe API::V3::Tags do it 'returns the repository tags' do get v3_api("/projects/#{project.id}/repository/tags", current_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.first['name']).to eq(tag_name) end @@ -40,7 +40,7 @@ describe API::V3::Tags do it "returns an array of project tags" do get v3_api("/projects/#{project.id}/repository/tags", 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.first['name']).to eq(tag_name) end @@ -55,7 +55,7 @@ describe API::V3::Tags do it "returns an array of project tags with release info" do get v3_api("/projects/#{project.id}/repository/tags", 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.first['name']).to eq(tag_name) expect(json_response.first['message']).to eq('Version 1.1.0') @@ -75,13 +75,13 @@ describe API::V3::Tags do it 'deletes an existing tag' do delete v3_api("/projects/#{project.id}/repository/tags/#{tag_name}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['tag_name']).to eq(tag_name) end it 'raises 404 if the tag does not exist' do delete v3_api("/projects/#{project.id}/repository/tags/foobar", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/templates_spec.rb b/spec/requests/api/v3/templates_spec.rb index 00446c7f29c..38a8994eb79 100644 --- a/spec/requests/api/v3/templates_spec.rb +++ b/spec/requests/api/v3/templates_spec.rb @@ -19,7 +19,7 @@ describe API::V3::Templates do it 'returns a list of available gitignore templates' do get v3_api(path) - 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 be > 15 end @@ -29,7 +29,7 @@ describe API::V3::Templates do it 'returns a list of available gitlab_ci_ymls' do get v3_api(path) - 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.first['name']).not_to be_nil end @@ -39,7 +39,7 @@ describe API::V3::Templates do it 'adds a disclaimer on the top' do get v3_api(path) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['content']).to start_with("# This file is a template,") end end @@ -66,7 +66,7 @@ describe API::V3::Templates do it 'returns a list of available license templates' do get v3_api(path) - 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(12) expect(json_response.map { |l| l['key'] }).to include('agpl-3.0') @@ -77,7 +77,7 @@ describe API::V3::Templates do it 'returns a list of available popular license templates' do get v3_api("#{path}?popular=1") - 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(3) expect(json_response.map { |l| l['key'] }).to include('apache-2.0') @@ -159,7 +159,7 @@ describe API::V3::Templates do let(:license_type) { 'muth-over9000' } it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/triggers_spec.rb b/spec/requests/api/v3/triggers_spec.rb index 7ccf387f2dc..e8e2f49d7a0 100644 --- a/spec/requests/api/v3/triggers_spec.rb +++ b/spec/requests/api/v3/triggers_spec.rb @@ -27,17 +27,17 @@ describe API::V3::Triggers do context 'Handles errors' do it 'returns bad request if token is missing' do post v3_api("/projects/#{project.id}/trigger/builds"), ref: 'master' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns not found if project is not found' do post v3_api('/projects/0/trigger/builds'), options.merge(ref: 'master') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns unauthorized if token is for different project' do post v3_api("/projects/#{project2.id}/trigger/builds"), options.merge(ref: 'master') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -46,7 +46,7 @@ describe API::V3::Triggers do it 'creates builds' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) pipeline.builds.reload expect(pipeline.builds.pending.size).to eq(2) expect(pipeline.builds.size).to eq(5) @@ -54,7 +54,7 @@ describe API::V3::Triggers do it 'returns bad request with no builds created if there\'s no commit for that ref' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'other-branch') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base']) .to contain_exactly('Reference not found') end @@ -66,19 +66,19 @@ describe API::V3::Triggers do it 'validates variables to be a hash' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(variables: 'value', ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('variables is invalid') end it 'validates variables needs to be a map of key-valued strings' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(variables: { key: %w(1 2) }, ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end it 'creates trigger request with variables' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(variables: variables, ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) pipeline.builds.reload expect(pipeline.variables.map { |v| { v.key => v.value } }.first).to eq(variables) expect(json_response['variables']).to eq(variables) @@ -91,7 +91,7 @@ describe API::V3::Triggers do expect do post v3_api("/projects/#{project.id}/ref/master/trigger/builds?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(5) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when ref contains a dot' do @@ -102,7 +102,7 @@ describe API::V3::Triggers do post v3_api("/projects/#{project.id}/ref/v.1-branch/trigger/builds?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(4) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -113,7 +113,7 @@ describe API::V3::Triggers do it 'returns list of triggers' do get v3_api("/projects/#{project.id}/triggers", 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_a(Array) expect(json_response[0]).to have_key('token') @@ -124,7 +124,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -132,7 +132,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -142,14 +142,14 @@ describe API::V3::Triggers do it 'returns trigger details' do get v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Hash) end it 'responds with 404 Not Found if requesting non-existing trigger' do get v3_api("/projects/#{project.id}/triggers/abcdef012345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -157,7 +157,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -165,7 +165,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers/#{trigger.token}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -177,7 +177,7 @@ describe API::V3::Triggers do post v3_api("/projects/#{project.id}/triggers", user) end.to change {project.triggers.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to be_a(Hash) end end @@ -186,7 +186,7 @@ describe API::V3::Triggers do it 'does not create trigger' do post v3_api("/projects/#{project.id}/triggers", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -194,7 +194,7 @@ describe API::V3::Triggers do it 'does not create trigger' do post v3_api("/projects/#{project.id}/triggers") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -205,14 +205,14 @@ describe API::V3::Triggers do expect do delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change {project.triggers.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing trigger' do delete v3_api("/projects/#{project.id}/triggers/abcdef012345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -220,7 +220,7 @@ describe API::V3::Triggers do it 'does not delete trigger' do delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -228,7 +228,7 @@ describe API::V3::Triggers do it 'does not delete trigger' do delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/v3/users_spec.rb b/spec/requests/api/v3/users_spec.rb index 227b8d1b0c1..bbd05f240d2 100644 --- a/spec/requests/api/v3/users_spec.rb +++ b/spec/requests/api/v3/users_spec.rb @@ -12,7 +12,7 @@ describe API::V3::Users do it 'returns an array of users' do get v3_api('/users', 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 username = user.username @@ -45,14 +45,14 @@ describe API::V3::Users do context 'when unauthenticated' do it 'returns authentication error' do get v3_api("/users/#{user.id}/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get v3_api('/users/999999/keys', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -62,7 +62,7 @@ describe API::V3::Users do get v3_api("/users/#{user.id}/keys", admin) - 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.first['title']).to eq(key.title) end @@ -88,14 +88,14 @@ describe API::V3::Users do context 'when unauthenticated' do it 'returns authentication error' do get v3_api("/users/#{user.id}/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get v3_api('/users/999999/emails', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -105,7 +105,7 @@ describe API::V3::Users do get v3_api("/users/#{user.id}/emails", admin) - 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.first['email']).to eq(email.email) end @@ -113,7 +113,7 @@ describe API::V3::Users do it "returns a 404 for invalid ID" do put v3_api("/users/ASDF/emails", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -122,7 +122,7 @@ describe API::V3::Users do context "when unauthenticated" do it "returns authentication error" do get v3_api("/user/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -133,7 +133,7 @@ describe API::V3::Users do get v3_api("/user/keys", 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.first["title"]).to eq(key.title) end @@ -144,7 +144,7 @@ describe API::V3::Users do context "when unauthenticated" do it "returns authentication error" do get v3_api("/user/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -155,7 +155,7 @@ describe API::V3::Users do get v3_api("/user/emails", 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.first["email"]).to eq(email.email) end @@ -166,25 +166,25 @@ describe API::V3::Users do before { admin } it 'blocks existing user' do put v3_api("/users/#{user.id}/block", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.state).to eq('blocked') end it 'does not re-block ldap blocked users' do put v3_api("/users/#{ldap_blocked_user.id}/block", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do put v3_api("/users/#{user.id}/block", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do put v3_api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end @@ -195,38 +195,38 @@ describe API::V3::Users do it 'unblocks existing user' do put v3_api("/users/#{user.id}/unblock", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.state).to eq('active') end it 'unblocks a blocked user' do put v3_api("/users/#{blocked_user.id}/unblock", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(blocked_user.reload.state).to eq('active') end it 'does not unblock ldap blocked users' do put v3_api("/users/#{ldap_blocked_user.id}/unblock", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do put v3_api("/users/#{user.id}/unblock", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do put v3_api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do put v3_api("/users/ASDF/block", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -246,7 +246,7 @@ describe API::V3::Users do get api("/users/#{user.id}/events", other_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -262,7 +262,7 @@ describe API::V3::Users do end it 'responds with HTTP 200 OK' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'includes the push payload as a Hash' do @@ -281,7 +281,7 @@ describe API::V3::Users do it 'returns the "joined" event' do get v3_api("/users/#{user.id}/events", 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 @@ -327,7 +327,7 @@ describe API::V3::Users do it 'returns a 404 error if not found' do get v3_api('/users/420/events', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb index 48592e12822..79ee6c126f6 100644 --- a/spec/requests/api/variables_spec.rb +++ b/spec/requests/api/variables_spec.rb @@ -13,7 +13,7 @@ describe API::Variables do it 'returns project variables' do get api("/projects/#{project.id}/variables", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Array) end end @@ -22,7 +22,7 @@ describe API::Variables do it 'does not return project variables' do get api("/projects/#{project.id}/variables", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -30,7 +30,7 @@ describe API::Variables do it 'does not return project variables' do get api("/projects/#{project.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -40,7 +40,7 @@ describe API::Variables do it 'returns project variable details' do get api("/projects/#{project.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['value']).to eq(variable.value) expect(json_response['protected']).to eq(variable.protected?) end @@ -48,7 +48,7 @@ describe API::Variables do it 'responds with 404 Not Found if requesting non-existing variable' do get api("/projects/#{project.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -56,7 +56,7 @@ describe API::Variables do it 'does not return project variable details' do get api("/projects/#{project.id}/variables/#{variable.key}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -64,7 +64,7 @@ describe API::Variables do it 'does not return project variable details' do get api("/projects/#{project.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -76,7 +76,7 @@ describe API::Variables do post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true end.to change {project.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_truthy @@ -87,7 +87,7 @@ describe API::Variables do post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' end.to change {project.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_falsey @@ -98,7 +98,7 @@ describe API::Variables do post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2' end.to change {project.variables.count}.by(0) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -106,7 +106,7 @@ describe API::Variables do it 'does not create variable' do post api("/projects/#{project.id}/variables", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -114,7 +114,7 @@ describe API::Variables do it 'does not create variable' do post api("/projects/#{project.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -129,7 +129,7 @@ describe API::Variables do updated_variable = project.variables.first - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(value_before).to eq(variable.value) expect(updated_variable.value).to eq('VALUE_1_UP') expect(updated_variable).to be_protected @@ -138,7 +138,7 @@ describe API::Variables do it 'responds with 404 Not Found if requesting non-existing variable' do put api("/projects/#{project.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -146,7 +146,7 @@ describe API::Variables do it 'does not update variable' do put api("/projects/#{project.id}/variables/#{variable.key}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -154,7 +154,7 @@ describe API::Variables do it 'does not update variable' do put api("/projects/#{project.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -165,14 +165,14 @@ describe API::Variables do expect do delete api("/projects/#{project.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {project.variables.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing variable' do delete api("/projects/#{project.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -180,7 +180,7 @@ describe API::Variables do it 'does not delete variable' do delete api("/projects/#{project.id}/variables/#{variable.key}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -188,7 +188,7 @@ describe API::Variables do it 'does not delete variable' do delete api("/projects/#{project.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb index 9e889d1eecf..65bd001e491 100644 --- a/spec/requests/api/wikis_spec.rb +++ b/spec/requests/api/wikis_spec.rb @@ -26,7 +26,7 @@ describe API::Wikis do it 'returns the list of wiki pages without content' do get api(url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) json_response.each_with_index do |page, index| @@ -39,7 +39,7 @@ describe API::Wikis do it 'returns the list of wiki pages with content' do get api(url, user), with_content: 1 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) json_response.each_with_index do |page, index| @@ -54,14 +54,14 @@ describe API::Wikis do it 'return the empty list of wiki pages' do get api(url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(0) end end shared_examples_for 'returns wiki page' do it 'returns the wiki page' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(4) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(page.content) @@ -74,7 +74,7 @@ describe API::Wikis do it 'creates the wiki page' do post(api(url, user), payload) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response.size).to eq(4) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(payload[:content]) @@ -89,7 +89,7 @@ describe API::Wikis do post(api(url, user), payload) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response.size).to eq(1) expect(json_response['error']).to eq("#{part} is missing") end @@ -98,7 +98,7 @@ describe API::Wikis do shared_examples_for 'updates wiki page' do it 'updates the wiki page' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(4) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(payload[:content]) @@ -109,7 +109,7 @@ describe API::Wikis do shared_examples_for '403 Forbidden' do it 'returns 403 Forbidden' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response.size).to eq(1) expect(json_response['message']).to eq('403 Forbidden') end @@ -117,7 +117,7 @@ describe API::Wikis do shared_examples_for '404 Wiki Page Not Found' do it 'returns 404 Wiki Page Not Found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response.size).to eq(1) expect(json_response['message']).to eq('404 Wiki Page Not Found') end @@ -125,7 +125,7 @@ describe API::Wikis do shared_examples_for '404 Project Not Found' do it 'returns 404 Project Not Found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response.size).to eq(1) expect(json_response['message']).to eq('404 Project Not Found') end @@ -133,7 +133,7 @@ describe API::Wikis do shared_examples_for '204 No Content' do it 'returns 204 No Content' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end end diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index ecac40e301b..cd52194033a 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -9,7 +9,7 @@ describe 'Git HTTP requests' do context "when no credentials are provided" do it "responds to downloads with status 401 Unauthorized (no project existence information leak)" do download(path) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -18,7 +18,7 @@ describe 'Git HTTP requests' do context "when only username is provided" do it "responds to downloads with status 401 Unauthorized" do download(path, user: user.username) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -28,7 +28,7 @@ describe 'Git HTTP requests' do context "when authentication fails" do it "responds to downloads with status 401 Unauthorized" do download(path, user: user.username, password: "wrong-password") do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -37,7 +37,7 @@ describe 'Git HTTP requests' do context "when authentication succeeds" do it "does not respond to downloads with status 401 Unauthorized" do download(path, user: user.username, password: user.password) do |response| - expect(response).not_to have_http_status(:unauthorized) + expect(response).not_to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to be_nil end end @@ -49,7 +49,7 @@ describe 'Git HTTP requests' do context "when no credentials are provided" do it "responds to uploads with status 401 Unauthorized (no project existence information leak)" do upload(path) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -58,7 +58,7 @@ describe 'Git HTTP requests' do context "when only username is provided" do it "responds to uploads with status 401 Unauthorized" do upload(path, user: user.username) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -68,7 +68,7 @@ describe 'Git HTTP requests' do context "when authentication fails" do it "responds to uploads with status 401 Unauthorized" do upload(path, user: user.username, password: "wrong-password") do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -77,7 +77,7 @@ describe 'Git HTTP requests' do context "when authentication succeeds" do it "does not respond to uploads with status 401 Unauthorized" do upload(path, user: user.username, password: user.password) do |response| - expect(response).not_to have_http_status(:unauthorized) + expect(response).not_to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to be_nil end end @@ -88,7 +88,7 @@ describe 'Git HTTP requests' do shared_examples_for 'pulls are allowed' do it do download(path, env) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -97,7 +97,7 @@ describe 'Git HTTP requests' do shared_examples_for 'pushes are allowed' do it do upload(path, env) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -115,7 +115,7 @@ describe 'Git HTTP requests' do context 'when authenticated' do it 'rejects downloads and uploads with 404 Not Found' do download_or_upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -165,7 +165,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do upload(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_wiki_error(:write_to_wiki)) end end @@ -190,13 +190,13 @@ describe 'Git HTTP requests' do it 'allows clones' do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end it 'pushes are allowed' do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -205,14 +205,14 @@ describe 'Git HTTP requests' do context 'and not on the team' do it 'rejects clones with 404 Not Found' do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:project_not_found)) end end it 'rejects pushes with 404 Not Found' do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:project_not_found)) end end @@ -253,7 +253,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do upload(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:receive_pack_disabled_over_http)) end end @@ -264,7 +264,7 @@ describe 'Git HTTP requests' do allow(Gitlab.config.gitlab_shell).to receive(:upload_pack).and_return(false) download(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:upload_pack_disabled_over_http)) end end @@ -276,7 +276,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do upload(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(change_access_error(:push_code)) end end @@ -332,7 +332,7 @@ describe 'Git HTTP requests' do it 'downloads get status 404 with "project was moved" message' do clone_get(path, {}) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to match(project_moved_message) end end @@ -355,7 +355,7 @@ describe 'Git HTTP requests' do clone_get(path, env) - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -374,7 +374,7 @@ describe 'Git HTTP requests' do project.team << [user, :master] download(path, env) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -382,7 +382,7 @@ describe 'Git HTTP requests' do user.block download('doesnt/exist.git', env) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -392,7 +392,7 @@ describe 'Git HTTP requests' do expect(Rack::Attack::Allow2Ban).to receive(:reset).twice download(path, env) do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -401,7 +401,7 @@ describe 'Git HTTP requests' do expect(Rack::Attack::Allow2Ban).to receive(:reset).twice upload(path, env) do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -440,14 +440,14 @@ describe 'Git HTTP requests' do context 'when username and password are provided' do it 'rejects pulls with personal access token error message' do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end it 'rejects the push attempt with personal access token error message' do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -468,14 +468,14 @@ describe 'Git HTTP requests' do it 'rejects pulls with personal access token error message' do download(path, user: 'foo', password: 'bar') do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end it 'rejects pushes with personal access token error message' do upload(path, user: 'foo', password: 'bar') do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -489,7 +489,7 @@ describe 'Git HTTP requests' do it 'does not display the personal access token error message' do upload(path, user: 'foo', password: 'bar') do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -541,13 +541,13 @@ describe 'Git HTTP requests' do it 'downloads get status 404 with "project was moved" message' do clone_get(path, env) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to match(project_moved_message) end it 'uploads get status 404 with "project was moved" message' do upload(path, env) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to match(project_moved_message) end end @@ -557,13 +557,13 @@ describe 'Git HTTP requests' do context "when the user doesn't have access to the project" do it "pulls get status 404" do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end it "uploads get status 404" do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -595,7 +595,7 @@ describe 'Git HTTP requests' do it "rejects pushes with 403 Forbidden" do push_get(path, env) - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:upload)) end @@ -604,7 +604,7 @@ describe 'Git HTTP requests' do it "rejects pulls for other project with 404 Not Found" do clone_get("#{other_project.full_path}.git", env) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:project_not_found)) end end @@ -627,7 +627,7 @@ describe 'Git HTTP requests' do it 'rejects pulls with 403 Forbidden' do clone_get path, env - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:no_repo)) end end @@ -635,7 +635,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do push_get path, env - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:upload)) end end @@ -648,7 +648,7 @@ describe 'Git HTTP requests' do it 'downloads from other project get status 403' do clone_get "#{other_project.full_path}.git", user: 'gitlab-ci-token', password: build.token - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -660,7 +660,7 @@ describe 'Git HTTP requests' do it 'downloads from other project get status 404' do clone_get "#{other_project.full_path}.git", user: 'gitlab-ci-token', password: build.token - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -748,7 +748,7 @@ describe 'Git HTTP requests' do end it "returns the file" do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end @@ -758,7 +758,7 @@ describe 'Git HTTP requests' do end it "returns not found" do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -783,7 +783,7 @@ describe 'Git HTTP requests' do context "when the project doesn't exist" do it "responds with status 404 Not Found" do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -800,7 +800,7 @@ describe 'Git HTTP requests' do it "responds with status 200" do clone_get(path, env) do |response| - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb index 41bf43a9bce..94e04ce5608 100644 --- a/spec/requests/jwt_controller_spec.rb +++ b/spec/requests/jwt_controller_spec.rb @@ -13,12 +13,12 @@ describe JwtController do context 'existing service' do subject! { get '/jwt/auth', parameters } - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } context 'returning custom http code' do let(:service) { double(execute: { http_status: 505 }) } - it { expect(response).to have_http_status(505) } + it { expect(response).to have_gitlab_http_status(505) } end end @@ -41,7 +41,7 @@ describe JwtController do subject! { get '/jwt/auth', parameters, headers } - it { expect(response).to have_http_status(401) } + it { expect(response).to have_gitlab_http_status(401) } end context 'using personal access tokens' do @@ -56,7 +56,7 @@ describe JwtController do subject! { get '/jwt/auth', parameters, headers } it 'authenticates correctly' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(service_class).to have_received(:new).with(nil, user, parameters) end end @@ -75,7 +75,7 @@ describe JwtController do context 'without personal token' do it 'rejects the authorization attempt' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -85,7 +85,7 @@ describe JwtController do let(:headers) { { authorization: credentials(user.username, access_token.token) } } it 'accepts the authorization attempt' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -98,7 +98,7 @@ describe JwtController do it 'rejects the authorization attempt' do get '/jwt/auth', parameters, headers - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -108,7 +108,7 @@ describe JwtController do allow_any_instance_of(ApplicationSetting).to receive(:password_authentication_enabled?) { false } get '/jwt/auth', parameters, headers - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -119,7 +119,7 @@ describe JwtController do it 'accepts the authorization attempt' do get '/jwt/auth', parameters - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'allows read access' do @@ -132,7 +132,7 @@ describe JwtController do context 'unknown service' do subject! { get '/jwt/auth', service: 'unknown' } - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end def credentials(login, password) diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index bca5bf81c5c..52e93e157f1 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -41,7 +41,7 @@ describe 'Git LFS API and storage' do end it 'responds with 501' do - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) expect(json_response).to include('message' => 'Git LFS is not enabled on this GitLab server, contact your admin.') end end @@ -75,13 +75,13 @@ describe 'Git LFS API and storage' do it 'responds with a 501 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end it 'responds with a 501 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end end @@ -93,13 +93,13 @@ describe 'Git LFS API and storage' do it 'responds with a 501 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end it 'responds with a 501 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end end end @@ -118,14 +118,14 @@ describe 'Git LFS API and storage' do it 'responds with a 403 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response).to include('message' => 'Access forbidden. Check your access level.') end it 'responds with a 403 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response).to include('message' => 'Access forbidden. Check your access level.') end end @@ -138,14 +138,14 @@ describe 'Git LFS API and storage' do it 'responds with a 200 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['objects'].first['size']).to eq(1575078) end it 'responds with a 200 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -160,7 +160,7 @@ describe 'Git LFS API and storage' do shared_examples 'a deprecated' do it 'responds with 501' do - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end it 'returns deprecated message' do @@ -201,7 +201,7 @@ describe 'Git LFS API and storage' do context 'and request comes from gitlab-workhorse' do context 'without user being authorized' do it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -210,7 +210,7 @@ describe 'Git LFS API and storage' do let(:sendfile) { 'X-Sendfile' } it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with the file location' do @@ -228,7 +228,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -272,7 +272,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -311,7 +311,7 @@ describe 'Git LFS API and storage' do end it 'rejects downloading code' do - expect(response).to have_http_status(other_project_status) + expect(response).to have_gitlab_http_status(other_project_status) end end end @@ -351,7 +351,7 @@ describe 'Git LFS API and storage' do let(:authorization) { authorize_user } it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -387,7 +387,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with href to download' do @@ -415,7 +415,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with href to download' do @@ -446,7 +446,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with an 404 for specific object' do @@ -483,7 +483,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with upload hypermedia link for the new object' do @@ -528,7 +528,7 @@ describe 'Git LFS API and storage' do let(:update_user_permissions) { nil } it 'responds with 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -536,7 +536,7 @@ describe 'Git LFS API and storage' do let(:role) { :guest } it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -564,7 +564,7 @@ describe 'Git LFS API and storage' do let(:pipeline) { create(:ci_empty_pipeline, project: other_project) } it 'rejects downloading code' do - expect(response).to have_http_status(other_project_status) + expect(response).to have_gitlab_http_status(other_project_status) end end end @@ -608,7 +608,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200 and href to download' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with status 200 and href to download' do @@ -636,7 +636,7 @@ describe 'Git LFS API and storage' do end it 'responds with authorization required' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -669,7 +669,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with links the object to the project' do @@ -695,7 +695,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with upload hypermedia link' do @@ -725,7 +725,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with upload hypermedia link for the new object' do @@ -747,7 +747,7 @@ describe 'Git LFS API and storage' do let(:authorization) { authorize_user } it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -761,7 +761,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -772,7 +772,7 @@ describe 'Git LFS API and storage' do # I'm not sure what this tests that is different from the previous test it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -781,7 +781,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -794,13 +794,13 @@ describe 'Git LFS API and storage' do end it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when user does not have push access' do it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -820,7 +820,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -865,7 +865,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -875,7 +875,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -885,7 +885,7 @@ describe 'Git LFS API and storage' do end it 'does not recognize it as a valid lfs command' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -897,7 +897,7 @@ describe 'Git LFS API and storage' do end it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -907,7 +907,7 @@ describe 'Git LFS API and storage' do end it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -917,7 +917,7 @@ describe 'Git LFS API and storage' do end it 'does not recognize it as a valid lfs command' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -945,7 +945,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'uses the gitlab-workhorse content type' do @@ -965,7 +965,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'lfs object is linked to the project' do @@ -976,12 +976,12 @@ describe 'Git LFS API and storage' do context 'invalid tempfiles' do it 'rejects slashes in the tempfile name (path traversal' do put_finalize('foo/bar') - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'rejects tempfile names that do not start with the oid' do put_finalize("foo#{sample_oid}") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1010,7 +1010,7 @@ describe 'Git LFS API and storage' do end it 'responds with 403 (not 404 because the build user can read the project)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1024,7 +1024,7 @@ describe 'Git LFS API and storage' do end it 'responds with 404 (do not leak non-public project existence)' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1037,7 +1037,7 @@ describe 'Git LFS API and storage' do end it 'responds with 404 (do not leak non-public project existence)' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1066,7 +1066,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with location of lfs store and object details' do @@ -1082,7 +1082,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'lfs object is linked to the source project' do @@ -1110,7 +1110,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1121,7 +1121,7 @@ describe 'Git LFS API and storage' do # I'm not sure what this tests that is different from the previous test it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1130,7 +1130,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1155,7 +1155,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'links the lfs object to the project' do diff --git a/spec/requests/openid_connect_spec.rb b/spec/requests/openid_connect_spec.rb index a927de952d0..0b1f8ce6f6d 100644 --- a/spec/requests/openid_connect_spec.rb +++ b/spec/requests/openid_connect_spec.rb @@ -37,7 +37,7 @@ describe 'OpenID Connect requests' do it 'userinfo response is unauthorized' do request_user_info - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 expect(response.body).to be_blank end end diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index 6667ce771bd..286d8a884a4 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -99,19 +99,19 @@ describe 'cycle analytics events' do it 'does not list the test events' do get project_cycle_analytics_test_path(project, format: :json) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end it 'does not list the staging events' do get project_cycle_analytics_staging_path(project, format: :json) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end it 'lists the issue events' do get project_cycle_analytics_issue_path(project, format: :json) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end end |