Commit a02dfe61 authored by Peter Leitzen's avatar Peter Leitzen

Add http status cop to api specs a-p

243 files inspected, 539 offenses detected, 539 offenses corrected
parent 870b6dc6
...@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus: ...@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/requests/{groups,projects,repositories}/**/*' - 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb' - 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb' - 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-o]*.rb' - 'spec/requests/api/[a-p]*.rb'
- 'ee/spec/requests/api/[a-o]*.rb' - 'ee/spec/requests/api/[a-p]*.rb'
Style/MultilineWhenThen: Style/MultilineWhenThen:
Enabled: false Enabled: false
......
...@@ -23,13 +23,13 @@ describe API::PackageFiles do ...@@ -23,13 +23,13 @@ describe API::PackageFiles do
it 'returns 200' do it 'returns 200' do
get api(url) get api(url)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'returns 404 if package does not exist' do it 'returns 404 if package does not exist' do
get api("/projects/#{project.id}/packages/0/package_files") get api("/projects/#{project.id}/packages/0/package_files")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -39,7 +39,7 @@ describe API::PackageFiles do ...@@ -39,7 +39,7 @@ describe API::PackageFiles do
it 'returns 404 for non authenticated user' do it 'returns 404 for non authenticated user' do
get api(url) get api(url)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 for a user without access to the project' do it 'returns 404 for a user without access to the project' do
...@@ -47,13 +47,13 @@ describe API::PackageFiles do ...@@ -47,13 +47,13 @@ describe API::PackageFiles do
get api(url, user) get api(url, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 200 and valid response schema' do it 'returns 200 and valid response schema' do
get api(url, user) get api(url, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package_files', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package_files', dir: 'ee')
end end
end end
...@@ -94,7 +94,7 @@ describe API::PackageFiles do ...@@ -94,7 +94,7 @@ describe API::PackageFiles do
it 'returns 403' do it 'returns 403' do
get api(url, user) get api(url, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
......
...@@ -13,7 +13,7 @@ describe API::ProjectAliases, api: true do ...@@ -13,7 +13,7 @@ describe API::ProjectAliases, api: true do
end end
it 'returns 403' do it 'returns 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -25,7 +25,7 @@ describe API::ProjectAliases, api: true do ...@@ -25,7 +25,7 @@ describe API::ProjectAliases, api: true do
end end
it 'returns 403' do it 'returns 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -37,7 +37,7 @@ describe API::ProjectAliases, api: true do ...@@ -37,7 +37,7 @@ describe API::ProjectAliases, api: true do
end end
it 'returns 403' do it 'returns 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -49,7 +49,7 @@ describe API::ProjectAliases, api: true do ...@@ -49,7 +49,7 @@ describe API::ProjectAliases, api: true do
end end
it 'returns 403' do it 'returns 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -60,13 +60,13 @@ describe API::ProjectAliases, api: true do ...@@ -60,13 +60,13 @@ describe API::ProjectAliases, api: true do
let(:user) { nil } let(:user) { nil }
it 'returns 401' do it 'returns 401' do
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
context 'regular user' do context 'regular user' do
it 'returns 403' do it 'returns 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -88,7 +88,7 @@ describe API::ProjectAliases, api: true do ...@@ -88,7 +88,7 @@ describe API::ProjectAliases, api: true do
let!(:project_alias_2) { create(:project_alias) } let!(:project_alias_2) { create(:project_alias) }
it 'returns the project aliases list' do it 'returns the project aliases list' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project_aliases', dir: 'ee') expect(response).to match_response_schema('public_api/v4/project_aliases', dir: 'ee')
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
end end
...@@ -110,7 +110,7 @@ describe API::ProjectAliases, api: true do ...@@ -110,7 +110,7 @@ describe API::ProjectAliases, api: true do
context 'existing project alias' do context 'existing project alias' do
it 'returns the project alias' do it 'returns the project alias' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project_alias', dir: 'ee') expect(response).to match_response_schema('public_api/v4/project_alias', dir: 'ee')
end end
end end
...@@ -119,7 +119,7 @@ describe API::ProjectAliases, api: true do ...@@ -119,7 +119,7 @@ describe API::ProjectAliases, api: true do
let(:alias_name) { 'some-project' } let(:alias_name) { 'some-project' }
it 'returns 404' do it 'returns 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -141,7 +141,7 @@ describe API::ProjectAliases, api: true do ...@@ -141,7 +141,7 @@ describe API::ProjectAliases, api: true do
context 'existing project alias' do context 'existing project alias' do
it 'returns 400' do it 'returns 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -149,7 +149,7 @@ describe API::ProjectAliases, api: true do ...@@ -149,7 +149,7 @@ describe API::ProjectAliases, api: true do
let(:alias_name) { 'some-project' } let(:alias_name) { 'some-project' }
it 'returns 200' do it 'returns 200' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/project_alias', dir: 'ee') expect(response).to match_response_schema('public_api/v4/project_alias', dir: 'ee')
end end
end end
...@@ -171,7 +171,7 @@ describe API::ProjectAliases, api: true do ...@@ -171,7 +171,7 @@ describe API::ProjectAliases, api: true do
context 'existing project alias' do context 'existing project alias' do
it 'returns 204' do it 'returns 204' do
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
...@@ -179,7 +179,7 @@ describe API::ProjectAliases, api: true do ...@@ -179,7 +179,7 @@ describe API::ProjectAliases, api: true do
let(:alias_name) { 'some-project' } let(:alias_name) { 'some-project' }
it 'returns 404' do it 'returns 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -29,7 +29,7 @@ describe API::ProjectApprovalRules do ...@@ -29,7 +29,7 @@ describe API::ProjectApprovalRules do
it 'matches the response schema' do it 'matches the response schema' do
get api(url, developer) get api(url, developer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project_approval_rules', dir: 'ee') expect(response).to match_response_schema('public_api/v4/project_approval_rules', dir: 'ee')
json = json_response json = json_response
......
...@@ -29,7 +29,7 @@ describe API::ProjectApprovalSettings do ...@@ -29,7 +29,7 @@ describe API::ProjectApprovalSettings do
it 'matches the response schema' do it 'matches the response schema' do
get api(url, developer) get api(url, developer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project_approval_settings', dir: 'ee') expect(response).to match_response_schema('public_api/v4/project_approval_settings', dir: 'ee')
json = json_response json = json_response
......
...@@ -21,7 +21,7 @@ describe API::ProjectApprovals do ...@@ -21,7 +21,7 @@ describe API::ProjectApprovals do
end end
it 'returns 200 status' do it 'returns 200 status' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'matches the response schema' do it 'matches the response schema' do
...@@ -46,7 +46,7 @@ describe API::ProjectApprovals do ...@@ -46,7 +46,7 @@ describe API::ProjectApprovals do
it 'returns 400 status' do it 'returns 400 status' do
post api(url, current_user) post api(url, current_user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -54,7 +54,7 @@ describe API::ProjectApprovals do ...@@ -54,7 +54,7 @@ describe API::ProjectApprovals do
it 'returns 201 status' do it 'returns 201 status' do
post api(url, current_user), params: { approvals_before_merge: 3 } post api(url, current_user), params: { approvals_before_merge: 3 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'matches the response schema' do it 'matches the response schema' do
...@@ -169,7 +169,7 @@ describe API::ProjectApprovals do ...@@ -169,7 +169,7 @@ describe API::ProjectApprovals do
it 'returns 403' do it 'returns 403' do
post api(url, user2), params: { approvals_before_merge: 4 } post api(url, user2), params: { approvals_before_merge: 4 }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -185,7 +185,7 @@ describe API::ProjectApprovals do ...@@ -185,7 +185,7 @@ describe API::ProjectApprovals do
put api(url, current_user), params: { approver_ids: [], approver_group_ids: [] }.to_json, headers: { CONTENT_TYPE: 'application/json' } put api(url, current_user), params: { approver_ids: [], approver_group_ids: [] }.to_json, headers: { CONTENT_TYPE: 'application/json' }
end.to change { project.approvers.count }.from(1).to(0) end.to change { project.approvers.count }.from(1).to(0)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvers']).to be_empty expect(json_response['approvers']).to be_empty
expect(json_response['approver_groups']).to be_empty expect(json_response['approver_groups']).to be_empty
end end
...@@ -198,7 +198,7 @@ describe API::ProjectApprovals do ...@@ -198,7 +198,7 @@ describe API::ProjectApprovals do
put api(url, current_user), params: { approver_ids: '', approver_group_ids: '' } put api(url, current_user), params: { approver_ids: '', approver_group_ids: '' }
end.to change { project.approvers.count }.from(1).to(0) end.to change { project.approvers.count }.from(1).to(0)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvers']).to be_empty expect(json_response['approvers']).to be_empty
expect(json_response['approver_groups']).to be_empty expect(json_response['approver_groups']).to be_empty
end end
...@@ -215,7 +215,7 @@ describe API::ProjectApprovals do ...@@ -215,7 +215,7 @@ describe API::ProjectApprovals do
expect(project.approvers.first.user_id).to eq(approver.id) expect(project.approvers.first.user_id).to eq(approver.id)
expect(project.approver_groups.first.group_id).to eq(group.id) expect(project.approver_groups.first.group_id).to eq(group.id)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvers'][0]['user']['username']).to eq(approver.username) expect(json_response['approvers'][0]['user']['username']).to eq(approver.username)
expect(json_response['approver_groups'][0]['group']['name']).to eq(group.name) expect(json_response['approver_groups'][0]['group']['name']).to eq(group.name)
end end
...@@ -255,7 +255,7 @@ describe API::ProjectApprovals do ...@@ -255,7 +255,7 @@ describe API::ProjectApprovals do
put api(url, user2), params: { approver_ids: [], approver_group_ids: [] }.to_json, headers: { CONTENT_TYPE: 'application/json' } put api(url, user2), params: { approver_ids: [], approver_group_ids: [] }.to_json, headers: { CONTENT_TYPE: 'application/json' }
end.not_to change { project.approvers.count } end.not_to change { project.approvers.count }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
......
...@@ -90,7 +90,7 @@ describe API::ProjectClusters do ...@@ -90,7 +90,7 @@ describe API::ProjectClusters do
end end
it 'responds with 201' do it 'responds with 201' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'allows multiple clusters to be associated to project' do it 'allows multiple clusters to be associated to project' do
......
...@@ -17,7 +17,7 @@ describe API::ProjectMilestones do ...@@ -17,7 +17,7 @@ describe API::ProjectMilestones do
it 'matches V4 EE-specific response schema for a list of issues' do it 'matches V4 EE-specific response schema for a list of issues' do
get api(issues_route, user) get api(issues_route, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/issues', dir: 'ee') expect(response).to match_response_schema('public_api/v4/issues', dir: 'ee')
end end
......
...@@ -104,7 +104,7 @@ describe API::ProjectPackages do ...@@ -104,7 +104,7 @@ describe API::ProjectPackages do
it 'returns 403' do it 'returns 403' do
get api(url, user) get api(url, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -137,20 +137,20 @@ describe API::ProjectPackages do ...@@ -137,20 +137,20 @@ describe API::ProjectPackages do
it 'returns 200 and the package information' do it 'returns 200 and the package information' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package', dir: 'ee')
end end
it 'returns 404 when the package does not exist' do it 'returns 404 when the package does not exist' do
get api(no_package_url, user) get api(no_package_url, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 for the package from a different project' do it 'returns 404 for the package from a different project' do
get api(wrong_package_url, user) get api(wrong_package_url, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it_behaves_like 'no destroy url' it_behaves_like 'no destroy url'
...@@ -162,13 +162,13 @@ describe API::ProjectPackages do ...@@ -162,13 +162,13 @@ describe API::ProjectPackages do
it 'returns 404 for non authenticated user' do it 'returns 404 for non authenticated user' do
get api(package_url) get api(package_url)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 for a user without access to the project' do it 'returns 404 for a user without access to the project' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'user is a developer' do context 'user is a developer' do
...@@ -179,7 +179,7 @@ describe API::ProjectPackages do ...@@ -179,7 +179,7 @@ describe API::ProjectPackages do
it 'returns 200 and the package information' do it 'returns 200 and the package information' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package', dir: 'ee')
end end
...@@ -202,7 +202,7 @@ describe API::ProjectPackages do ...@@ -202,7 +202,7 @@ describe API::ProjectPackages do
get api(package_url, user) get api(package_url, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package_with_build', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package_with_build', dir: 'ee')
end end
end end
...@@ -217,7 +217,7 @@ describe API::ProjectPackages do ...@@ -217,7 +217,7 @@ describe API::ProjectPackages do
it 'returns 403' do it 'returns 403' do
subject subject
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -232,13 +232,13 @@ describe API::ProjectPackages do ...@@ -232,13 +232,13 @@ describe API::ProjectPackages do
it 'returns 403 for non authenticated user' do it 'returns 403 for non authenticated user' do
delete api(package_url) delete api(package_url)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'returns 403 for a user without access to the project' do it 'returns 403 for a user without access to the project' do
delete api(package_url, user) delete api(package_url, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -248,13 +248,13 @@ describe API::ProjectPackages do ...@@ -248,13 +248,13 @@ describe API::ProjectPackages do
it 'returns 404 for non authenticated user' do it 'returns 404 for non authenticated user' do
delete api(package_url) delete api(package_url)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 for a user without access to the project' do it 'returns 404 for a user without access to the project' do
delete api(package_url, user) delete api(package_url, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 when the package does not exist' do it 'returns 404 when the package does not exist' do
...@@ -262,7 +262,7 @@ describe API::ProjectPackages do ...@@ -262,7 +262,7 @@ describe API::ProjectPackages do
delete api(no_package_url, user) delete api(no_package_url, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 for the package from a different project' do it 'returns 404 for the package from a different project' do
...@@ -270,7 +270,7 @@ describe API::ProjectPackages do ...@@ -270,7 +270,7 @@ describe API::ProjectPackages do
delete api(wrong_package_url, user) delete api(wrong_package_url, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 403 for a user without enough permissions' do it 'returns 403 for a user without enough permissions' do
...@@ -278,7 +278,7 @@ describe API::ProjectPackages do ...@@ -278,7 +278,7 @@ describe API::ProjectPackages do
delete api(package_url, user) delete api(package_url, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'returns 204' do it 'returns 204' do
...@@ -286,7 +286,7 @@ describe API::ProjectPackages do ...@@ -286,7 +286,7 @@ describe API::ProjectPackages do
delete api(package_url, user) delete api(package_url, user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
end end
...@@ -299,7 +299,7 @@ describe API::ProjectPackages do ...@@ -299,7 +299,7 @@ describe API::ProjectPackages do
it 'returns 403' do it 'returns 403' do
delete api(package_url, user) delete api(package_url, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
......
...@@ -35,7 +35,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -35,7 +35,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
end end
it "returns project push rule" do it "returns project push rule" do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash expect(json_response).to be_an Hash
expect(json_response['project_id']).to eq(project.id) expect(json_response['project_id']).to eq(project.id)
end end
...@@ -66,7 +66,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -66,7 +66,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false } let(:ruc_enabled) { false }
it 'succeeds' do it 'succeeds' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'does not return the reject_unsigned_commits information' do it 'does not return the reject_unsigned_commits information' do
...@@ -78,7 +78,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -78,7 +78,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:push_rules_enabled) { false } let(:push_rules_enabled) { false }
it 'is forbidden' do it 'is forbidden' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -87,7 +87,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -87,7 +87,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "does not have access to project push rule" do it "does not have access to project push rule" do
get api("/projects/#{project.id}/push_rule", user3) get api("/projects/#{project.id}/push_rule", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -119,7 +119,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -119,7 +119,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ccc_enabled) { false } let(:ccc_enabled) { false }
it "is forbidden to use this service" do it "is forbidden to use this service" do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -127,12 +127,12 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -127,12 +127,12 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false } let(:ruc_enabled) { false }
it "is forbidden to use this service" do it "is forbidden to use this service" do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
it "is accepted" do it "is accepted" do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it "indicates that it belongs to the correct project" do it "indicates that it belongs to the correct project" do
...@@ -147,7 +147,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -147,7 +147,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ccc_enabled) { false } let(:ccc_enabled) { false }
it "is forbidden to send the the :commit_committer_check parameter" do it "is forbidden to send the the :commit_committer_check parameter" do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
context "without the :commit_committer_check parameter" do context "without the :commit_committer_check parameter" do
...@@ -172,7 +172,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -172,7 +172,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false } let(:ruc_enabled) { false }
it "is forbidden to send the the :reject_unsigned_commits parameter" do it "is forbidden to send the the :reject_unsigned_commits parameter" do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
context "without the :reject_unsigned_commits parameter" do context "without the :reject_unsigned_commits parameter" do
...@@ -198,7 +198,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -198,7 +198,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
post api("/projects/#{project.id}/push_rule", user), post api("/projects/#{project.id}/push_rule", user),
params: { commit_message_regex: 'JIRA\-\d+' } params: { commit_message_regex: 'JIRA\-\d+' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['project_id']).to eq(project.id) expect(json_response['project_id']).to eq(project.id)
expect(json_response['commit_message_regex']).to eq('JIRA\-\d+') expect(json_response['commit_message_regex']).to eq('JIRA\-\d+')
expect(json_response['max_file_size']).to eq(0) expect(json_response['max_file_size']).to eq(0)
...@@ -207,14 +207,14 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -207,14 +207,14 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it 'returns 400 if no parameter is given' do it 'returns 400 if no parameter is given' do
post api("/projects/#{project.id}/push_rule", user) post api("/projects/#{project.id}/push_rule", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context "user with developer_access" do context "user with developer_access" do
it "does not add push rule to project" do it "does not add push rule to project" do
post api("/projects/#{project.id}/push_rule", user3), params: rules_params post api("/projects/#{project.id}/push_rule", user3), params: rules_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -228,7 +228,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -228,7 +228,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "does not add push rule to project" do it "does not add push rule to project" do
post api("/projects/#{project.id}/push_rule", user), params: { deny_delete_tag: true } post api("/projects/#{project.id}/push_rule", user), params: { deny_delete_tag: true }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
end end
...@@ -246,7 +246,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -246,7 +246,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
end end
it "is successful" do it "is successful" do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'includes the expected settings' do it 'includes the expected settings' do
...@@ -259,7 +259,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -259,7 +259,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:new_settings) { { commit_committer_check: true } } let(:new_settings) { { commit_committer_check: true } }
it "is successful" do it "is successful" do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it "sets the commit_committer_check" do it "sets the commit_committer_check" do
...@@ -270,7 +270,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -270,7 +270,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ccc_enabled) { false } let(:ccc_enabled) { false }
it "is an error to provide this parameter" do it "is an error to provide this parameter" do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -279,7 +279,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -279,7 +279,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:new_settings) { { reject_unsigned_commits: true } } let(:new_settings) { { reject_unsigned_commits: true } }
it "is successful" do it "is successful" do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it "sets the reject_unsigned_commits" do it "sets the reject_unsigned_commits" do
...@@ -290,7 +290,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -290,7 +290,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false } let(:ruc_enabled) { false }
it "is an error to provide the this parameter" do it "is an error to provide the this parameter" do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -299,7 +299,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -299,7 +299,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:new_settings) { {} } let(:new_settings) { {} }
it "is an error" do it "is an error" do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -309,13 +309,13 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -309,13 +309,13 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
put api("/projects/#{project.id}/push_rule", user), put api("/projects/#{project.id}/push_rule", user),
params: { deny_delete_tag: false, commit_message_regex: 'Fixes \d+\..*' } params: { deny_delete_tag: false, commit_message_regex: 'Fixes \d+\..*' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "does not update push rule for unauthorized user" do it "does not update push rule for unauthorized user" do
post api("/projects/#{project.id}/push_rule", user3), params: { deny_delete_tag: true } post api("/projects/#{project.id}/push_rule", user3), params: { deny_delete_tag: true }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -328,7 +328,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -328,7 +328,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "deletes push rule from project" do it "deletes push rule from project" do
delete api("/projects/#{project.id}/push_rule", user) delete api("/projects/#{project.id}/push_rule", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
...@@ -336,7 +336,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -336,7 +336,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "returns a 403 error" do it "returns a 403 error" do
delete api("/projects/#{project.id}/push_rule", user3) delete api("/projects/#{project.id}/push_rule", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -346,7 +346,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -346,7 +346,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "deletes push rule from project" do it "deletes push rule from project" do
delete api("/projects/#{project.id}/push_rule", user) delete api("/projects/#{project.id}/push_rule", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response).to be_an Hash expect(json_response).to be_an Hash
expect(json_response['message']).to eq('404 Push Rule Not Found') expect(json_response['message']).to eq('404 Push Rule Not Found')
end end
...@@ -354,7 +354,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do ...@@ -354,7 +354,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "returns a 403 error if not authorized" do it "returns a 403 error if not authorized" do
delete api("/projects/#{project.id}/push_rule", user3) delete api("/projects/#{project.id}/push_rule", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
......
...@@ -21,7 +21,7 @@ describe API::ProjectSnapshots do ...@@ -21,7 +21,7 @@ describe API::ProjectSnapshots do
get api("/projects/#{project.id}/snapshot", nil), params: {}, headers: req.headers get api("/projects/#{project.id}/snapshot", nil), params: {}, headers: req.headers
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
This diff is collapsed.
...@@ -18,7 +18,7 @@ describe API::ProtectedBranches do ...@@ -18,7 +18,7 @@ describe API::ProtectedBranches do
it 'returns the protected branch' do it 'returns the protected branch' do
get api(route, user) get api(route, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['unprotect_access_levels']).to eq([]) expect(json_response['unprotect_access_levels']).to eq([])
end end
...@@ -43,7 +43,7 @@ describe API::ProtectedBranches do ...@@ -43,7 +43,7 @@ describe API::ProtectedBranches do
merge_group_ids = json_response['merge_access_levels'].map {|level| level['group_id']} merge_group_ids = json_response['merge_access_levels'].map {|level| level['group_id']}
unprotect_group_ids = json_response['unprotect_access_levels'].map {|level| level['group_id']} unprotect_group_ids = json_response['unprotect_access_levels'].map {|level| level['group_id']}
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(push_user_ids).to include(push_user.id) expect(push_user_ids).to include(push_user.id)
expect(merge_group_ids).to include(merge_group.id) expect(merge_group_ids).to include(merge_group.id)
expect(unprotect_group_ids).to include(unprotect_group.id) expect(unprotect_group_ids).to include(unprotect_group.id)
...@@ -100,7 +100,7 @@ describe API::ProtectedBranches do ...@@ -100,7 +100,7 @@ describe API::ProtectedBranches do
patch api(route, user), params: { code_owner_approval_required: true } patch api(route, user), params: { code_owner_approval_required: true }
end.to change { protected_branch.reload.code_owner_approval_required } end.to change { protected_branch.reload.code_owner_approval_required }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['code_owner_approval_required']).to eq(true) expect(json_response['code_owner_approval_required']).to eq(true)
end end
end end
...@@ -115,7 +115,7 @@ describe API::ProtectedBranches do ...@@ -115,7 +115,7 @@ describe API::ProtectedBranches do
patch api(route, user), params: { code_owner_approval_required: true } patch api(route, user), params: { code_owner_approval_required: true }
end.not_to change { protected_branch.reload.code_owner_approval_required } end.not_to change { protected_branch.reload.code_owner_approval_required }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -128,7 +128,7 @@ describe API::ProtectedBranches do ...@@ -128,7 +128,7 @@ describe API::ProtectedBranches do
it "returns a 403 response" do it "returns a 403 response" do
patch api(route, user) patch api(route, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -138,7 +138,7 @@ describe API::ProtectedBranches do ...@@ -138,7 +138,7 @@ describe API::ProtectedBranches do
let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) } let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) }
def expect_protection_to_be_successful def expect_protection_to_be_successful
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
end end
...@@ -150,14 +150,14 @@ describe API::ProtectedBranches do ...@@ -150,14 +150,14 @@ describe API::ProtectedBranches do
it 'protects a single branch' do it 'protects a single branch' do
post post_endpoint, params: { name: branch_name } post post_endpoint, params: { name: branch_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['unprotect_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['unprotect_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
end end
it 'protects a single branch and only admins can unprotect' do it 'protects a single branch and only admins can unprotect' do
post post_endpoint, params: { name: branch_name, unprotect_access_level: Gitlab::Access::ADMIN } post post_endpoint, params: { name: branch_name, unprotect_access_level: Gitlab::Access::ADMIN }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -175,7 +175,7 @@ describe API::ProtectedBranches do ...@@ -175,7 +175,7 @@ describe API::ProtectedBranches do
post post_endpoint, params: { name: branch_name, code_owner_approval_required: true } post post_endpoint, params: { name: branch_name, code_owner_approval_required: true }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["code_owner_approval_required"]).to eq(true) expect(json_response["code_owner_approval_required"]).to eq(true)
new_branch = project.protected_branches.find_by_name(branch_name) new_branch = project.protected_branches.find_by_name(branch_name)
...@@ -188,7 +188,7 @@ describe API::ProtectedBranches do ...@@ -188,7 +188,7 @@ describe API::ProtectedBranches do
post post_endpoint, params: { name: branch_name, code_owner_approval_required: false } post post_endpoint, params: { name: branch_name, code_owner_approval_required: false }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["code_owner_approval_required"]).to eq(false) expect(json_response["code_owner_approval_required"]).to eq(false)
new_branch = project.protected_branches.find_by_name(branch_name) new_branch = project.protected_branches.find_by_name(branch_name)
...@@ -203,7 +203,7 @@ describe API::ProtectedBranches do ...@@ -203,7 +203,7 @@ describe API::ProtectedBranches do
post post_endpoint, params: { name: branch_name, code_owner_approval_required: true } post post_endpoint, params: { name: branch_name, code_owner_approval_required: true }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["code_owner_approval_required"]).to eq(false) expect(json_response["code_owner_approval_required"]).to eq(false)
new_branch = project.protected_branches.find_by_name(branch_name) new_branch = project.protected_branches.find_by_name(branch_name)
...@@ -281,7 +281,7 @@ describe API::ProtectedBranches do ...@@ -281,7 +281,7 @@ describe API::ProtectedBranches do
post post_endpoint, params: { name: branch_name, allowed_to_merge: [{ user_id: push_user.id }] } post post_endpoint, params: { name: branch_name, allowed_to_merge: [{ user_id: push_user.id }] }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['message'][0]).to match(/is not a member of the project/) expect(json_response['message'][0]).to match(/is not a member of the project/)
end end
...@@ -290,7 +290,7 @@ describe API::ProtectedBranches do ...@@ -290,7 +290,7 @@ describe API::ProtectedBranches do
post post_endpoint, params: { name: branch_name, allowed_to_merge: [{ group_id: merge_group.id }] } post post_endpoint, params: { name: branch_name, allowed_to_merge: [{ group_id: merge_group.id }] }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['message'][0]).to match(/does not have access to the project/) expect(json_response['message'][0]).to match(/does not have access to the project/)
end end
...@@ -299,7 +299,7 @@ describe API::ProtectedBranches do ...@@ -299,7 +299,7 @@ describe API::ProtectedBranches do
post post_endpoint, params: { name: branch_name, allowed_to_push: [{ user_id: push_user.id }] } post post_endpoint, params: { name: branch_name, allowed_to_push: [{ user_id: push_user.id }] }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['push_access_levels'].count).to eq(1) expect(json_response['push_access_levels'].count).to eq(1)
expect(json_response['merge_access_levels'].count).to eq(1) expect(json_response['merge_access_levels'].count).to eq(1)
expect(json_response['push_access_levels'][0]['user_id']).to eq(push_user.id) expect(json_response['push_access_levels'][0]['user_id']).to eq(push_user.id)
......
...@@ -32,7 +32,7 @@ describe API::ProtectedEnvironments do ...@@ -32,7 +32,7 @@ describe API::ProtectedEnvironments do
it 'returns the protected environments' do it 'returns the protected environments' do
request request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -57,7 +57,7 @@ describe API::ProtectedEnvironments do ...@@ -57,7 +57,7 @@ describe API::ProtectedEnvironments do
it 'returns the protected environment' do it 'returns the protected environment' do
request request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee') expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee')
expect(json_response['name']).to eq(protected_environment_name) expect(json_response['name']).to eq(protected_environment_name)
expect(json_response['deploy_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) expect(json_response['deploy_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
...@@ -89,7 +89,7 @@ describe API::ProtectedEnvironments do ...@@ -89,7 +89,7 @@ describe API::ProtectedEnvironments do
post api_url, params: { name: 'staging', deploy_access_levels: [{ user_id: deployer.id }] } post api_url, params: { name: 'staging', deploy_access_levels: [{ user_id: deployer.id }] }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee') expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee')
expect(json_response['name']).to eq('staging') expect(json_response['name']).to eq('staging')
expect(json_response['deploy_access_levels'].first['user_id']).to eq(deployer.id) expect(json_response['deploy_access_levels'].first['user_id']).to eq(deployer.id)
...@@ -100,7 +100,7 @@ describe API::ProtectedEnvironments do ...@@ -100,7 +100,7 @@ describe API::ProtectedEnvironments do
post api_url, params: { name: 'staging', deploy_access_levels: [{ group_id: group.id }] } post api_url, params: { name: 'staging', deploy_access_levels: [{ group_id: group.id }] }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee') expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee')
expect(json_response['name']).to eq('staging') expect(json_response['name']).to eq('staging')
expect(json_response['deploy_access_levels'].first['group_id']).to eq(group.id) expect(json_response['deploy_access_levels'].first['group_id']).to eq(group.id)
...@@ -109,7 +109,7 @@ describe API::ProtectedEnvironments do ...@@ -109,7 +109,7 @@ describe API::ProtectedEnvironments do
it 'protects the environment with maintainers allowed to deploy' do it 'protects the environment with maintainers allowed to deploy' do
post api_url, params: { name: 'staging', deploy_access_levels: [{ access_level: Gitlab::Access::MAINTAINER }] } post api_url, params: { name: 'staging', deploy_access_levels: [{ access_level: Gitlab::Access::MAINTAINER }] }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee') expect(response).to match_response_schema('public_api/v4/protected_environment', dir: 'ee')
expect(json_response['name']).to eq('staging') expect(json_response['name']).to eq('staging')
expect(json_response['deploy_access_levels'].first['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['deploy_access_levels'].first['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -121,7 +121,7 @@ describe API::ProtectedEnvironments do ...@@ -121,7 +121,7 @@ describe API::ProtectedEnvironments do
post api_url, params: { name: 'production', deploy_access_levels: [{ user_id: deployer.id }] } post api_url, params: { name: 'production', deploy_access_levels: [{ user_id: deployer.id }] }
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
end end
context 'without deploy_access_levels' do context 'without deploy_access_levels' do
...@@ -133,7 +133,7 @@ describe API::ProtectedEnvironments do ...@@ -133,7 +133,7 @@ describe API::ProtectedEnvironments do
it 'returns error with invalid deploy access level' do it 'returns error with invalid deploy access level' do
post api_url, params: { name: 'staging', deploy_access_levels: [{ access_level: nil }] } post api_url, params: { name: 'staging', deploy_access_levels: [{ access_level: nil }] }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
...@@ -156,7 +156,7 @@ describe API::ProtectedEnvironments do ...@@ -156,7 +156,7 @@ describe API::ProtectedEnvironments do
request request
end.to change { project.protected_environments.count }.by(-1) end.to change { project.protected_environments.count }.by(-1)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
......
This diff is collapsed.
...@@ -289,7 +289,7 @@ describe API::PipelineSchedules do ...@@ -289,7 +289,7 @@ describe API::PipelineSchedules do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer) delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer)
end.to change { project.pipeline_schedules.count }.by(-1) end.to change { project.pipeline_schedules.count }.by(-1)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do
......
This diff is collapsed.
...@@ -26,7 +26,7 @@ describe API::ProjectClusters do ...@@ -26,7 +26,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
get api("/projects/#{project.id}/clusters", developer_user) get api("/projects/#{project.id}/clusters", developer_user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -36,7 +36,7 @@ describe API::ProjectClusters do ...@@ -36,7 +36,7 @@ describe API::ProjectClusters do
end end
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'includes pagination headers' do it 'includes pagination headers' do
...@@ -71,7 +71,7 @@ describe API::ProjectClusters do ...@@ -71,7 +71,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
get api("/projects/#{project.id}/clusters/#{cluster_id}", developer_user) get api("/projects/#{project.id}/clusters/#{cluster_id}", developer_user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -142,7 +142,7 @@ describe API::ProjectClusters do ...@@ -142,7 +142,7 @@ describe API::ProjectClusters do
let(:cluster_id) { 123 } let(:cluster_id) { 123 }
it 'returns 404' do it 'returns 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -175,7 +175,7 @@ describe API::ProjectClusters do ...@@ -175,7 +175,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
post api("/projects/#{project.id}/clusters/user", developer_user), params: cluster_params post api("/projects/#{project.id}/clusters/user", developer_user), params: cluster_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -186,7 +186,7 @@ describe API::ProjectClusters do ...@@ -186,7 +186,7 @@ describe API::ProjectClusters do
context 'with valid params' do context 'with valid params' do
it 'responds with 201' do it 'responds with 201' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'creates a new Cluster::Cluster' do it 'creates a new Cluster::Cluster' do
...@@ -236,7 +236,7 @@ describe API::ProjectClusters do ...@@ -236,7 +236,7 @@ describe API::ProjectClusters do
let(:namespace) { 'invalid_namespace' } let(:namespace) { 'invalid_namespace' }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not create a new Clusters::Cluster' do it 'does not create a new Clusters::Cluster' do
...@@ -258,7 +258,7 @@ describe API::ProjectClusters do ...@@ -258,7 +258,7 @@ describe API::ProjectClusters do
end end
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters')) expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters'))
end end
...@@ -270,7 +270,7 @@ describe API::ProjectClusters do ...@@ -270,7 +270,7 @@ describe API::ProjectClusters do
end end
it 'responds with 403' do it 'responds with 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
...@@ -307,7 +307,7 @@ describe API::ProjectClusters do ...@@ -307,7 +307,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
put api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: update_params put api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: update_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -322,7 +322,7 @@ describe API::ProjectClusters do ...@@ -322,7 +322,7 @@ describe API::ProjectClusters do
context 'with valid params' do context 'with valid params' do
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'updates cluster attributes' do it 'updates cluster attributes' do
...@@ -336,7 +336,7 @@ describe API::ProjectClusters do ...@@ -336,7 +336,7 @@ describe API::ProjectClusters do
let(:namespace) { 'invalid_namespace' } let(:namespace) { 'invalid_namespace' }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not update cluster attributes' do it 'does not update cluster attributes' do
...@@ -354,7 +354,7 @@ describe API::ProjectClusters do ...@@ -354,7 +354,7 @@ describe API::ProjectClusters do
let(:management_project_id) { create(:project).id } let(:management_project_id) { create(:project).id }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns validation errors' do it 'returns validation errors' do
...@@ -372,7 +372,7 @@ describe API::ProjectClusters do ...@@ -372,7 +372,7 @@ describe API::ProjectClusters do
end end
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns validation error' do it 'returns validation error' do
...@@ -384,7 +384,7 @@ describe API::ProjectClusters do ...@@ -384,7 +384,7 @@ describe API::ProjectClusters do
let(:namespace) { 'new-namespace' } let(:namespace) { 'new-namespace' }
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -413,7 +413,7 @@ describe API::ProjectClusters do ...@@ -413,7 +413,7 @@ describe API::ProjectClusters do
end end
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'updates platform kubernetes attributes' do it 'updates platform kubernetes attributes' do
...@@ -430,7 +430,7 @@ describe API::ProjectClusters do ...@@ -430,7 +430,7 @@ describe API::ProjectClusters do
let(:cluster) { create(:cluster, :project, :provided_by_user) } let(:cluster) { create(:cluster, :project, :provided_by_user) }
it 'responds with 404' do it 'responds with 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -448,7 +448,7 @@ describe API::ProjectClusters do ...@@ -448,7 +448,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
delete api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: cluster_params delete api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: cluster_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -458,7 +458,7 @@ describe API::ProjectClusters do ...@@ -458,7 +458,7 @@ describe API::ProjectClusters do
end end
it 'responds with 204' do it 'responds with 204' do
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'deletes the cluster' do it 'deletes the cluster' do
...@@ -469,7 +469,7 @@ describe API::ProjectClusters do ...@@ -469,7 +469,7 @@ describe API::ProjectClusters do
let(:cluster) { create(:cluster, :project, :provided_by_user) } let(:cluster) { create(:cluster, :project, :provided_by_user) }
it 'responds with 404' do it 'responds with 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -163,7 +163,7 @@ describe API::ProjectContainerRepositories do ...@@ -163,7 +163,7 @@ describe API::ProjectContainerRepositories do
stub_exclusive_lease_taken(lease_key, timeout: 1.hour) stub_exclusive_lease_taken(lease_key, timeout: 1.hour)
subject subject
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(response.body).to include('This request has already been made.') expect(response.body).to include('This request has already been made.')
end end
......
...@@ -14,7 +14,7 @@ describe API::ProjectEvents do ...@@ -14,7 +14,7 @@ describe API::ProjectEvents do
it 'returns 404 for private project' do it 'returns 404 for private project' do
get api("/projects/#{private_project.id}/events") get api("/projects/#{private_project.id}/events")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 200 status for a public project' do it 'returns 200 status for a public project' do
...@@ -22,7 +22,7 @@ describe API::ProjectEvents do ...@@ -22,7 +22,7 @@ describe API::ProjectEvents do
get api("/projects/#{public_project.id}/events") get api("/projects/#{public_project.id}/events")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -36,14 +36,14 @@ describe API::ProjectEvents do ...@@ -36,14 +36,14 @@ describe API::ProjectEvents do
it 'returns only accessible events' do it 'returns only accessible events' do
get api("/projects/#{public_project.id}/events", non_member) get api("/projects/#{public_project.id}/events", non_member)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
end end
it 'returns all events when the user has access' do it 'returns all events when the user has access' do
get api("/projects/#{public_project.id}/events", user) get api("/projects/#{public_project.id}/events", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2) expect(json_response.size).to eq(2)
end end
end end
...@@ -92,7 +92,7 @@ describe API::ProjectEvents do ...@@ -92,7 +92,7 @@ describe API::ProjectEvents do
it 'returns 404' do it 'returns 404' do
get api("/projects/#{private_project.id}/events", non_member) get api("/projects/#{private_project.id}/events", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -100,7 +100,7 @@ describe API::ProjectEvents do ...@@ -100,7 +100,7 @@ describe API::ProjectEvents do
it 'returns project 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) 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_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
...@@ -109,7 +109,7 @@ describe API::ProjectEvents do ...@@ -109,7 +109,7 @@ describe API::ProjectEvents do
it 'returns 404 if project does not exist' do it 'returns 404 if project does not exist' do
get api("/projects/1234/events", user) get api("/projects/1234/events", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'when the requesting token does not have "api" scope' do context 'when the requesting token does not have "api" scope' do
...@@ -118,7 +118,7 @@ describe API::ProjectEvents do ...@@ -118,7 +118,7 @@ describe API::ProjectEvents do
it 'returns a "403" response' do it 'returns a "403" response' do
get api("/projects/#{private_project.id}/events", personal_access_token: token) get api("/projects/#{private_project.id}/events", personal_access_token: token)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -142,7 +142,7 @@ describe API::ProjectEvents do ...@@ -142,7 +142,7 @@ describe API::ProjectEvents do
get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request } get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request }
end.not_to exceed_all_query_limit(control_count) end.not_to exceed_all_query_limit(control_count)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.size).to eq(2) expect(json_response.size).to eq(2)
expect(json_response.map { |r| r['target_id'] }).to match_array([merge_request1.id, merge_request2.id]) expect(json_response.map { |r| r['target_id'] }).to match_array([merge_request1.id, merge_request2.id])
......
...@@ -55,7 +55,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -55,7 +55,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'prevents requesting project export' do it 'prevents requesting project export' do
request request
expect(response).to have_gitlab_http_status(429) expect(response).to have_gitlab_http_status(:too_many_requests)
expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.') expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.')
end end
end end
...@@ -77,7 +77,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -77,7 +77,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is none' do it 'is none' do
get api(path_none, user) get api(path_none, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('none') expect(json_response['export_status']).to eq('none')
end end
...@@ -85,7 +85,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -85,7 +85,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is started' do it 'is started' do
get api(path_started, user) get api(path_started, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('started') expect(json_response['export_status']).to eq('started')
end end
...@@ -93,7 +93,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -93,7 +93,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is after_export' do it 'is after_export' do
get api(path_after_export, user) get api(path_after_export, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('after_export_action') expect(json_response['export_status']).to eq('after_export_action')
end end
...@@ -101,7 +101,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -101,7 +101,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is finished' do it 'is finished' do
get api(path_finished, user) get api(path_finished, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('finished') expect(json_response['export_status']).to eq('finished')
end end
...@@ -185,7 +185,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -185,7 +185,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'downloads' do it 'downloads' do
get api(download_path_finished, user) get api(download_path_finished, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -194,7 +194,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -194,7 +194,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'downloads' do it 'downloads' do
get api(download_path_export_action, user) get api(download_path_export_action, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -324,7 +324,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -324,7 +324,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
post(api(path, user), params: { 'upload[url]' => 'http://gitlab.com' }) post(api(path, user), params: { 'upload[url]' => 'http://gitlab.com' })
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
...@@ -334,7 +334,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -334,7 +334,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
post api(path, user) post api(path, user)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
end end
...@@ -403,7 +403,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -403,7 +403,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute) expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute)
post api(path, project.owner), params: params post api(path, project.owner), params: params
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
end end
......
...@@ -25,7 +25,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -25,7 +25,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns project hooks" do it "returns project hooks" do
get api("/projects/#{project.id}/hooks", user) get api("/projects/#{project.id}/hooks", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.count).to eq(1) expect(json_response.count).to eq(1)
...@@ -49,7 +49,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -49,7 +49,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "does not access project hooks" do it "does not access project hooks" do
get api("/projects/#{project.id}/hooks", user3) get api("/projects/#{project.id}/hooks", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -59,7 +59,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -59,7 +59,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a project hook" do it "returns a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user) get api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['url']).to eq(hook.url) expect(json_response['url']).to eq(hook.url)
expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['issues_events']).to eq(hook.issues_events)
expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events) expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
...@@ -77,14 +77,14 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -77,14 +77,14 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a 404 error if hook id is not available" do it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user) get api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
context "unauthorized user" do context "unauthorized user" do
it "does not access an existing hook" do it "does not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3) get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -96,7 +96,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -96,7 +96,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
params: { url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, job_events: true, push_events_branch_filter: 'some-feature-branch' } params: { url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, job_events: true, push_events_branch_filter: 'some-feature-branch' }
end.to change {project.hooks.count}.by(1) end.to change {project.hooks.count}.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['url']).to eq('http://example.com') expect(json_response['url']).to eq('http://example.com')
expect(json_response['issues_events']).to eq(true) expect(json_response['issues_events']).to eq(true)
expect(json_response['confidential_issues_events']).to eq(true) expect(json_response['confidential_issues_events']).to eq(true)
...@@ -120,7 +120,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -120,7 +120,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token } post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token }
end.to change {project.hooks.count}.by(1) end.to change {project.hooks.count}.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["url"]).to eq("http://example.com") expect(json_response["url"]).to eq("http://example.com")
expect(json_response).not_to include("token") expect(json_response).not_to include("token")
...@@ -132,17 +132,17 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -132,17 +132,17 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a 400 error if url not given" do it "returns a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user) post api("/projects/#{project.id}/hooks", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 422 error if url not valid" do it "returns a 422 error if url not valid" do
post api("/projects/#{project.id}/hooks", user), params: { url: "ftp://example.com" } post api("/projects/#{project.id}/hooks", user), params: { url: "ftp://example.com" }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
it "returns a 422 error if branch filter is not valid" do it "returns a 422 error if branch filter is not valid" do
post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", push_events_branch_filter: '~badbranchname/' } post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", push_events_branch_filter: '~badbranchname/' }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
...@@ -151,7 +151,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -151,7 +151,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), put api("/projects/#{project.id}/hooks/#{hook.id}", user),
params: { url: 'http://example.org', push_events: false, job_events: true } params: { url: 'http://example.org', push_events: false, job_events: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['url']).to eq('http://example.org') expect(json_response['url']).to eq('http://example.org')
expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['issues_events']).to eq(hook.issues_events)
expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events) expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
...@@ -171,7 +171,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -171,7 +171,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: "http://example.org", token: token } put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: "http://example.org", token: token }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response["url"]).to eq("http://example.org") expect(json_response["url"]).to eq("http://example.org")
expect(json_response).not_to include("token") expect(json_response).not_to include("token")
...@@ -181,17 +181,17 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -181,17 +181,17 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns 404 error if hook id not found" do it "returns 404 error if hook id not found" do
put api("/projects/#{project.id}/hooks/1234", user), params: { url: 'http://example.org' } put api("/projects/#{project.id}/hooks/1234", user), params: { url: 'http://example.org' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns 400 error if url is not given" do it "returns 400 error if url is not given" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user) put api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 422 error if url is not valid" do it "returns a 422 error if url is not valid" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: 'ftp://example.com' } put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: 'ftp://example.com' }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
...@@ -200,19 +200,19 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -200,19 +200,19 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect do expect do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user) delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change {project.hooks.count}.by(-1) end.to change {project.hooks.count}.by(-1)
end end
it "returns a 404 error when deleting non existent hook" do it "returns a 404 error when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user) delete api("/projects/#{project.id}/hooks/42", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns a 404 error if hook id not given" do it "returns a 404 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user) delete api("/projects/#{project.id}/hooks", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns a 404 if a user attempts to delete project hooks they do not own" do it "returns a 404 if a user attempts to delete project hooks they do not own" do
...@@ -221,7 +221,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -221,7 +221,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
other_project.add_maintainer(test_user) other_project.add_maintainer(test_user)
delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user) delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(WebHook.exists?(hook.id)).to be_truthy expect(WebHook.exists?(hook.id)).to be_truthy
end end
......
...@@ -25,7 +25,7 @@ describe API::ProjectImport do ...@@ -25,7 +25,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'schedules an import using the namespace path' do it 'schedules an import using the namespace path' do
...@@ -33,7 +33,7 @@ describe API::ProjectImport do ...@@ -33,7 +33,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
context 'when a name is explicitly set' do context 'when a name is explicitly set' do
...@@ -44,7 +44,7 @@ describe API::ProjectImport do ...@@ -44,7 +44,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id, name: expected_name } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id, name: expected_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'schedules an import using the namespace path and a different name' do it 'schedules an import using the namespace path and a different name' do
...@@ -52,7 +52,7 @@ describe API::ProjectImport do ...@@ -52,7 +52,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path, name: expected_name } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path, name: expected_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'sets name correctly' do it 'sets name correctly' do
...@@ -88,7 +88,7 @@ describe API::ProjectImport do ...@@ -88,7 +88,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import2', file: fixture_file_upload(file) } post api('/projects/import', user), params: { path: 'test-import2', file: fixture_file_upload(file) }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'does not schedule an import for a namespace that does not exist' do it 'does not schedule an import for a namespace that does not exist' do
...@@ -97,7 +97,7 @@ describe API::ProjectImport do ...@@ -97,7 +97,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { namespace: 'nonexistent', path: 'test-import2', file: fixture_file_upload(file) } post api('/projects/import', user), params: { namespace: 'nonexistent', path: 'test-import2', file: fixture_file_upload(file) }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Namespace Not Found') expect(json_response['message']).to eq('404 Namespace Not Found')
end end
...@@ -111,7 +111,7 @@ describe API::ProjectImport do ...@@ -111,7 +111,7 @@ describe API::ProjectImport do
namespace: namespace.full_path namespace: namespace.full_path
}) })
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Namespace Not Found') expect(json_response['message']).to eq('404 Namespace Not Found')
end end
...@@ -120,7 +120,7 @@ describe API::ProjectImport do ...@@ -120,7 +120,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import3', file: './random/test' } post api('/projects/import', user), params: { path: 'test-import3', file: './random/test' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('file is invalid') expect(json_response['error']).to eq('file is invalid')
end end
...@@ -181,7 +181,7 @@ describe API::ProjectImport do ...@@ -181,7 +181,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file) } post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file) }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Name has already been taken') expect(json_response['message']).to eq('Name has already been taken')
end end
...@@ -191,7 +191,7 @@ describe API::ProjectImport do ...@@ -191,7 +191,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file), overwrite: true } post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file), overwrite: true }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
end end
...@@ -204,7 +204,7 @@ describe API::ProjectImport do ...@@ -204,7 +204,7 @@ describe API::ProjectImport do
it 'prevents users from importing projects' do it 'prevents users from importing projects' do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id }
expect(response).to have_gitlab_http_status(429) expect(response).to have_gitlab_http_status(:too_many_requests)
expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.') expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.')
end end
end end
...@@ -222,7 +222,7 @@ describe API::ProjectImport do ...@@ -222,7 +222,7 @@ describe API::ProjectImport do
get api("/projects/#{project.id}/import", user) get api("/projects/#{project.id}/import", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('import_status' => 'started') expect(json_response).to include('import_status' => 'started')
end end
...@@ -233,7 +233,7 @@ describe API::ProjectImport do ...@@ -233,7 +233,7 @@ describe API::ProjectImport do
get api("/projects/#{project.id}/import", user) get api("/projects/#{project.id}/import", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('import_status' => 'failed', expect(json_response).to include('import_status' => 'failed',
'import_error' => 'error') 'import_error' => 'error')
end end
......
...@@ -27,19 +27,19 @@ describe API::ProjectMilestones do ...@@ -27,19 +27,19 @@ describe API::ProjectMilestones do
it 'returns 404 response when the project does not exists' do it 'returns 404 response when the project does not exists' do
delete api("/projects/0/milestones/#{milestone.id}", user) delete api("/projects/0/milestones/#{milestone.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 response when the milestone does not exists' do it 'returns 404 response when the milestone does not exists' do
delete api("/projects/#{project.id}/milestones/0", user) delete api("/projects/#{project.id}/milestones/0", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns 404 from guest user deleting a milestone" do it "returns 404 from guest user deleting a milestone" do
delete api("/projects/#{project.id}/milestones/#{milestone.id}", guest) delete api("/projects/#{project.id}/milestones/#{milestone.id}", guest)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -67,7 +67,7 @@ describe API::ProjectMilestones do ...@@ -67,7 +67,7 @@ describe API::ProjectMilestones do
it 'returns 403' do it 'returns 403' do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -79,14 +79,14 @@ describe API::ProjectMilestones do ...@@ -79,14 +79,14 @@ describe API::ProjectMilestones do
it 'returns 200' do it 'returns 200' do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(group.milestones.first.title).to eq(milestone.title) expect(group.milestones.first.title).to eq(milestone.title)
end end
it 'returns 200 for closed milestone' do it 'returns 200 for closed milestone' do
post api("/projects/#{project.id}/milestones/#{closed_milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{closed_milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(group.milestones.first.title).to eq(closed_milestone.title) expect(group.milestones.first.title).to eq(closed_milestone.title)
end end
end end
...@@ -99,13 +99,13 @@ describe API::ProjectMilestones do ...@@ -99,13 +99,13 @@ describe API::ProjectMilestones do
it 'returns 404 response when the project does not exist' do it 'returns 404 response when the project does not exist' do
post api("/projects/0/milestones/#{milestone.id}/promote", user) post api("/projects/0/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 response when the milestone does not exist' do it 'returns 404 response when the milestone does not exist' do
post api("/projects/#{project.id}/milestones/0/promote", user) post api("/projects/#{project.id}/milestones/0/promote", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -117,7 +117,7 @@ describe API::ProjectMilestones do ...@@ -117,7 +117,7 @@ describe API::ProjectMilestones do
it 'returns 403' do it 'returns 403' do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
......
...@@ -34,26 +34,26 @@ describe API::ProjectSnapshots do ...@@ -34,26 +34,26 @@ describe API::ProjectSnapshots do
it 'returns authentication error as project owner' do it 'returns authentication error as project owner' do
get api("/projects/#{project.id}/snapshot", project.owner) get api("/projects/#{project.id}/snapshot", project.owner)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'returns authentication error as unauthenticated user' do it 'returns authentication error as unauthenticated user' do
get api("/projects/#{project.id}/snapshot", nil) get api("/projects/#{project.id}/snapshot", nil)
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'requests project repository raw archive as administrator' do it 'requests project repository raw archive as administrator' do
get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '0' } get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '0' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect_snapshot_response_for(project.repository) expect_snapshot_response_for(project.repository)
end end
it 'requests wiki repository raw archive as administrator' do it 'requests wiki repository raw archive as administrator' do
get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '1' } get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '1' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect_snapshot_response_for(project.wiki.repository) expect_snapshot_response_for(project.wiki.repository)
end end
end end
......
...@@ -14,7 +14,7 @@ describe API::ProjectSnippets do ...@@ -14,7 +14,7 @@ describe API::ProjectSnippets do
it 'exposes known attributes' do it 'exposes known attributes' do
get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin) get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) 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['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
...@@ -24,13 +24,13 @@ describe API::ProjectSnippets do ...@@ -24,13 +24,13 @@ describe API::ProjectSnippets do
other_project = create(:project) other_project = create(:project)
get api("/projects/#{other_project.id}/snippets/#{snippet.id}/user_agent_detail", admin) get api("/projects/#{other_project.id}/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns unauthorized for non-admin users" do it "returns unauthorized for non-admin users" do
get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", user) get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -45,7 +45,7 @@ describe API::ProjectSnippets do ...@@ -45,7 +45,7 @@ describe API::ProjectSnippets do
get api("/projects/#{project.id}/snippets", user) get api("/projects/#{project.id}/snippets", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
...@@ -58,7 +58,7 @@ describe API::ProjectSnippets do ...@@ -58,7 +58,7 @@ describe API::ProjectSnippets do
get api("/projects/#{project.id}/snippets/", user) get api("/projects/#{project.id}/snippets/", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(0) expect(json_response.size).to eq(0)
...@@ -72,7 +72,7 @@ describe API::ProjectSnippets do ...@@ -72,7 +72,7 @@ describe API::ProjectSnippets do
it 'returns snippet json' do it 'returns snippet json' do
get api("/projects/#{project.id}/snippets/#{snippet.id}", user) get api("/projects/#{project.id}/snippets/#{snippet.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(snippet.title) expect(json_response['title']).to eq(snippet.title)
expect(json_response['description']).to eq(snippet.description) expect(json_response['description']).to eq(snippet.description)
...@@ -82,7 +82,7 @@ describe API::ProjectSnippets do ...@@ -82,7 +82,7 @@ describe API::ProjectSnippets do
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
get api("/projects/#{project.id}/snippets/1234", user) get api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
end end
...@@ -110,7 +110,7 @@ describe API::ProjectSnippets do ...@@ -110,7 +110,7 @@ describe API::ProjectSnippets do
it 'creates a new snippet' do it 'creates a new snippet' do
post api("/projects/#{project.id}/snippets/", user), params: params post api("/projects/#{project.id}/snippets/", user), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
snippet = ProjectSnippet.find(json_response['id']) snippet = ProjectSnippet.find(json_response['id'])
expect(snippet.content).to eq(params[:code]) expect(snippet.content).to eq(params[:code])
expect(snippet.description).to eq(params[:description]) expect(snippet.description).to eq(params[:description])
...@@ -123,7 +123,7 @@ describe API::ProjectSnippets do ...@@ -123,7 +123,7 @@ describe API::ProjectSnippets do
it 'creates a new snippet' do it 'creates a new snippet' do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
snippet = ProjectSnippet.find(json_response['id']) snippet = ProjectSnippet.find(json_response['id'])
expect(snippet.content).to eq(params[:code]) expect(snippet.content).to eq(params[:code])
expect(snippet.description).to eq(params[:description]) expect(snippet.description).to eq(params[:description])
...@@ -137,7 +137,7 @@ describe API::ProjectSnippets do ...@@ -137,7 +137,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
snippet = ProjectSnippet.find(json_response['id']) snippet = ProjectSnippet.find(json_response['id'])
expect(snippet.content).to eq(params[:content]) expect(snippet.content).to eq(params[:content])
expect(snippet.description).to eq(params[:description]) expect(snippet.description).to eq(params[:description])
...@@ -151,7 +151,7 @@ describe API::ProjectSnippets do ...@@ -151,7 +151,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('code, content are mutually exclusive') expect(json_response['error']).to eq('code, content are mutually exclusive')
end end
...@@ -160,7 +160,7 @@ describe API::ProjectSnippets do ...@@ -160,7 +160,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 400 for empty code field' do it 'returns 400 for empty code field' do
...@@ -168,7 +168,7 @@ describe API::ProjectSnippets do ...@@ -168,7 +168,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context 'when the snippet is spam' do context 'when the snippet is spam' do
...@@ -196,7 +196,7 @@ describe API::ProjectSnippets do ...@@ -196,7 +196,7 @@ describe API::ProjectSnippets do
expect { create_snippet(project, visibility: 'public') } expect { create_snippet(project, visibility: 'public') }
.not_to change { Snippet.count } .not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" }) expect(json_response['message']).to eq({ "error" => "Spam detected" })
end end
...@@ -218,7 +218,7 @@ describe API::ProjectSnippets do ...@@ -218,7 +218,7 @@ describe API::ProjectSnippets do
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content, description: new_description, visibility: 'private' } put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content, description: new_description, visibility: 'private' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
snippet.reload snippet.reload
expect(snippet.content).to eq(new_content) expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description) expect(snippet.description).to eq(new_description)
...@@ -231,7 +231,7 @@ describe API::ProjectSnippets do ...@@ -231,7 +231,7 @@ describe API::ProjectSnippets do
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { content: new_content, description: new_description } put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { content: new_content, description: new_description }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
snippet.reload snippet.reload
expect(snippet.content).to eq(new_content) expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description) expect(snippet.description).to eq(new_description)
...@@ -240,21 +240,21 @@ describe API::ProjectSnippets do ...@@ -240,21 +240,21 @@ describe API::ProjectSnippets do
it 'returns 400 when both code and content parameters specified' do it 'returns 400 when both code and content parameters specified' do
put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { code: 'some content', content: 'other content' } put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { code: 'some content', content: 'other content' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('code, content are mutually exclusive') expect(json_response['error']).to eq('code, content are mutually exclusive')
end end
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { title: 'foo' } put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { title: 'foo' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
it 'returns 400 for missing parameters' do it 'returns 400 for missing parameters' do
put api("/projects/#{project.id}/snippets/1234", admin) put api("/projects/#{project.id}/snippets/1234", admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 400 for empty code field' do it 'returns 400 for empty code field' do
...@@ -262,7 +262,7 @@ describe API::ProjectSnippets do ...@@ -262,7 +262,7 @@ describe API::ProjectSnippets do
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content } put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context 'when the snippet is spam' do context 'when the snippet is spam' do
...@@ -306,7 +306,7 @@ describe API::ProjectSnippets do ...@@ -306,7 +306,7 @@ describe API::ProjectSnippets do
expect { update_snippet(title: 'Foo', visibility: 'public') } expect { update_snippet(title: 'Foo', visibility: 'public') }
.not_to change { snippet.reload.title } .not_to change { snippet.reload.title }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" }) expect(json_response['message']).to eq({ "error" => "Spam detected" })
end end
...@@ -324,13 +324,13 @@ describe API::ProjectSnippets do ...@@ -324,13 +324,13 @@ describe API::ProjectSnippets do
it 'deletes snippet' do it 'deletes snippet' do
delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
delete api("/projects/#{snippet.project.id}/snippets/1234", admin) delete api("/projects/#{snippet.project.id}/snippets/1234", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
...@@ -345,7 +345,7 @@ describe API::ProjectSnippets do ...@@ -345,7 +345,7 @@ describe API::ProjectSnippets do
it 'returns raw text' do it 'returns raw text' do
get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin) get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
expect(response.body).to eq(snippet.content) expect(response.body).to eq(snippet.content)
end end
...@@ -353,7 +353,7 @@ describe API::ProjectSnippets do ...@@ -353,7 +353,7 @@ describe API::ProjectSnippets do
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin) get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
end end
......
...@@ -21,7 +21,7 @@ describe API::ProjectStatistics do ...@@ -21,7 +21,7 @@ describe API::ProjectStatistics do
it 'returns the fetch statistics of the last 30 days' do it 'returns the fetch statistics of the last 30 days' do
get api("/projects/#{public_project.id}/statistics", maintainer) get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
fetches = json_response['fetches'] fetches = json_response['fetches']
expect(fetches['total']).to eq(40) expect(fetches['total']).to eq(40)
expect(fetches['days'].length).to eq(5) expect(fetches['days'].length).to eq(5)
...@@ -34,7 +34,7 @@ describe API::ProjectStatistics do ...@@ -34,7 +34,7 @@ describe API::ProjectStatistics do
get api("/projects/#{public_project.id}/statistics", maintainer) get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
fetches = json_response['fetches'] fetches = json_response['fetches']
expect(fetches['total']).to eq(40) expect(fetches['total']).to eq(40)
expect(fetches['days'].length).to eq(5) expect(fetches['days'].length).to eq(5)
...@@ -47,7 +47,7 @@ describe API::ProjectStatistics do ...@@ -47,7 +47,7 @@ describe API::ProjectStatistics do
get api("/projects/#{public_project.id}/statistics", developer) get api("/projects/#{public_project.id}/statistics", developer)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
...@@ -56,7 +56,7 @@ describe API::ProjectStatistics do ...@@ -56,7 +56,7 @@ describe API::ProjectStatistics do
get api("/projects/#{public_project.id}/statistics", maintainer) get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -15,7 +15,7 @@ describe API::ProjectTemplates do ...@@ -15,7 +15,7 @@ describe API::ProjectTemplates do
it 'returns dockerfiles' do it 'returns dockerfiles' do
get api("/projects/#{public_project.id}/templates/dockerfiles") get api("/projects/#{public_project.id}/templates/dockerfiles")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Binary' } expect(json_response).to satisfy_one { |template| template['key'] == 'Binary' }
...@@ -24,7 +24,7 @@ describe API::ProjectTemplates do ...@@ -24,7 +24,7 @@ describe API::ProjectTemplates do
it 'returns gitignores' do it 'returns gitignores' do
get api("/projects/#{public_project.id}/templates/gitignores") get api("/projects/#{public_project.id}/templates/gitignores")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Actionscript' } expect(json_response).to satisfy_one { |template| template['key'] == 'Actionscript' }
...@@ -33,7 +33,7 @@ describe API::ProjectTemplates do ...@@ -33,7 +33,7 @@ describe API::ProjectTemplates do
it 'returns gitlab_ci_ymls' do it 'returns gitlab_ci_ymls' do
get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls") get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Android' } expect(json_response).to satisfy_one { |template| template['key'] == 'Android' }
...@@ -42,7 +42,7 @@ describe API::ProjectTemplates do ...@@ -42,7 +42,7 @@ describe API::ProjectTemplates do
it 'returns licenses' do it 'returns licenses' do
get api("/projects/#{public_project.id}/templates/licenses") get api("/projects/#{public_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'mit' } expect(json_response).to satisfy_one { |template| template['key'] == 'mit' }
...@@ -51,19 +51,19 @@ describe API::ProjectTemplates do ...@@ -51,19 +51,19 @@ describe API::ProjectTemplates do
it 'returns 400 for an unknown template type' do it 'returns 400 for an unknown template type' do
get api("/projects/#{public_project.id}/templates/unknown") get api("/projects/#{public_project.id}/templates/unknown")
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'denies access to an anonymous user on a private project' do it 'denies access to an anonymous user on a private project' do
get api("/projects/#{private_project.id}/templates/licenses") get api("/projects/#{private_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'permits access to a developer on a private project' do it 'permits access to a developer on a private project' do
get api("/projects/#{private_project.id}/templates/licenses", developer) get api("/projects/#{private_project.id}/templates/licenses", developer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
end end
end end
...@@ -72,7 +72,7 @@ describe API::ProjectTemplates do ...@@ -72,7 +72,7 @@ describe API::ProjectTemplates do
it 'returns key and name for the listed licenses' do it 'returns key and name for the listed licenses' do
get api("/projects/#{public_project.id}/templates/licenses") get api("/projects/#{public_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
end end
end end
...@@ -81,7 +81,7 @@ describe API::ProjectTemplates do ...@@ -81,7 +81,7 @@ describe API::ProjectTemplates do
it 'returns a specific dockerfile' do it 'returns a specific dockerfile' do
get api("/projects/#{public_project.id}/templates/dockerfiles/Binary") get api("/projects/#{public_project.id}/templates/dockerfiles/Binary")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('Binary') expect(json_response['name']).to eq('Binary')
end end
...@@ -89,7 +89,7 @@ describe API::ProjectTemplates do ...@@ -89,7 +89,7 @@ describe API::ProjectTemplates do
it 'returns a specific gitignore' do it 'returns a specific gitignore' do
get api("/projects/#{public_project.id}/templates/gitignores/Actionscript") get api("/projects/#{public_project.id}/templates/gitignores/Actionscript")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('Actionscript') expect(json_response['name']).to eq('Actionscript')
end end
...@@ -97,7 +97,7 @@ describe API::ProjectTemplates do ...@@ -97,7 +97,7 @@ describe API::ProjectTemplates do
it 'returns C++ gitignore' do it 'returns C++ gitignore' do
get api("/projects/#{public_project.id}/templates/gitignores/C++") get api("/projects/#{public_project.id}/templates/gitignores/C++")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('C++') expect(json_response['name']).to eq('C++')
end end
...@@ -105,7 +105,7 @@ describe API::ProjectTemplates do ...@@ -105,7 +105,7 @@ describe API::ProjectTemplates do
it 'returns C++ gitignore for URL-encoded names' do it 'returns C++ gitignore for URL-encoded names' do
get api("/projects/#{public_project.id}/templates/gitignores/C%2B%2B") get api("/projects/#{public_project.id}/templates/gitignores/C%2B%2B")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('C++') expect(json_response['name']).to eq('C++')
end end
...@@ -113,7 +113,7 @@ describe API::ProjectTemplates do ...@@ -113,7 +113,7 @@ describe API::ProjectTemplates do
it 'returns a specific gitlab_ci_yml' do it 'returns a specific gitlab_ci_yml' do
get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls/Android") get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls/Android")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('Android') expect(json_response['name']).to eq('Android')
end end
...@@ -121,26 +121,26 @@ describe API::ProjectTemplates do ...@@ -121,26 +121,26 @@ describe API::ProjectTemplates do
it 'returns a specific license' do it 'returns a specific license' do
get api("/projects/#{public_project.id}/templates/licenses/mit") get api("/projects/#{public_project.id}/templates/licenses/mit")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/license') expect(response).to match_response_schema('public_api/v4/license')
end end
it 'returns 404 for an unknown specific template' do it 'returns 404 for an unknown specific template' do
get api("/projects/#{public_project.id}/templates/licenses/unknown") get api("/projects/#{public_project.id}/templates/licenses/unknown")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'denies access to an anonymous user on a private project' do it 'denies access to an anonymous user on a private project' do
get api("/projects/#{private_project.id}/templates/licenses/mit") get api("/projects/#{private_project.id}/templates/licenses/mit")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'permits access to a developer on a private project' do it 'permits access to a developer on a private project' do
get api("/projects/#{private_project.id}/templates/licenses/mit", developer) get api("/projects/#{private_project.id}/templates/licenses/mit", developer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/license') expect(response).to match_response_schema('public_api/v4/license')
end end
...@@ -148,7 +148,7 @@ describe API::ProjectTemplates do ...@@ -148,7 +148,7 @@ describe API::ProjectTemplates do
it 'rejects invalid filenames' do it 'rejects invalid filenames' do
get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea") get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea")
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
end end
end end
...@@ -165,7 +165,7 @@ describe API::ProjectTemplates do ...@@ -165,7 +165,7 @@ describe API::ProjectTemplates do
fullname: 'Fullname Placeholder' fullname: 'Fullname Placeholder'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/license') expect(response).to match_response_schema('public_api/v4/license')
content = json_response['content'] content = json_response['content']
......
This diff is collapsed.
...@@ -19,7 +19,7 @@ describe API::ProtectedBranches do ...@@ -19,7 +19,7 @@ describe API::ProtectedBranches do
it 'returns the protected branches' do it 'returns the protected branches' do
get api(route, user), params: params.merge(per_page: 100) get api(route, user), params: params.merge(per_page: 100)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -66,7 +66,7 @@ describe API::ProtectedBranches do ...@@ -66,7 +66,7 @@ describe API::ProtectedBranches do
it 'returns the protected branch' do it 'returns the protected branch' do
get api(route, user) get api(route, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
...@@ -118,7 +118,7 @@ describe API::ProtectedBranches do ...@@ -118,7 +118,7 @@ describe API::ProtectedBranches do
let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) } let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) }
def expect_protection_to_be_successful def expect_protection_to_be_successful
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
end end
...@@ -130,7 +130,7 @@ describe API::ProtectedBranches do ...@@ -130,7 +130,7 @@ describe API::ProtectedBranches do
it 'protects a single branch' do it 'protects a single branch' do
post post_endpoint, params: { name: branch_name } post post_endpoint, params: { name: branch_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -139,7 +139,7 @@ describe API::ProtectedBranches do ...@@ -139,7 +139,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can push' do it 'protects a single branch and developers can push' do
post post_endpoint, params: { name: branch_name, push_access_level: 30 } post post_endpoint, params: { name: branch_name, push_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -148,7 +148,7 @@ describe API::ProtectedBranches do ...@@ -148,7 +148,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can merge' do it 'protects a single branch and developers can merge' do
post post_endpoint, params: { name: branch_name, merge_access_level: 30 } post post_endpoint, params: { name: branch_name, merge_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
...@@ -157,7 +157,7 @@ describe API::ProtectedBranches do ...@@ -157,7 +157,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can push and merge' do it 'protects a single branch and developers can push and merge' do
post post_endpoint, params: { name: branch_name, push_access_level: 30, merge_access_level: 30 } post post_endpoint, params: { name: branch_name, push_access_level: 30, merge_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
...@@ -166,7 +166,7 @@ describe API::ProtectedBranches do ...@@ -166,7 +166,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can push' do it 'protects a single branch and no one can push' do
post post_endpoint, params: { name: branch_name, push_access_level: 0 } post post_endpoint, params: { name: branch_name, push_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -175,7 +175,7 @@ describe API::ProtectedBranches do ...@@ -175,7 +175,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can merge' do it 'protects a single branch and no one can merge' do
post post_endpoint, params: { name: branch_name, merge_access_level: 0 } post post_endpoint, params: { name: branch_name, merge_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
...@@ -184,7 +184,7 @@ describe API::ProtectedBranches do ...@@ -184,7 +184,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can push or merge' do it 'protects a single branch and no one can push or merge' do
post post_endpoint, params: { name: branch_name, push_access_level: 0, merge_access_level: 0 } post post_endpoint, params: { name: branch_name, push_access_level: 0, merge_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
...@@ -193,7 +193,7 @@ describe API::ProtectedBranches do ...@@ -193,7 +193,7 @@ describe API::ProtectedBranches do
it 'returns a 409 error if the same branch is protected twice' do it 'returns a 409 error if the same branch is protected twice' do
post post_endpoint, params: { name: protected_name } post post_endpoint, params: { name: protected_name }
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
end end
context 'when branch has a wildcard in its name' do context 'when branch has a wildcard in its name' do
...@@ -217,7 +217,7 @@ describe API::ProtectedBranches do ...@@ -217,7 +217,7 @@ describe API::ProtectedBranches do
it "prevents deletion of the protected branch rule" do it "prevents deletion of the protected branch rule" do
post post_endpoint, params: { name: branch_name } post post_endpoint, params: { name: branch_name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -230,7 +230,7 @@ describe API::ProtectedBranches do ...@@ -230,7 +230,7 @@ describe API::ProtectedBranches do
it "returns a 403 error if guest" do it "returns a 403 error if guest" do
post post_endpoint, params: { name: branch_name } post post_endpoint, params: { name: branch_name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -245,7 +245,7 @@ describe API::ProtectedBranches do ...@@ -245,7 +245,7 @@ describe API::ProtectedBranches do
it "unprotects a single branch" do it "unprotects a single branch" do
delete delete_endpoint delete delete_endpoint
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -255,7 +255,7 @@ describe API::ProtectedBranches do ...@@ -255,7 +255,7 @@ describe API::ProtectedBranches do
it "returns 404 if branch does not exist" do it "returns 404 if branch does not exist" do
delete api("/projects/#{project.id}/protected_branches/barfoo", user) delete api("/projects/#{project.id}/protected_branches/barfoo", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'when a policy restricts rule deletion' do context 'when a policy restricts rule deletion' do
...@@ -267,7 +267,7 @@ describe API::ProtectedBranches do ...@@ -267,7 +267,7 @@ describe API::ProtectedBranches do
it "prevents deletion of the protected branch rule" do it "prevents deletion of the protected branch rule" do
delete delete_endpoint delete delete_endpoint
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -277,7 +277,7 @@ describe API::ProtectedBranches do ...@@ -277,7 +277,7 @@ describe API::ProtectedBranches do
it "unprotects a wildcard branch" do it "unprotects a wildcard branch" do
delete delete_endpoint delete delete_endpoint
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
end end
......
...@@ -19,7 +19,7 @@ describe API::ProtectedTags do ...@@ -19,7 +19,7 @@ describe API::ProtectedTags do
it 'returns the protected tags' do it 'returns the protected tags' do
get api(route, user), params: { per_page: 100 } get api(route, user), params: { per_page: 100 }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -55,7 +55,7 @@ describe API::ProtectedTags do ...@@ -55,7 +55,7 @@ describe API::ProtectedTags do
it 'returns the protected tag' do it 'returns the protected tag' do
get api(route, user) get api(route, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) expect(json_response['create_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
end end
...@@ -106,7 +106,7 @@ describe API::ProtectedTags do ...@@ -106,7 +106,7 @@ describe API::ProtectedTags do
it 'protects a single tag with maintainers can create tags' do it 'protects a single tag with maintainers can create tags' do
post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
end end
...@@ -115,7 +115,7 @@ describe API::ProtectedTags do ...@@ -115,7 +115,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user), post api("/projects/#{project.id}/protected_tags", user),
params: { name: tag_name, create_access_level: 30 } params: { name: tag_name, create_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
end end
...@@ -124,7 +124,7 @@ describe API::ProtectedTags do ...@@ -124,7 +124,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user), post api("/projects/#{project.id}/protected_tags", user),
params: { name: tag_name, create_access_level: 0 } params: { name: tag_name, create_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
end end
...@@ -132,7 +132,7 @@ describe API::ProtectedTags do ...@@ -132,7 +132,7 @@ describe API::ProtectedTags do
it 'returns a 422 error if the same tag is protected twice' do it 'returns a 422 error if the same tag is protected twice' do
post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['message'][0]).to eq('Name has already been taken') expect(json_response['message'][0]).to eq('Name has already been taken')
end end
...@@ -140,7 +140,7 @@ describe API::ProtectedTags do ...@@ -140,7 +140,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name }
post api("/projects/#{project2.id}/protected_tags", user), params: { name: protected_name } post api("/projects/#{project2.id}/protected_tags", user), params: { name: protected_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(protected_name) expect(json_response['name']).to eq(protected_name)
end end
...@@ -150,7 +150,7 @@ describe API::ProtectedTags do ...@@ -150,7 +150,7 @@ describe API::ProtectedTags do
it 'protects multiple tags with a wildcard in the name' do it 'protects multiple tags with a wildcard in the name' do
post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
end end
...@@ -165,7 +165,7 @@ describe API::ProtectedTags do ...@@ -165,7 +165,7 @@ describe API::ProtectedTags do
it 'returns a 403 error if guest' do it 'returns a 403 error if guest' do
post api("/projects/#{project.id}/protected_tags/", user), params: { name: tag_name } post api("/projects/#{project.id}/protected_tags/", user), params: { name: tag_name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -178,7 +178,7 @@ describe API::ProtectedTags do ...@@ -178,7 +178,7 @@ describe API::ProtectedTags do
it 'unprotects a single tag' do it 'unprotects a single tag' do
delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user) delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -188,7 +188,7 @@ describe API::ProtectedTags do ...@@ -188,7 +188,7 @@ describe API::ProtectedTags do
it "returns 404 if tag does not exist" do it "returns 404 if tag does not exist" do
delete api("/projects/#{project.id}/protected_tags/barfoo", user) delete api("/projects/#{project.id}/protected_tags/barfoo", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'when tag has a wildcard in its name' do context 'when tag has a wildcard in its name' do
...@@ -197,7 +197,7 @@ describe API::ProtectedTags do ...@@ -197,7 +197,7 @@ describe API::ProtectedTags do
it 'unprotects a wildcard tag' do it 'unprotects a wildcard tag' do
delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user) delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment