Commit a11f6d3c authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'pl-rubocop-have-gitlab-http-status-spec-requests-api-5' into 'master'

Add http status cop to api specs a-p

See merge request gitlab-org/gitlab!25175
parents 46861810 a02dfe61
...@@ -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
......
...@@ -127,7 +127,7 @@ describe API::ProjectPackages do ...@@ -127,7 +127,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
...@@ -160,20 +160,20 @@ describe API::ProjectPackages do ...@@ -160,20 +160,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'
...@@ -185,13 +185,13 @@ describe API::ProjectPackages do ...@@ -185,13 +185,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
...@@ -202,7 +202,7 @@ describe API::ProjectPackages do ...@@ -202,7 +202,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
...@@ -225,7 +225,7 @@ describe API::ProjectPackages do ...@@ -225,7 +225,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
...@@ -240,7 +240,7 @@ describe API::ProjectPackages do ...@@ -240,7 +240,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
...@@ -255,13 +255,13 @@ describe API::ProjectPackages do ...@@ -255,13 +255,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
...@@ -271,13 +271,13 @@ describe API::ProjectPackages do ...@@ -271,13 +271,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
...@@ -285,7 +285,7 @@ describe API::ProjectPackages do ...@@ -285,7 +285,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
...@@ -293,7 +293,7 @@ describe API::ProjectPackages do ...@@ -293,7 +293,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
...@@ -301,7 +301,7 @@ describe API::ProjectPackages do ...@@ -301,7 +301,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
...@@ -309,7 +309,7 @@ describe API::ProjectPackages do ...@@ -309,7 +309,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
...@@ -322,7 +322,7 @@ describe API::ProjectPackages do ...@@ -322,7 +322,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
...@@ -17,7 +17,7 @@ describe API::Projects do ...@@ -17,7 +17,7 @@ describe API::Projects do
get api('/projects', user) get api('/projects', user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
context 'filters by verification flags' do context 'filters by verification flags' do
...@@ -29,7 +29,7 @@ describe API::Projects do ...@@ -29,7 +29,7 @@ describe API::Projects do
get api('/projects', user), params: { repository_checksum_failed: true } get api('/projects', user), params: { repository_checksum_failed: true }
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.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -42,7 +42,7 @@ describe API::Projects do ...@@ -42,7 +42,7 @@ describe API::Projects do
get api('/projects', user), params: { wiki_checksum_failed: true } get api('/projects', user), params: { wiki_checksum_failed: true }
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.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -71,7 +71,7 @@ describe API::Projects do ...@@ -71,7 +71,7 @@ describe API::Projects do
it 'includes the label in the response' do it 'includes the label in the response' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['external_authorization_classification_label']).to eq('the-label') expect(json_response['external_authorization_classification_label']).to eq('the-label')
end end
end end
...@@ -84,7 +84,7 @@ describe API::Projects do ...@@ -84,7 +84,7 @@ describe API::Projects do
it 'returns a 404' do it 'returns a 404' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -96,7 +96,7 @@ describe API::Projects do ...@@ -96,7 +96,7 @@ describe API::Projects do
it 'does not include the label in the response' do it 'does not include the label in the response' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['external_authorization_classification_label']).to be_nil expect(json_response['external_authorization_classification_label']).to be_nil
end end
end end
...@@ -118,7 +118,7 @@ describe API::Projects do ...@@ -118,7 +118,7 @@ describe API::Projects do
it 'returns 200' do it 'returns 200' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -130,13 +130,13 @@ describe API::Projects do ...@@ -130,13 +130,13 @@ describe API::Projects do
it 'returns 404 for request from ip not in the range' do it 'returns 404 for request from ip not in the range' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 200 for request from ip in the range' do it 'returns 200 for request from ip in the range' do
get api("/projects/#{project.id}", user), headers: { 'REMOTE_ADDR' => '192.168.0.0' } get api("/projects/#{project.id}", user), headers: { 'REMOTE_ADDR' => '192.168.0.0' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -205,7 +205,7 @@ describe API::Projects do ...@@ -205,7 +205,7 @@ describe API::Projects do
it 'returns repository_storage attribute' do it 'returns repository_storage attribute' do
get api("/projects/#{project.id}", admin) get api("/projects/#{project.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['repository_storage']).to eq(project.repository_storage) expect(json_response['repository_storage']).to eq(project.repository_storage)
end end
end end
...@@ -239,7 +239,7 @@ describe API::Projects do ...@@ -239,7 +239,7 @@ describe API::Projects do
expect { api_call }.to change { Project.count }.by(1) expect { api_call }.to change { Project.count }.by(1)
end end
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project = Project.find(json_response['id']) project = Project.find(json_response['id'])
expect(project.name).to eq(new_project_name) expect(project.name).to eq(new_project_name)
...@@ -251,7 +251,7 @@ describe API::Projects do ...@@ -251,7 +251,7 @@ describe API::Projects do
expect { api_call }.not_to change { Project.count } expect { api_call }.not_to change { Project.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['template_name']).to eq(["'bogus-template' is unknown or invalid"]) expect(json_response['message']['template_name']).to eq(["'bogus-template' is unknown or invalid"])
end end
...@@ -262,7 +262,7 @@ describe API::Projects do ...@@ -262,7 +262,7 @@ describe API::Projects do
expect { api_call }.not_to change { Project.count } expect { api_call }.not_to change { Project.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['template_project_id']).to eq(["#{new_project.id} is unknown or invalid"]) expect(json_response['message']['template_project_id']).to eq(["#{new_project.id} is unknown or invalid"])
end end
end end
...@@ -397,7 +397,7 @@ describe API::Projects do ...@@ -397,7 +397,7 @@ describe API::Projects do
it 'creates new project with pull mirroring set up' do it 'creates new project with pull mirroring set up' do
post api('/projects', user), params: mirror_params post api('/projects', user), params: mirror_params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(Project.first).to have_attributes( expect(Project.first).to have_attributes(
mirror: true, mirror: true,
import_url: import_url, import_url: import_url,
...@@ -412,7 +412,7 @@ describe API::Projects do ...@@ -412,7 +412,7 @@ describe API::Projects do
expect { post api('/projects', user), params: mirror_params } expect { post api('/projects', user), params: mirror_params }
.to change { Project.count }.by(1) .to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(Project.first).to have_attributes( expect(Project.first).to have_attributes(
mirror: false, mirror: false,
import_url: import_url, import_url: import_url,
...@@ -429,7 +429,7 @@ describe API::Projects do ...@@ -429,7 +429,7 @@ describe API::Projects do
it 'ignores the mirroring options' do it 'ignores the mirroring options' do
post api('/projects', user), params: mirror_params post api('/projects', user), params: mirror_params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(Project.first.mirror?).to be false expect(Project.first.mirror?).to be false
end end
...@@ -438,7 +438,7 @@ describe API::Projects do ...@@ -438,7 +438,7 @@ describe API::Projects do
post api('/projects', admin), params: mirror_params post api('/projects', admin), params: mirror_params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(Project.first).to have_attributes( expect(Project.first).to have_attributes(
mirror: true, mirror: true,
import_url: import_url, import_url: import_url,
...@@ -462,7 +462,7 @@ describe API::Projects do ...@@ -462,7 +462,7 @@ describe API::Projects do
it 'updates the classification label' do it 'updates the classification label' do
put(api("/projects/#{project.id}", user), params: { external_authorization_classification_label: 'new label' }) put(api("/projects/#{project.id}", user), params: { external_authorization_classification_label: 'new label' })
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.external_authorization_classification_label).to eq('new label') expect(project.reload.external_authorization_classification_label).to eq('new label')
end end
end end
...@@ -480,7 +480,7 @@ describe API::Projects do ...@@ -480,7 +480,7 @@ describe API::Projects do
it 'returns 200' do it 'returns 200' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'enables the service_desk' do it 'enables the service_desk' do
...@@ -500,7 +500,7 @@ describe API::Projects do ...@@ -500,7 +500,7 @@ describe API::Projects do
end end
end.not_to change(ProjectUpdateRepositoryStorageWorker.jobs, :size) end.not_to change(ProjectUpdateRepositoryStorageWorker.jobs, :size)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['issues_enabled']).to eq(false) expect(json_response['issues_enabled']).to eq(false)
expect(new_project.reload.repository.storage).to eq('default') expect(new_project.reload.repository.storage).to eq('default')
end end
...@@ -514,7 +514,7 @@ describe API::Projects do ...@@ -514,7 +514,7 @@ describe API::Projects do
it 'returns 500 when repository storage is unknown' do it 'returns 500 when repository storage is unknown' do
put(api("/projects/#{new_project.id}", admin), params: { repository_storage: unknown_storage }) put(api("/projects/#{new_project.id}", admin), params: { repository_storage: unknown_storage })
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response['message']).to match('ArgumentError') expect(json_response['message']).to match('ArgumentError')
end end
...@@ -527,7 +527,7 @@ describe API::Projects do ...@@ -527,7 +527,7 @@ describe API::Projects do
end end
end.to change(ProjectUpdateRepositoryStorageWorker.jobs, :size).by(1) end.to change(ProjectUpdateRepositoryStorageWorker.jobs, :size).by(1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -553,7 +553,7 @@ describe API::Projects do ...@@ -553,7 +553,7 @@ describe API::Projects do
it 'does not update mirror related attributes' do it 'does not update mirror related attributes' do
put(api("/projects/#{project.id}", user), params: mirror_params) put(api("/projects/#{project.id}", user), params: mirror_params)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.mirror).to be false expect(project.reload.mirror).to be false
end end
...@@ -566,7 +566,7 @@ describe API::Projects do ...@@ -566,7 +566,7 @@ describe API::Projects do
put(api("/projects/#{project.id}", admin), params: mirror_params) put(api("/projects/#{project.id}", admin), params: mirror_params)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project.reload).to have_attributes( expect(project.reload).to have_attributes(
mirror: true, mirror: true,
import_url: import_url, import_url: import_url,
...@@ -583,7 +583,7 @@ describe API::Projects do ...@@ -583,7 +583,7 @@ describe API::Projects do
put(api("/projects/#{project.id}", user), params: mirror_params) put(api("/projects/#{project.id}", user), params: mirror_params)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project.reload).to have_attributes( expect(project.reload).to have_attributes(
mirror: true, mirror: true,
import_url: import_url, import_url: import_url,
...@@ -599,7 +599,7 @@ describe API::Projects do ...@@ -599,7 +599,7 @@ describe API::Projects do
put(api("/projects/#{project.id}", user), params: mirror_params) put(api("/projects/#{project.id}", user), params: mirror_params)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.mirror).to be false expect(project.reload.mirror).to be false
end end
...@@ -610,7 +610,7 @@ describe API::Projects do ...@@ -610,7 +610,7 @@ describe API::Projects do
put(api("/projects/#{project.id}", user), params: mirror_params) put(api("/projects/#{project.id}", user), params: mirror_params)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]["mirror_user_id"].first).to eq("is invalid") expect(json_response["message"]["mirror_user_id"].first).to eq("is invalid")
end end
...@@ -637,7 +637,7 @@ describe API::Projects do ...@@ -637,7 +637,7 @@ describe API::Projects do
it 'disables project packages feature' do it 'disables project packages feature' do
put(api("/projects/#{project.id}", user), params: { packages_enabled: false }) put(api("/projects/#{project.id}", user), params: { packages_enabled: false })
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.packages_enabled).to be false expect(project.reload.packages_enabled).to be false
expect(json_response['packages_enabled']).to eq(false) expect(json_response['packages_enabled']).to eq(false)
end end
...@@ -651,7 +651,7 @@ describe API::Projects do ...@@ -651,7 +651,7 @@ describe API::Projects do
it 'disables project packages feature but does not return packages_enabled attribute' do it 'disables project packages feature but does not return packages_enabled attribute' do
put(api("/projects/#{project.id}", user), params: { packages_enabled: false }) put(api("/projects/#{project.id}", user), params: { packages_enabled: false })
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.packages_enabled).to be false expect(project.reload.packages_enabled).to be false
expect(json_response['packages_enabled']).to be_nil expect(json_response['packages_enabled']).to be_nil
end end
...@@ -665,7 +665,7 @@ describe API::Projects do ...@@ -665,7 +665,7 @@ describe API::Projects do
put api("/projects/#{project.id}", user), params: project_param put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvals_before_merge']).to eq(3) expect(json_response['approvals_before_merge']).to eq(3)
end end
end end
...@@ -683,7 +683,7 @@ describe API::Projects do ...@@ -683,7 +683,7 @@ describe API::Projects do
post api("/projects/#{project.id}/restore", user) post api("/projects/#{project.id}/restore", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['archived']).to be_falsey expect(json_response['archived']).to be_falsey
expect(json_response['marked_for_deletion_at']).to be_falsey expect(json_response['marked_for_deletion_at']).to be_falsey
end end
...@@ -694,7 +694,7 @@ describe API::Projects do ...@@ -694,7 +694,7 @@ describe API::Projects do
post api("/projects/#{project.id}/restore", user) post api("/projects/#{project.id}/restore", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq(message) expect(json_response["message"]).to eq(message)
end end
end end
...@@ -707,7 +707,7 @@ describe API::Projects do ...@@ -707,7 +707,7 @@ describe API::Projects do
it 'returns error' do it 'returns error' do
post api("/projects/#{project.id}/restore", user) post api("/projects/#{project.id}/restore", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -721,7 +721,7 @@ describe API::Projects do ...@@ -721,7 +721,7 @@ describe API::Projects do
it 'marks project for deletion' do it 'marks project for deletion' do
delete api("/projects/#{project.id}", user) delete api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(project.reload.marked_for_deletion?).to be_truthy expect(project.reload.marked_for_deletion?).to be_truthy
end end
...@@ -731,7 +731,7 @@ describe API::Projects do ...@@ -731,7 +731,7 @@ describe API::Projects do
delete api("/projects/#{project.id}", user) delete api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq(message) expect(json_response["message"]).to eq(message)
end end
...@@ -740,7 +740,7 @@ describe API::Projects do ...@@ -740,7 +740,7 @@ describe API::Projects do
allow(Gitlab::CurrentSettings).to receive(:deletion_adjourned_period).and_return(0) allow(Gitlab::CurrentSettings).to receive(:deletion_adjourned_period).and_return(0)
delete api("/projects/#{project.id}", user) delete api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(project.reload.pending_delete).to eq(true) expect(project.reload.pending_delete).to eq(true)
end end
end end
...@@ -754,7 +754,7 @@ describe API::Projects do ...@@ -754,7 +754,7 @@ describe API::Projects do
it 'deletes project' do it 'deletes project' do
delete api("/projects/#{project.id}", user) delete api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(project.reload.pending_delete).to eq(true) expect(project.reload.pending_delete).to eq(true)
end end
end end
......
...@@ -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
......
...@@ -49,7 +49,7 @@ describe API::PagesDomains do ...@@ -49,7 +49,7 @@ describe API::PagesDomains do
it 'returns paginated all pages domains' do it 'returns paginated all pages domains' do
get api('/pages/domains', admin) get api('/pages/domains', admin)
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/pages_domain_basics') expect(response).to match_response_schema('public_api/v4/pages_domain_basics')
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
...@@ -76,7 +76,7 @@ describe API::PagesDomains do ...@@ -76,7 +76,7 @@ describe API::PagesDomains do
it 'returns paginated pages domains' do it 'returns paginated pages domains' 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(response).to match_response_schema('public_api/v4/pages_domains') expect(response).to match_response_schema('public_api/v4/pages_domains')
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
...@@ -147,7 +147,7 @@ describe API::PagesDomains do ...@@ -147,7 +147,7 @@ describe API::PagesDomains do
it 'returns pages domain' do it 'returns pages domain' do
get api(route_domain, user) get api(route_domain, 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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(json_response['domain']).to eq(pages_domain.domain) expect(json_response['domain']).to eq(pages_domain.domain)
expect(json_response['url']).to eq(pages_domain.url) expect(json_response['url']).to eq(pages_domain.url)
...@@ -157,7 +157,7 @@ describe API::PagesDomains do ...@@ -157,7 +157,7 @@ describe API::PagesDomains do
it 'returns pages domain with project path' do it 'returns pages domain with project path' do
get api(route_domain_path, user) get api(route_domain_path, 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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(json_response['domain']).to eq(pages_domain.domain) expect(json_response['domain']).to eq(pages_domain.domain)
expect(json_response['url']).to eq(pages_domain.url) expect(json_response['url']).to eq(pages_domain.url)
...@@ -167,7 +167,7 @@ describe API::PagesDomains do ...@@ -167,7 +167,7 @@ describe API::PagesDomains do
it 'returns pages domain with a certificate' do it 'returns pages domain with a certificate' do
get api(route_secure_domain, user) get api(route_secure_domain, 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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(json_response['domain']).to eq(pages_domain_secure.domain) expect(json_response['domain']).to eq(pages_domain_secure.domain)
expect(json_response['url']).to eq(pages_domain_secure.url) expect(json_response['url']).to eq(pages_domain_secure.url)
...@@ -179,7 +179,7 @@ describe API::PagesDomains do ...@@ -179,7 +179,7 @@ describe API::PagesDomains do
it 'returns pages domain with an expired certificate' do it 'returns pages domain with an expired certificate' do
get api(route_expired_domain, user) get api(route_expired_domain, 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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(json_response['certificate']['expired']).to be true expect(json_response['certificate']['expired']).to be true
end end
...@@ -187,7 +187,7 @@ describe API::PagesDomains do ...@@ -187,7 +187,7 @@ describe API::PagesDomains do
it 'returns pages domain with letsencrypt' do it 'returns pages domain with letsencrypt' do
get api(route_letsencrypt_domain, user) get api(route_letsencrypt_domain, 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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(json_response['domain']).to eq(pages_domain_with_letsencrypt.domain) expect(json_response['domain']).to eq(pages_domain_with_letsencrypt.domain)
expect(json_response['url']).to eq(pages_domain_with_letsencrypt.url) expect(json_response['url']).to eq(pages_domain_with_letsencrypt.url)
...@@ -261,7 +261,7 @@ describe API::PagesDomains do ...@@ -261,7 +261,7 @@ describe API::PagesDomains do
post api(route, user), params: params post api(route, user), params: params
pages_domain = PagesDomain.find_by(domain: json_response['domain']) pages_domain = PagesDomain.find_by(domain: json_response['domain'])
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain.domain).to eq(params[:domain]) expect(pages_domain.domain).to eq(params[:domain])
expect(pages_domain.certificate).to be_nil expect(pages_domain.certificate).to be_nil
...@@ -273,7 +273,7 @@ describe API::PagesDomains do ...@@ -273,7 +273,7 @@ describe API::PagesDomains do
post api(route, user), params: params_secure post api(route, user), params: params_secure
pages_domain = PagesDomain.find_by(domain: json_response['domain']) pages_domain = PagesDomain.find_by(domain: json_response['domain'])
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain.domain).to eq(params_secure[:domain]) expect(pages_domain.domain).to eq(params_secure[:domain])
expect(pages_domain.certificate).to eq(params_secure[:certificate]) expect(pages_domain.certificate).to eq(params_secure[:certificate])
...@@ -285,7 +285,7 @@ describe API::PagesDomains do ...@@ -285,7 +285,7 @@ describe API::PagesDomains do
post api(route, user), params: pages_domain_with_letsencrypt_params post api(route, user), params: pages_domain_with_letsencrypt_params
pages_domain = PagesDomain.find_by(domain: json_response['domain']) pages_domain = PagesDomain.find_by(domain: json_response['domain'])
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain.domain).to eq(pages_domain_with_letsencrypt_params[:domain]) expect(pages_domain.domain).to eq(pages_domain_with_letsencrypt_params[:domain])
expect(pages_domain.auto_ssl_enabled).to be true expect(pages_domain.auto_ssl_enabled).to be true
...@@ -295,7 +295,7 @@ describe API::PagesDomains do ...@@ -295,7 +295,7 @@ describe API::PagesDomains do
post api(route, user), params: params_secure.merge(auto_ssl_enabled: true) post api(route, user), params: params_secure.merge(auto_ssl_enabled: true)
pages_domain = PagesDomain.find_by(domain: json_response['domain']) pages_domain = PagesDomain.find_by(domain: json_response['domain'])
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain.domain).to eq(params_secure[:domain]) expect(pages_domain.domain).to eq(params_secure[:domain])
expect(pages_domain.certificate).to eq(params_secure[:certificate]) expect(pages_domain.certificate).to eq(params_secure[:certificate])
...@@ -306,13 +306,13 @@ describe API::PagesDomains do ...@@ -306,13 +306,13 @@ describe API::PagesDomains do
it 'fails to create pages domain without key' do it 'fails to create pages domain without key' do
post api(route, user), params: pages_domain_secure_params.slice(:domain, :certificate) post api(route, user), params: pages_domain_secure_params.slice(:domain, :certificate)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'fails to create pages domain with key missmatch' do it 'fails to create pages domain with key missmatch' do
post api(route, user), params: pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key) post api(route, user), params: pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -370,7 +370,7 @@ describe API::PagesDomains do ...@@ -370,7 +370,7 @@ describe API::PagesDomains do
put api(route_secure_domain, user), params: { certificate: nil, key: nil } put api(route_secure_domain, user), params: { certificate: nil, key: nil }
pages_domain_secure.reload pages_domain_secure.reload
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain_secure.certificate).to be_nil expect(pages_domain_secure.certificate).to be_nil
expect(pages_domain_secure.key).to be_nil expect(pages_domain_secure.key).to be_nil
...@@ -381,7 +381,7 @@ describe API::PagesDomains do ...@@ -381,7 +381,7 @@ describe API::PagesDomains do
put api(route_domain, user), params: params_secure put api(route_domain, user), params: params_secure
pages_domain.reload pages_domain.reload
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain.certificate).to eq(params_secure[:certificate]) expect(pages_domain.certificate).to eq(params_secure[:certificate])
expect(pages_domain.key).to eq(params_secure[:key]) expect(pages_domain.key).to eq(params_secure[:key])
...@@ -391,7 +391,7 @@ describe API::PagesDomains do ...@@ -391,7 +391,7 @@ describe API::PagesDomains do
put api(route_domain, user), params: params_secure.merge(auto_ssl_enabled: true) put api(route_domain, user), params: params_secure.merge(auto_ssl_enabled: true)
pages_domain.reload pages_domain.reload
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain.certificate).to eq(params_secure[:certificate]) expect(pages_domain.certificate).to eq(params_secure[:certificate])
expect(pages_domain.key).to eq(params_secure[:key]) expect(pages_domain.key).to eq(params_secure[:key])
...@@ -402,7 +402,7 @@ describe API::PagesDomains do ...@@ -402,7 +402,7 @@ describe API::PagesDomains do
put api(route_domain, user), params: { auto_ssl_enabled: true } put api(route_domain, user), params: { auto_ssl_enabled: true }
pages_domain.reload pages_domain.reload
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain.auto_ssl_enabled).to be true expect(pages_domain.auto_ssl_enabled).to be true
end end
...@@ -411,7 +411,7 @@ describe API::PagesDomains do ...@@ -411,7 +411,7 @@ describe API::PagesDomains do
put api(route_letsencrypt_domain, user), params: { auto_ssl_enabled: false } put api(route_letsencrypt_domain, user), params: { auto_ssl_enabled: false }
pages_domain_with_letsencrypt.reload pages_domain_with_letsencrypt.reload
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain_with_letsencrypt.auto_ssl_enabled).to be false expect(pages_domain_with_letsencrypt.auto_ssl_enabled).to be false
expect(pages_domain_with_letsencrypt.key).to be expect(pages_domain_with_letsencrypt.key).to be
...@@ -422,7 +422,7 @@ describe API::PagesDomains do ...@@ -422,7 +422,7 @@ describe API::PagesDomains do
put api(route_expired_domain, user), params: params_secure put api(route_expired_domain, user), params: params_secure
pages_domain_expired.reload pages_domain_expired.reload
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain_expired.certificate).to eq(params_secure[:certificate]) expect(pages_domain_expired.certificate).to eq(params_secure[:certificate])
expect(pages_domain_expired.key).to eq(params_secure[:key]) expect(pages_domain_expired.key).to eq(params_secure[:key])
...@@ -432,7 +432,7 @@ describe API::PagesDomains do ...@@ -432,7 +432,7 @@ describe API::PagesDomains do
put api(route_secure_domain, user), params: params_secure_nokey put api(route_secure_domain, user), params: params_secure_nokey
pages_domain_secure.reload pages_domain_secure.reload
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/pages_domain/detail') expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
expect(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate]) expect(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate])
end end
...@@ -448,19 +448,19 @@ describe API::PagesDomains do ...@@ -448,19 +448,19 @@ describe API::PagesDomains do
it 'fails to update pages domain adding certificate without key' do it 'fails to update pages domain adding certificate without key' do
put api(route_domain, user), params: params_secure_nokey put api(route_domain, user), params: params_secure_nokey
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'fails to update pages domain adding certificate with missing chain' do it 'fails to update pages domain adding certificate with missing chain' do
put api(route_domain, user), params: pages_domain_secure_missing_chain_params.slice(:certificate) put api(route_domain, user), params: pages_domain_secure_missing_chain_params.slice(:certificate)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'fails to update pages domain with key missmatch' do it 'fails to update pages domain with key missmatch' do
put api(route_secure_domain, user), params: pages_domain_secure_key_missmatch_params.slice(:certificate, :key) put api(route_secure_domain, user), params: pages_domain_secure_key_missmatch_params.slice(:certificate, :key)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -524,7 +524,7 @@ describe API::PagesDomains do ...@@ -524,7 +524,7 @@ describe API::PagesDomains do
it 'deletes a pages domain' do it 'deletes a pages domain' do
delete api(route_domain, user) delete api(route_domain, user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
......
...@@ -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
......
...@@ -23,7 +23,7 @@ describe API::Pipelines do ...@@ -23,7 +23,7 @@ describe API::Pipelines do
it 'returns project pipelines' do it 'returns project pipelines' do
get api("/projects/#{project.id}/pipelines", user) get api("/projects/#{project.id}/pipelines", 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.first['sha']).to match /\A\h{40}\z/ expect(json_response.first['sha']).to match /\A\h{40}\z/
...@@ -294,7 +294,7 @@ describe API::Pipelines do ...@@ -294,7 +294,7 @@ describe API::Pipelines do
it 'does not return project pipelines' do it 'does not return project pipelines' do
get api("/projects/#{project.id}/pipelines", non_member) get api("/projects/#{project.id}/pipelines", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['message']).to eq '404 Project Not Found'
expect(json_response).not_to be_an Array expect(json_response).not_to be_an Array
end end
...@@ -323,7 +323,7 @@ describe API::Pipelines do ...@@ -323,7 +323,7 @@ describe API::Pipelines do
post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
end.to change { project.ci_pipelines.count }.by(1) end.to change { project.ci_pipelines.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response).to be_a Hash expect(json_response).to be_a Hash
expect(json_response['sha']).to eq project.commit.id expect(json_response['sha']).to eq project.commit.id
end end
...@@ -337,7 +337,7 @@ describe API::Pipelines do ...@@ -337,7 +337,7 @@ describe API::Pipelines do
end.to change { project.ci_pipelines.count }.by(1) end.to change { project.ci_pipelines.count }.by(1)
expect_variables(project.ci_pipelines.last.variables, variables) expect_variables(project.ci_pipelines.last.variables, variables)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response).to be_a Hash expect(json_response).to be_a Hash
expect(json_response['sha']).to eq project.commit.id expect(json_response['sha']).to eq project.commit.id
expect(json_response).not_to have_key('variables') expect(json_response).not_to have_key('variables')
...@@ -358,7 +358,7 @@ describe API::Pipelines do ...@@ -358,7 +358,7 @@ describe API::Pipelines do
end.to change { project.ci_pipelines.count }.by(1) end.to change { project.ci_pipelines.count }.by(1)
expect_variables(project.ci_pipelines.last.variables, variables) expect_variables(project.ci_pipelines.last.variables, variables)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response).to be_a Hash expect(json_response).to be_a Hash
expect(json_response['sha']).to eq project.commit.id expect(json_response['sha']).to eq project.commit.id
expect(json_response).not_to have_key('variables') expect(json_response).not_to have_key('variables')
...@@ -372,7 +372,7 @@ describe API::Pipelines do ...@@ -372,7 +372,7 @@ describe API::Pipelines do
post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
end.not_to change { project.ci_pipelines.count } end.not_to change { project.ci_pipelines.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -380,7 +380,7 @@ describe API::Pipelines do ...@@ -380,7 +380,7 @@ describe API::Pipelines do
it 'fails when using an invalid ref' do it 'fails when using an invalid ref' do
post api("/projects/#{project.id}/pipeline", user), params: { ref: 'invalid_ref' } post api("/projects/#{project.id}/pipeline", user), params: { ref: 'invalid_ref' }
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 'Reference not found' expect(json_response['message']['base'].first).to eq 'Reference not found'
expect(json_response).not_to be_an Array expect(json_response).not_to be_an Array
end end
...@@ -395,7 +395,7 @@ describe API::Pipelines do ...@@ -395,7 +395,7 @@ describe API::Pipelines do
it 'fails to create pipeline' do it 'fails to create pipeline' do
post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
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 'Missing CI config file' expect(json_response['message']['base'].first).to eq 'Missing CI config file'
expect(json_response).not_to be_an Array expect(json_response).not_to be_an Array
end end
...@@ -407,7 +407,7 @@ describe API::Pipelines do ...@@ -407,7 +407,7 @@ describe API::Pipelines do
it 'does not create pipeline' do it 'does not create pipeline' do
post api("/projects/#{project.id}/pipeline", non_member), params: { ref: project.default_branch } post api("/projects/#{project.id}/pipeline", non_member), params: { ref: project.default_branch }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['message']).to eq '404 Project Not Found'
expect(json_response).not_to be_an Array expect(json_response).not_to be_an Array
end end
...@@ -428,21 +428,21 @@ describe API::Pipelines do ...@@ -428,21 +428,21 @@ describe API::Pipelines do
it 'exposes known attributes' do it 'exposes known attributes' do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) get api("/projects/#{project.id}/pipelines/#{pipeline.id}", 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/pipeline/detail') expect(response).to match_response_schema('public_api/v4/pipeline/detail')
end end
it 'returns project pipelines' do it 'returns project pipelines' do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['sha']).to match /\A\h{40}\z/ expect(json_response['sha']).to match /\A\h{40}\z/
end end
it 'returns 404 when it does not exist' do it 'returns 404 when it does not exist' do
get api("/projects/#{project.id}/pipelines/123456", user) get api("/projects/#{project.id}/pipelines/123456", 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'
expect(json_response['id']).to be nil expect(json_response['id']).to be nil
end end
...@@ -464,7 +464,7 @@ describe API::Pipelines do ...@@ -464,7 +464,7 @@ describe API::Pipelines do
it 'does not return a project pipeline' do it 'does not return a project pipeline' do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['message']).to eq '404 Project Not Found'
expect(json_response['id']).to be nil expect(json_response['id']).to be nil
end end
...@@ -489,7 +489,7 @@ describe API::Pipelines do ...@@ -489,7 +489,7 @@ describe API::Pipelines do
it 'gets the latest pipleine' do it 'gets the latest pipleine' do
get api("/projects/#{project.id}/pipelines/latest", user) get api("/projects/#{project.id}/pipelines/latest", 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/pipeline/detail') expect(response).to match_response_schema('public_api/v4/pipeline/detail')
expect(json_response['ref']).to eq(project.default_branch) expect(json_response['ref']).to eq(project.default_branch)
expect(json_response['sha']).to eq(project.commit.id) expect(json_response['sha']).to eq(project.commit.id)
...@@ -500,7 +500,7 @@ describe API::Pipelines do ...@@ -500,7 +500,7 @@ describe API::Pipelines do
it 'gets the latest pipleine' do it 'gets the latest pipleine' do
get api("/projects/#{project.id}/pipelines/latest", user), params: { ref: second_branch.name } get api("/projects/#{project.id}/pipelines/latest", user), params: { ref: second_branch.name }
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/pipeline/detail') expect(response).to match_response_schema('public_api/v4/pipeline/detail')
expect(json_response['ref']).to eq(second_branch.name) expect(json_response['ref']).to eq(second_branch.name)
expect(json_response['sha']).to eq(second_branch.target) expect(json_response['sha']).to eq(second_branch.target)
...@@ -512,7 +512,7 @@ describe API::Pipelines do ...@@ -512,7 +512,7 @@ describe API::Pipelines do
it 'does not return a project pipeline' do it 'does not return a project pipeline' do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['message']).to eq '404 Project Not Found'
expect(json_response['id']).to be nil expect(json_response['id']).to be nil
end end
...@@ -528,7 +528,7 @@ describe API::Pipelines do ...@@ -528,7 +528,7 @@ describe API::Pipelines do
it 'returns pipeline variables empty' do it 'returns pipeline variables empty' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty expect(json_response).to be_empty
end end
...@@ -538,7 +538,7 @@ describe API::Pipelines do ...@@ -538,7 +538,7 @@ describe API::Pipelines do
it 'returns pipeline variables' do it 'returns pipeline variables' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly({ "variable_type" => "env_var", "key" => "foo", "value" => "bar" }) expect(json_response).to contain_exactly({ "variable_type" => "env_var", "key" => "foo", "value" => "bar" })
end end
end end
...@@ -559,7 +559,7 @@ describe API::Pipelines do ...@@ -559,7 +559,7 @@ describe API::Pipelines do
it 'returns pipeline variables' do it 'returns pipeline variables' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly({ "variable_type" => "env_var", "key" => "foo", "value" => "bar" }) expect(json_response).to contain_exactly({ "variable_type" => "env_var", "key" => "foo", "value" => "bar" })
end end
end end
...@@ -570,7 +570,7 @@ describe API::Pipelines do ...@@ -570,7 +570,7 @@ describe API::Pipelines do
it 'does not return pipeline variables' do it 'does not return pipeline variables' 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
...@@ -579,7 +579,7 @@ describe API::Pipelines do ...@@ -579,7 +579,7 @@ describe API::Pipelines do
it 'does not return pipeline variables' do it 'does not return pipeline variables' do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/variables", non_member) get api("/projects/#{project.id}/pipelines/#{pipeline.id}/variables", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['message']).to eq '404 Project Not Found'
end end
end end
...@@ -592,14 +592,14 @@ describe API::Pipelines do ...@@ -592,14 +592,14 @@ describe API::Pipelines do
it 'destroys the pipeline' do it 'destroys the pipeline' do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect { pipeline.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { pipeline.reload }.to raise_error(ActiveRecord::RecordNotFound)
end end
it 'returns 404 when it does not exist' do it 'returns 404 when it does not exist' do
delete api("/projects/#{project.id}/pipelines/123456", owner) delete api("/projects/#{project.id}/pipelines/123456", owner)
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
...@@ -613,7 +613,7 @@ describe API::Pipelines do ...@@ -613,7 +613,7 @@ describe API::Pipelines do
it 'destroys associated jobs' do it 'destroys associated jobs' do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect { build.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { build.reload }.to raise_error(ActiveRecord::RecordNotFound)
end end
end end
...@@ -624,7 +624,7 @@ describe API::Pipelines do ...@@ -624,7 +624,7 @@ describe API::Pipelines do
it 'returns a 404' do it 'returns a 404' do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['message']).to eq '404 Project Not Found'
end end
end end
...@@ -639,7 +639,7 @@ describe API::Pipelines do ...@@ -639,7 +639,7 @@ describe API::Pipelines do
it 'returns a 403' do it 'returns a 403' do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", developer) delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", 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
end end
...@@ -660,7 +660,7 @@ describe API::Pipelines do ...@@ -660,7 +660,7 @@ describe API::Pipelines do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user) post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user)
end.to change { pipeline.builds.count }.from(1).to(2) end.to change { pipeline.builds.count }.from(1).to(2)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(build.reload.retried?).to be true expect(build.reload.retried?).to be true
end end
end end
...@@ -669,7 +669,7 @@ describe API::Pipelines do ...@@ -669,7 +669,7 @@ describe API::Pipelines do
it 'does not return a project pipeline' do it 'does not return a project pipeline' do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member) post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['message']).to eq '404 Project Not Found'
expect(json_response['id']).to be nil expect(json_response['id']).to be nil
end end
...@@ -688,7 +688,7 @@ describe API::Pipelines do ...@@ -688,7 +688,7 @@ describe API::Pipelines do
it 'retries failed builds', :sidekiq_might_not_need_inline do it 'retries failed builds', :sidekiq_might_not_need_inline do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user) post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('canceled') expect(json_response['status']).to eq('canceled')
end end
end end
...@@ -703,7 +703,7 @@ describe API::Pipelines do ...@@ -703,7 +703,7 @@ describe API::Pipelines do
it 'rejects the action' do it 'rejects the action' do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter) post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(pipeline.reload.status).to eq('pending') expect(pipeline.reload.status).to eq('pending')
end end
end end
......
...@@ -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
......
...@@ -30,7 +30,7 @@ describe API::ProjectImport do ...@@ -30,7 +30,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
...@@ -38,7 +38,7 @@ describe API::ProjectImport do ...@@ -38,7 +38,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
...@@ -49,7 +49,7 @@ describe API::ProjectImport do ...@@ -49,7 +49,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
...@@ -57,7 +57,7 @@ describe API::ProjectImport do ...@@ -57,7 +57,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
...@@ -93,7 +93,7 @@ describe API::ProjectImport do ...@@ -93,7 +93,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
...@@ -102,7 +102,7 @@ describe API::ProjectImport do ...@@ -102,7 +102,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
...@@ -116,7 +116,7 @@ describe API::ProjectImport do ...@@ -116,7 +116,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
...@@ -125,7 +125,7 @@ describe API::ProjectImport do ...@@ -125,7 +125,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
...@@ -186,7 +186,7 @@ describe API::ProjectImport do ...@@ -186,7 +186,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
...@@ -196,7 +196,7 @@ describe API::ProjectImport do ...@@ -196,7 +196,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
...@@ -209,7 +209,7 @@ describe API::ProjectImport do ...@@ -209,7 +209,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
...@@ -276,7 +276,7 @@ describe API::ProjectImport do ...@@ -276,7 +276,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
...@@ -287,7 +287,7 @@ describe API::ProjectImport do ...@@ -287,7 +287,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']
......
...@@ -110,7 +110,7 @@ describe API::Projects do ...@@ -110,7 +110,7 @@ describe API::Projects do
it 'returns an array of projects' do it 'returns an array of projects' do
get api('/projects', current_user), params: filter get api('/projects', current_user), params: filter
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.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id)) expect(json_response.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id))
...@@ -210,7 +210,7 @@ describe API::Projects do ...@@ -210,7 +210,7 @@ describe API::Projects do
get api('/projects', user) get api('/projects', 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(json_response.map { |p| p['id'] }).not_to include(project.id) expect(json_response.map { |p| p['id'] }).not_to include(project.id)
end end
...@@ -242,7 +242,7 @@ describe API::Projects do ...@@ -242,7 +242,7 @@ describe API::Projects do
it "does not include statistics by default" do it "does not include statistics by default" do
get api('/projects', user) get api('/projects', 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.first).not_to include('statistics') expect(json_response.first).not_to include('statistics')
...@@ -251,7 +251,7 @@ describe API::Projects do ...@@ -251,7 +251,7 @@ describe API::Projects do
it "includes statistics if requested" do it "includes statistics if requested" do
get api('/projects', user), params: { statistics: true } get api('/projects', user), params: { statistics: true }
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.first).to include 'statistics' expect(json_response.first).to include 'statistics'
...@@ -260,7 +260,7 @@ describe API::Projects do ...@@ -260,7 +260,7 @@ describe API::Projects do
it "does not include license by default" do it "does not include license by default" do
get api('/projects', user) get api('/projects', 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.first).not_to include('license', 'license_url') expect(json_response.first).not_to include('license', 'license_url')
...@@ -269,7 +269,7 @@ describe API::Projects do ...@@ -269,7 +269,7 @@ describe API::Projects do
it "does not include license if requested" do it "does not include license if requested" do
get api('/projects', user), params: { license: true } get api('/projects', user), params: { license: true }
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.first).not_to include('license', 'license_url') expect(json_response.first).not_to include('license', 'license_url')
...@@ -314,7 +314,7 @@ describe API::Projects do ...@@ -314,7 +314,7 @@ describe API::Projects do
get api('/projects?simple=true', user) get api('/projects?simple=true', 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.first.keys).to match_array expected_keys expect(json_response.first.keys).to match_array expected_keys
...@@ -327,7 +327,7 @@ describe API::Projects do ...@@ -327,7 +327,7 @@ describe API::Projects do
it 'returns archived projects' do it 'returns archived projects' do
get api('/projects?archived=true', user) get api('/projects?archived=true', 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.length).to eq(Project.public_or_visible_to_user(user).where(archived: true).size) expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: true).size)
...@@ -337,7 +337,7 @@ describe API::Projects do ...@@ -337,7 +337,7 @@ describe API::Projects do
it 'returns non-archived projects' do it 'returns non-archived projects' do
get api('/projects?archived=false', user) get api('/projects?archived=false', 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.length).to eq(Project.public_or_visible_to_user(user).where(archived: false).size) expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: false).size)
...@@ -347,7 +347,7 @@ describe API::Projects do ...@@ -347,7 +347,7 @@ describe API::Projects do
it 'returns every project' do it 'returns every project' do
get api('/projects', user) get api('/projects', 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.map { |project| project['id'] }).to contain_exactly(*Project.public_or_visible_to_user(user).pluck(:id)) expect(json_response.map { |project| project['id'] }).to contain_exactly(*Project.public_or_visible_to_user(user).pluck(:id))
...@@ -398,7 +398,7 @@ describe API::Projects do ...@@ -398,7 +398,7 @@ describe API::Projects do
it 'filters based on private visibility param' do it 'filters based on private visibility param' do
get api('/projects', user), params: { visibility: 'private' } get api('/projects', user), params: { visibility: 'private' }
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.map { |p| p['id'] }).to contain_exactly(project.id, project2.id, project3.id) expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id, project2.id, project3.id)
...@@ -409,7 +409,7 @@ describe API::Projects do ...@@ -409,7 +409,7 @@ describe API::Projects do
get api('/projects', user), params: { visibility: 'internal' } get api('/projects', user), params: { visibility: 'internal' }
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.map { |p| p['id'] }).to contain_exactly(project2.id) expect(json_response.map { |p| p['id'] }).to contain_exactly(project2.id)
...@@ -418,7 +418,7 @@ describe API::Projects do ...@@ -418,7 +418,7 @@ describe API::Projects do
it 'filters based on public visibility param' do it 'filters based on public visibility param' do
get api('/projects', user), params: { visibility: 'public' } get api('/projects', user), params: { visibility: 'public' }
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.map { |p| p['id'] }).to contain_exactly(public_project.id) expect(json_response.map { |p| p['id'] }).to contain_exactly(public_project.id)
...@@ -431,7 +431,7 @@ describe API::Projects do ...@@ -431,7 +431,7 @@ describe API::Projects do
it 'filters case-insensitively by programming language' do it 'filters case-insensitively by programming language' do
get api('/projects', user), params: { with_programming_language: 'javascript' } get api('/projects', user), params: { with_programming_language: 'javascript' }
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.map { |p| p['id'] }).to contain_exactly(project3.id) expect(json_response.map { |p| p['id'] }).to contain_exactly(project3.id)
...@@ -442,7 +442,7 @@ describe API::Projects do ...@@ -442,7 +442,7 @@ describe API::Projects do
it 'returns the correct order when sorted by id' do it 'returns the correct order when sorted by id' do
get api('/projects', user), params: { order_by: 'id', sort: 'desc' } get api('/projects', user), params: { order_by: 'id', sort: 'desc' }
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.first['id']).to eq(project3.id) expect(json_response.first['id']).to eq(project3.id)
...@@ -453,7 +453,7 @@ describe API::Projects do ...@@ -453,7 +453,7 @@ describe API::Projects do
it 'returns an array of projects the user owns' do it 'returns an array of projects the user owns' do
get api('/projects', user4), params: { owned: true } get api('/projects', user4), params: { owned: true }
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.first['name']).to eq(project4.name) expect(json_response.first['name']).to eq(project4.name)
...@@ -472,7 +472,7 @@ describe API::Projects do ...@@ -472,7 +472,7 @@ describe API::Projects do
it 'returns the starred projects viewable by the user' do it 'returns the starred projects viewable by the user' do
get api('/projects', user3), params: { starred: true } get api('/projects', user3), params: { starred: true }
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.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id)
...@@ -494,7 +494,7 @@ describe API::Projects do ...@@ -494,7 +494,7 @@ describe API::Projects do
it 'returns only projects that satisfy all query parameters' do it 'returns only projects that satisfy all query parameters' do
get api('/projects', user), params: { visibility: 'public', owned: true, starred: true, search: 'gitlab' } get api('/projects', user), params: { visibility: 'public', owned: true, starred: true, search: 'gitlab' }
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)
...@@ -513,7 +513,7 @@ describe API::Projects do ...@@ -513,7 +513,7 @@ describe API::Projects do
it 'returns only projects that satisfy all query parameters' do it 'returns only projects that satisfy all query parameters' do
get api('/projects', user), params: { visibility: 'public', membership: true, starred: true, search: 'gitlab' } get api('/projects', user), params: { visibility: 'public', membership: true, starred: true, search: 'gitlab' }
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(2) expect(json_response.size).to eq(2)
...@@ -532,7 +532,7 @@ describe API::Projects do ...@@ -532,7 +532,7 @@ describe API::Projects do
it 'returns an array of projects the user has at least developer access' do it 'returns an array of projects the user has at least developer access' do
get api('/projects', user2), params: { min_access_level: 30 } get api('/projects', user2), params: { min_access_level: 30 }
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.map { |project| project['id'] }).to contain_exactly(project2.id, project3.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(project2.id, project3.id)
...@@ -587,7 +587,7 @@ describe API::Projects do ...@@ -587,7 +587,7 @@ describe API::Projects do
it 'contains only the first project with per_page = 1' do it 'contains only the first project with per_page = 1' do
get api('/projects', current_user), params: params get api('/projects', current_user), params: params
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(json_response.map { |p| p['id'] }).to contain_exactly(public_project.id) expect(json_response.map { |p| p['id'] }).to contain_exactly(public_project.id)
end end
...@@ -609,14 +609,14 @@ describe API::Projects do ...@@ -609,14 +609,14 @@ describe API::Projects do
it 'returns an empty array when the page does not have any records' do it 'returns an empty array when the page does not have any records' do
get api('/projects', current_user), params: params.merge(id_after: Project.maximum(:id)) get api('/projects', current_user), params: params.merge(id_after: Project.maximum(:id))
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq([]) expect(json_response).to eq([])
end end
it 'responds with 501 if order_by is different from id' do it 'responds with 501 if order_by is different from id' do
get api('/projects', current_user), params: params.merge(order_by: :created_at) get api('/projects', current_user), params: params.merge(order_by: :created_at)
expect(response).to have_gitlab_http_status(405) expect(response).to have_gitlab_http_status(:method_not_allowed)
end end
end end
...@@ -634,7 +634,7 @@ describe API::Projects do ...@@ -634,7 +634,7 @@ describe API::Projects do
it 'contains only the last project with per_page = 1' do it 'contains only the last project with per_page = 1' do
get api('/projects', current_user), params: params get api('/projects', current_user), params: params
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(json_response.map { |p| p['id'] }).to contain_exactly(project3.id) expect(json_response.map { |p| p['id'] }).to contain_exactly(project3.id)
end end
...@@ -672,14 +672,14 @@ describe API::Projects do ...@@ -672,14 +672,14 @@ describe API::Projects do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0)
expect { post api('/projects', user2), params: { name: 'foo' } } expect { post api('/projects', user2), params: { name: 'foo' } }
.to change {Project.count}.by(0) .to change {Project.count}.by(0)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
it 'creates new project without path but with name and returns 201' do it 'creates new project without path but with name and returns 201' do
expect { post api('/projects', user), params: { name: 'Foo Project' } } expect { post api('/projects', user), params: { name: 'Foo Project' } }
.to change { Project.count }.by(1) .to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project = Project.first project = Project.first
...@@ -690,7 +690,7 @@ describe API::Projects do ...@@ -690,7 +690,7 @@ describe API::Projects do
it 'creates new project without name but with path and returns 201' do it 'creates new project without name but with path and returns 201' do
expect { post api('/projects', user), params: { path: 'foo_project' } } expect { post api('/projects', user), params: { path: 'foo_project' } }
.to change { Project.count }.by(1) .to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project = Project.first project = Project.first
...@@ -701,7 +701,7 @@ describe API::Projects do ...@@ -701,7 +701,7 @@ describe API::Projects do
it 'creates new project with name and path and returns 201' do it 'creates new project with name and path and returns 201' do
expect { post api('/projects', user), params: { path: 'path-project-Foo', name: 'Foo Project' } } expect { post api('/projects', user), params: { path: 'path-project-Foo', name: 'Foo Project' } }
.to change { Project.count }.by(1) .to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project = Project.first project = Project.first
...@@ -712,12 +712,12 @@ describe API::Projects do ...@@ -712,12 +712,12 @@ describe API::Projects do
it 'creates last project before reaching project limit' do it 'creates last project before reaching project limit' do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1)
post api('/projects', user2), params: { name: 'foo' } post api('/projects', user2), params: { name: 'foo' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'does not create new project without name or path and returns 400' do it 'does not create new project without name or path and returns 400' do
expect { post api('/projects', user) }.not_to change { Project.count } expect { post api('/projects', user) }.not_to change { Project.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "assigns attributes to project" do it "assigns attributes to project" do
...@@ -739,7 +739,7 @@ describe API::Projects do ...@@ -739,7 +739,7 @@ describe API::Projects do
post api('/projects', user), params: project post api('/projects', user), params: project
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project.each_pair do |k, v| project.each_pair do |k, v|
next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled storage_version].include?(k) next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled storage_version].include?(k)
...@@ -758,7 +758,7 @@ describe API::Projects do ...@@ -758,7 +758,7 @@ describe API::Projects do
expect { post api('/projects', user), params: { template_name: 'rails', name: 'rails-test' } } expect { post api('/projects', user), params: { template_name: 'rails', name: 'rails-test' } }
.to change { Project.count }.by(1) .to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project = Project.find(json_response['id']) project = Project.find(json_response['id'])
expect(project).to be_saved expect(project).to be_saved
...@@ -769,7 +769,7 @@ describe API::Projects do ...@@ -769,7 +769,7 @@ describe API::Projects do
expect { post api('/projects', user), params: { template_name: 'unknown', name: 'rails-test' } } expect { post api('/projects', user), params: { template_name: 'unknown', name: 'rails-test' } }
.not_to change { Project.count } .not_to change { Project.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['template_name']).to eq(["'unknown' is unknown or invalid"]) expect(json_response['message']['template_name']).to eq(["'unknown' is unknown or invalid"])
end end
...@@ -778,7 +778,7 @@ describe API::Projects do ...@@ -778,7 +778,7 @@ describe API::Projects do
expect { post api('/projects', user), params: project_params } expect { post api('/projects', user), params: project_params }
.not_to change { Project.count } .not_to change { Project.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'sets a project as public' do it 'sets a project as public' do
...@@ -931,7 +931,7 @@ describe API::Projects do ...@@ -931,7 +931,7 @@ describe API::Projects do
post api('/projects', user), params: project post api('/projects', user), params: project
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'ignores import_url when it is nil' do it 'ignores import_url when it is nil' do
...@@ -939,7 +939,7 @@ describe API::Projects do ...@@ -939,7 +939,7 @@ describe API::Projects do
post api('/projects', user), params: project post api('/projects', user), params: project
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
context 'when a visibility level is restricted' do context 'when a visibility level is restricted' do
...@@ -952,7 +952,7 @@ describe API::Projects do ...@@ -952,7 +952,7 @@ describe API::Projects do
it 'does not allow a non-admin to use a restricted visibility level' do it 'does not allow a non-admin to use a restricted visibility level' do
post api('/projects', user), params: project_param post api('/projects', user), params: project_param
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['visibility_level'].first).to( expect(json_response['message']['visibility_level'].first).to(
match('restricted by your GitLab administrator') match('restricted by your GitLab administrator')
) )
...@@ -972,14 +972,14 @@ describe API::Projects do ...@@ -972,14 +972,14 @@ describe API::Projects do
it 'returns error when user not found' do it 'returns error when user not found' do
get api('/users/0/projects/') get api('/users/0/projects/')
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found') expect(json_response['message']).to eq('404 User Not Found')
end end
it 'returns projects filtered by user id' do it 'returns projects filtered by user id' do
get api("/users/#{user4.id}/projects/", user) get api("/users/#{user4.id}/projects/", 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.map { |project| project['id'] }).to contain_exactly(public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
...@@ -991,7 +991,7 @@ describe API::Projects do ...@@ -991,7 +991,7 @@ describe API::Projects do
it 'only returns projects with id_after filter given' do it 'only returns projects with id_after filter given' do
get api("/users/#{user4.id}/projects?id_after=#{public_project.id}", user) get api("/users/#{user4.id}/projects?id_after=#{public_project.id}", 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.map { |project| project['id'] }).to contain_exactly(another_public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(another_public_project.id)
...@@ -1000,7 +1000,7 @@ describe API::Projects do ...@@ -1000,7 +1000,7 @@ describe API::Projects do
it 'returns both projects without a id_after filter' do it 'returns both projects without a id_after filter' do
get api("/users/#{user4.id}/projects", user) get api("/users/#{user4.id}/projects", 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.map { |project| project['id'] }).to contain_exactly(public_project.id, another_public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id, another_public_project.id)
...@@ -1013,7 +1013,7 @@ describe API::Projects do ...@@ -1013,7 +1013,7 @@ describe API::Projects do
it 'only returns projects with id_before filter given' do it 'only returns projects with id_before filter given' do
get api("/users/#{user4.id}/projects?id_before=#{another_public_project.id}", user) get api("/users/#{user4.id}/projects?id_before=#{another_public_project.id}", 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.map { |project| project['id'] }).to contain_exactly(public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
...@@ -1022,7 +1022,7 @@ describe API::Projects do ...@@ -1022,7 +1022,7 @@ describe API::Projects do
it 'returns both projects without a id_before filter' do it 'returns both projects without a id_before filter' do
get api("/users/#{user4.id}/projects", user) get api("/users/#{user4.id}/projects", 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.map { |project| project['id'] }).to contain_exactly(public_project.id, another_public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id, another_public_project.id)
...@@ -1035,7 +1035,7 @@ describe API::Projects do ...@@ -1035,7 +1035,7 @@ describe API::Projects do
it 'only returns projects with id matching the range' do it 'only returns projects with id matching the range' do
get api("/users/#{user4.id}/projects?id_after=#{more_projects.first.id}&id_before=#{more_projects.last.id}", user) get api("/users/#{user4.id}/projects?id_after=#{more_projects.first.id}&id_before=#{more_projects.last.id}", 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.map { |project| project['id'] }).to contain_exactly(*more_projects[1..-2].map(&:id)) expect(json_response.map { |project| project['id'] }).to contain_exactly(*more_projects[1..-2].map(&:id))
...@@ -1045,7 +1045,7 @@ describe API::Projects do ...@@ -1045,7 +1045,7 @@ describe API::Projects do
it 'returns projects filtered by username' do it 'returns projects filtered by username' do
get api("/users/#{user4.username}/projects/", user) get api("/users/#{user4.username}/projects/", 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.map { |project| project['id'] }).to contain_exactly(public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
...@@ -1059,7 +1059,7 @@ describe API::Projects do ...@@ -1059,7 +1059,7 @@ describe API::Projects do
get api("/users/#{user4.id}/projects/", user2), params: { min_access_level: 30 } get api("/users/#{user4.id}/projects/", user2), params: { min_access_level: 30 }
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.map { |project| project['id'] }).to contain_exactly(private_project1.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(private_project1.id)
...@@ -1071,7 +1071,7 @@ describe API::Projects do ...@@ -1071,7 +1071,7 @@ describe API::Projects do
it 'filters case-insensitively by programming language' do it 'filters case-insensitively by programming language' do
get api('/projects', user), params: { with_programming_language: 'ruby' } get api('/projects', user), params: { with_programming_language: 'ruby' }
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.map { |p| p['id'] }).to contain_exactly(project.id) expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id)
...@@ -1087,14 +1087,14 @@ describe API::Projects do ...@@ -1087,14 +1087,14 @@ describe API::Projects do
it 'returns error when user not found' do it 'returns error when user not found' do
get api('/users/9999/starred_projects/') get api('/users/9999/starred_projects/')
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found') expect(json_response['message']).to eq('404 User Not Found')
end end
it 'returns projects filtered by user' do it 'returns projects filtered by user' do
get api("/users/#{user3.id}/starred_projects/", user) get api("/users/#{user3.id}/starred_projects/", 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.map { |project| project['id'] }).to contain_exactly(project.id, project2.id, project3.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, project2.id, project3.id)
...@@ -1104,7 +1104,7 @@ describe API::Projects do ...@@ -1104,7 +1104,7 @@ describe API::Projects do
describe 'POST /projects/user/:id' do describe 'POST /projects/user/:id' do
it 'creates new project without path but with name and return 201' do it 'creates new project without path but with name and return 201' do
expect { post api("/projects/user/#{user.id}", admin), params: { name: 'Foo Project' } }.to change { Project.count }.by(1) expect { post api("/projects/user/#{user.id}", admin), params: { name: 'Foo Project' } }.to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project = Project.find(json_response['id']) project = Project.find(json_response['id'])
...@@ -1115,7 +1115,7 @@ describe API::Projects do ...@@ -1115,7 +1115,7 @@ describe API::Projects do
it 'creates new project with name and path and returns 201' do it 'creates new project with name and path and returns 201' do
expect { post api("/projects/user/#{user.id}", admin), params: { path: 'path-project-Foo', name: 'Foo Project' } } expect { post api("/projects/user/#{user.id}", admin), params: { path: 'path-project-Foo', name: 'Foo Project' } }
.to change { Project.count }.by(1) .to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project = Project.find(json_response['id']) project = Project.find(json_response['id'])
...@@ -1127,7 +1127,7 @@ describe API::Projects do ...@@ -1127,7 +1127,7 @@ describe API::Projects do
expect { post api("/projects/user/#{user.id}", admin) } expect { post api("/projects/user/#{user.id}", admin) }
.not_to change { Project.count } .not_to change { Project.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('name is missing') expect(json_response['error']).to eq('name is missing')
end end
...@@ -1142,7 +1142,7 @@ describe API::Projects do ...@@ -1142,7 +1142,7 @@ describe API::Projects do
post api("/projects/user/#{user.id}", admin), params: project post api("/projects/user/#{user.id}", admin), params: project
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
project.each_pair do |k, v| project.each_pair do |k, v|
next if %i[has_external_issue_tracker path storage_version].include?(k) next if %i[has_external_issue_tracker path storage_version].include?(k)
...@@ -1156,7 +1156,7 @@ describe API::Projects do ...@@ -1156,7 +1156,7 @@ describe API::Projects do
post api("/projects/user/#{user.id}", admin), params: project post api("/projects/user/#{user.id}", admin), params: project
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['visibility']).to eq('public') expect(json_response['visibility']).to eq('public')
end end
...@@ -1165,7 +1165,7 @@ describe API::Projects do ...@@ -1165,7 +1165,7 @@ describe API::Projects do
post api("/projects/user/#{user.id}", admin), params: project post api("/projects/user/#{user.id}", admin), params: project
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['visibility']).to eq('internal') expect(json_response['visibility']).to eq('internal')
end end
...@@ -1246,7 +1246,7 @@ describe API::Projects do ...@@ -1246,7 +1246,7 @@ describe API::Projects do
it "uploads the file and returns its info" do it "uploads the file and returns its info" do
post api("/projects/#{project.id}/uploads", user), params: { file: fixture_file_upload("spec/fixtures/dk.png", "image/png") } post api("/projects/#{project.id}/uploads", user), params: { file: fixture_file_upload("spec/fixtures/dk.png", "image/png") }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['alt']).to eq("dk") expect(json_response['alt']).to eq("dk")
expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to start_with("/uploads/")
expect(json_response['url']).to end_with("/dk.png") expect(json_response['url']).to end_with("/dk.png")
...@@ -1260,7 +1260,7 @@ describe API::Projects do ...@@ -1260,7 +1260,7 @@ describe API::Projects do
get api("/projects/#{private_project.id}") get api("/projects/#{private_project.id}")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns public projects' do it 'returns public projects' do
...@@ -1268,7 +1268,7 @@ describe API::Projects do ...@@ -1268,7 +1268,7 @@ describe API::Projects do
get api("/projects/#{public_project.id}") get api("/projects/#{public_project.id}")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(public_project.id) expect(json_response['id']).to eq(public_project.id)
expect(json_response['description']).to eq(public_project.description) expect(json_response['description']).to eq(public_project.description)
expect(json_response['default_branch']).to eq(public_project.default_branch) expect(json_response['default_branch']).to eq(public_project.default_branch)
...@@ -1283,7 +1283,7 @@ describe API::Projects do ...@@ -1283,7 +1283,7 @@ describe API::Projects do
get api("/projects/#{fork.id}") get api("/projects/#{fork.id}")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['forked_from_project']).to be_nil expect(json_response['forked_from_project']).to be_nil
end end
end end
...@@ -1295,7 +1295,7 @@ describe API::Projects do ...@@ -1295,7 +1295,7 @@ describe API::Projects do
it 'hides protected attributes of private repositories if user is not a member' do it 'hides protected attributes of private repositories if user is not a member' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
protected_attributes.each do |attribute| protected_attributes.each do |attribute|
expect(json_response.keys).not_to include(attribute) expect(json_response.keys).not_to include(attribute)
end end
...@@ -1306,7 +1306,7 @@ describe API::Projects do ...@@ -1306,7 +1306,7 @@ describe API::Projects do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
protected_attributes.each do |attribute| protected_attributes.each do |attribute|
expect(json_response.keys).to include(attribute) expect(json_response.keys).to include(attribute)
end end
...@@ -1323,7 +1323,7 @@ describe API::Projects do ...@@ -1323,7 +1323,7 @@ describe API::Projects do
get api("/projects/#{project.id}", admin) get api("/projects/#{project.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(project.id) expect(json_response['id']).to eq(project.id)
expect(json_response['description']).to eq(project.description) expect(json_response['description']).to eq(project.description)
expect(json_response['default_branch']).to eq(project.default_branch) expect(json_response['default_branch']).to eq(project.default_branch)
...@@ -1374,7 +1374,7 @@ describe API::Projects do ...@@ -1374,7 +1374,7 @@ describe API::Projects do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(project.id) expect(json_response['id']).to eq(project.id)
expect(json_response['description']).to eq(project.description) expect(json_response['description']).to eq(project.description)
expect(json_response['default_branch']).to eq(project.default_branch) expect(json_response['default_branch']).to eq(project.default_branch)
...@@ -1448,20 +1448,20 @@ describe API::Projects do ...@@ -1448,20 +1448,20 @@ describe API::Projects do
it 'returns a project by path name' do it 'returns a project by path name' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(project.name) expect(json_response['name']).to eq(project.name)
end end
it 'returns a 404 error if not found' do it 'returns a 404 error if not found' do
get api('/projects/42', user) get api('/projects/42', 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 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
it 'returns a 404 error if user is not a member' do it 'returns a 404 error if user is not a member' do
other_user = create(:user) other_user = create(:user)
get api("/projects/#{project.id}", other_user) get api("/projects/#{project.id}", other_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'handles users with dots' do it 'handles users with dots' do
...@@ -1469,14 +1469,14 @@ describe API::Projects do ...@@ -1469,14 +1469,14 @@ describe API::Projects do
project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace)
get api("/projects/#{CGI.escape(project.full_path)}", dot_user) get api("/projects/#{CGI.escape(project.full_path)}", dot_user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(project.name) expect(json_response['name']).to eq(project.name)
end end
it 'exposes namespace fields' do it 'exposes namespace fields' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['namespace']).to eq({ expect(json_response['namespace']).to eq({
'id' => user.namespace.id, 'id' => user.namespace.id,
'name' => user.namespace.name, 'name' => user.namespace.name,
...@@ -1492,14 +1492,14 @@ describe API::Projects do ...@@ -1492,14 +1492,14 @@ describe API::Projects do
it "does not include license fields by default" do it "does not include license fields by default" do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include('license', 'license_url') expect(json_response).not_to include('license', 'license_url')
end end
it 'includes license fields when requested' do it 'includes license fields when requested' do
get api("/projects/#{project.id}", user), params: { license: true } get api("/projects/#{project.id}", user), params: { license: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['license']).to eq({ expect(json_response['license']).to eq({
'key' => project.repository.license.key, 'key' => project.repository.license.key,
'name' => project.repository.license.name, 'name' => project.repository.license.name,
...@@ -1512,14 +1512,14 @@ describe API::Projects do ...@@ -1512,14 +1512,14 @@ describe API::Projects do
it "does not include statistics by default" do it "does not include statistics by default" do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include 'statistics' expect(json_response).not_to include 'statistics'
end end
it "includes statistics if requested" do it "includes statistics if requested" do
get api("/projects/#{project.id}", user), params: { statistics: true } get api("/projects/#{project.id}", user), params: { statistics: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include 'statistics' expect(json_response).to include 'statistics'
end end
...@@ -1529,7 +1529,7 @@ describe API::Projects do ...@@ -1529,7 +1529,7 @@ describe API::Projects do
it "does not include statistics if user is not a member" do it "does not include statistics if user is not a member" do
get api("/projects/#{project.id}", user), params: { statistics: true } get api("/projects/#{project.id}", user), params: { statistics: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include 'statistics' expect(json_response).not_to include 'statistics'
end end
...@@ -1538,7 +1538,7 @@ describe API::Projects do ...@@ -1538,7 +1538,7 @@ describe API::Projects do
get api("/projects/#{project.id}", user), params: { statistics: true } get api("/projects/#{project.id}", user), params: { statistics: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include 'statistics' expect(json_response).to include 'statistics'
end end
...@@ -1548,7 +1548,7 @@ describe API::Projects do ...@@ -1548,7 +1548,7 @@ describe API::Projects do
get api("/projects/#{project.id}", user), params: { statistics: true } get api("/projects/#{project.id}", user), params: { statistics: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include 'statistics' expect(json_response).to include 'statistics'
end end
end end
...@@ -1556,14 +1556,14 @@ describe API::Projects do ...@@ -1556,14 +1556,14 @@ describe API::Projects do
it "includes import_error if user can admin project" do it "includes import_error if user can admin project" do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include("import_error") expect(json_response).to include("import_error")
end end
it "does not include import_error if user cannot admin project" do it "does not include import_error if user cannot admin project" do
get api("/projects/#{project.id}", user3) get api("/projects/#{project.id}", user3)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include("import_error") expect(json_response).not_to include("import_error")
end end
...@@ -1572,7 +1572,7 @@ describe API::Projects do ...@@ -1572,7 +1572,7 @@ describe API::Projects do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", 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 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
...@@ -1614,7 +1614,7 @@ describe API::Projects do ...@@ -1614,7 +1614,7 @@ describe API::Projects do
get api("/projects/#{fork.id}", user) get api("/projects/#{fork.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['forked_from_project']).to include('id' => project.id) expect(json_response['forked_from_project']).to include('id' => project.id)
end end
...@@ -1625,7 +1625,7 @@ describe API::Projects do ...@@ -1625,7 +1625,7 @@ describe API::Projects do
get api("/projects/#{fork.id}", fork_user) get api("/projects/#{fork.id}", fork_user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['forked_from_project']).to be_nil expect(json_response['forked_from_project']).to be_nil
end end
end end
...@@ -1639,7 +1639,7 @@ describe API::Projects do ...@@ -1639,7 +1639,7 @@ describe API::Projects do
it 'contains permission information' do it 'contains permission information' do
get api("/projects", user) get api("/projects", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.first['permissions']['project_access']['access_level']) expect(json_response.first['permissions']['project_access']['access_level'])
.to eq(Gitlab::Access::MAINTAINER) .to eq(Gitlab::Access::MAINTAINER)
expect(json_response.first['permissions']['group_access']).to be_nil expect(json_response.first['permissions']['group_access']).to be_nil
...@@ -1651,7 +1651,7 @@ describe API::Projects do ...@@ -1651,7 +1651,7 @@ describe API::Projects do
project.add_maintainer(user) project.add_maintainer(user)
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['permissions']['project_access']['access_level']) expect(json_response['permissions']['project_access']['access_level'])
.to eq(Gitlab::Access::MAINTAINER) .to eq(Gitlab::Access::MAINTAINER)
expect(json_response['permissions']['group_access']).to be_nil expect(json_response['permissions']['group_access']).to be_nil
...@@ -1668,7 +1668,7 @@ describe API::Projects do ...@@ -1668,7 +1668,7 @@ describe API::Projects do
it 'sets the owner and return 200' do it 'sets the owner and return 200' do
get api("/projects/#{project2.id}", user) get api("/projects/#{project2.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['project_access']).to be_nil
expect(json_response['permissions']['group_access']['access_level']) expect(json_response['permissions']['group_access']['access_level'])
.to eq(Gitlab::Access::OWNER) .to eq(Gitlab::Access::OWNER)
...@@ -1687,7 +1687,7 @@ describe API::Projects do ...@@ -1687,7 +1687,7 @@ describe API::Projects do
it 'sets group access and return 200' do it 'sets group access and return 200' do
get api("/projects/#{project2.id}", user) get api("/projects/#{project2.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['project_access']).to be_nil
expect(json_response['permissions']['group_access']['access_level']) expect(json_response['permissions']['group_access']['access_level'])
.to eq(Gitlab::Access::OWNER) .to eq(Gitlab::Access::OWNER)
...@@ -1701,7 +1701,7 @@ describe API::Projects do ...@@ -1701,7 +1701,7 @@ describe API::Projects do
it 'sets the maximum group access and return 200' do it 'sets the maximum group access and return 200' do
get api("/projects/#{project2.id}", user) get api("/projects/#{project2.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['project_access']).to be_nil
expect(json_response['permissions']['group_access']['access_level']) expect(json_response['permissions']['group_access']['access_level'])
.to eq(Gitlab::Access::OWNER) .to eq(Gitlab::Access::OWNER)
...@@ -1718,7 +1718,7 @@ describe API::Projects do ...@@ -1718,7 +1718,7 @@ describe API::Projects do
it 'returns group web_url and avatar_url' do it 'returns group web_url and avatar_url' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
group_data = json_response['namespace'] group_data = json_response['namespace']
expect(group_data['web_url']).to eq(group.web_url) expect(group_data['web_url']).to eq(group.web_url)
...@@ -1733,7 +1733,7 @@ describe API::Projects do ...@@ -1733,7 +1733,7 @@ describe API::Projects do
it 'returns user web_url and avatar_url' do it 'returns user web_url and avatar_url' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
user_data = json_response['namespace'] user_data = json_response['namespace']
expect(user_data['web_url']).to eq("http://localhost/#{user.username}") expect(user_data['web_url']).to eq("http://localhost/#{user.username}")
...@@ -1758,7 +1758,7 @@ describe API::Projects do ...@@ -1758,7 +1758,7 @@ describe API::Projects do
user = project.namespace.owner user = project.namespace.owner
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)
...@@ -1787,7 +1787,7 @@ describe API::Projects do ...@@ -1787,7 +1787,7 @@ describe API::Projects do
it 'returns a 404 error if not found' do it 'returns a 404 error if not found' do
get api('/projects/42/users', user) get api('/projects/42/users', 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 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
...@@ -1796,7 +1796,7 @@ describe API::Projects do ...@@ -1796,7 +1796,7 @@ describe API::Projects do
get api("/projects/#{project.id}/users", other_user) get api("/projects/#{project.id}/users", other_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'filters out users listed in skip_users' do it 'filters out users listed in skip_users' do
...@@ -1805,7 +1805,7 @@ describe API::Projects do ...@@ -1805,7 +1805,7 @@ describe API::Projects do
get api("/projects/#{project.id}/users?skip_users=#{user.id}", user) get api("/projects/#{project.id}/users?skip_users=#{user.id}", user)
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)
expect(json_response[0]['id']).to eq(other_user.id) expect(json_response[0]['id']).to eq(other_user.id)
end end
...@@ -1826,7 +1826,7 @@ describe API::Projects do ...@@ -1826,7 +1826,7 @@ describe API::Projects do
it 'denies project to be forked from an existing project' do it 'denies project to be forked from an existing project' do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -1845,7 +1845,7 @@ describe API::Projects do ...@@ -1845,7 +1845,7 @@ describe API::Projects do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
project_fork_target.reload project_fork_target.reload
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id)
expect(project_fork_target.fork_network_member).to be_present expect(project_fork_target.fork_network_member).to be_present
expect(project_fork_target).to be_forked expect(project_fork_target).to be_forked
...@@ -1854,7 +1854,7 @@ describe API::Projects do ...@@ -1854,7 +1854,7 @@ describe API::Projects do
it 'denies project to be forked from a private project' do it 'denies project to be forked from a private project' do
post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", user) post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -1864,13 +1864,13 @@ describe API::Projects do ...@@ -1864,13 +1864,13 @@ describe API::Projects do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'allows project to be forked from a private project' do it 'allows project to be forked from a private project' do
post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", admin) post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", admin)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'refreshes the forks count cachce' do it 'refreshes the forks count cachce' do
...@@ -1881,7 +1881,7 @@ describe API::Projects do ...@@ -1881,7 +1881,7 @@ describe API::Projects do
it 'fails if forked_from project which does not exist' do it 'fails if forked_from project which does not exist' do
post api("/projects/#{project_fork_target.id}/fork/0", admin) post api("/projects/#{project_fork_target.id}/fork/0", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'fails with 409 if already forked' do it 'fails with 409 if already forked' do
...@@ -1892,7 +1892,7 @@ describe API::Projects do ...@@ -1892,7 +1892,7 @@ describe API::Projects do
post api("/projects/#{project_fork_target.id}/fork/#{other_project_fork_source.id}", admin) post api("/projects/#{project_fork_target.id}/fork/#{other_project_fork_source.id}", admin)
project_fork_target.reload project_fork_target.reload
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id)
expect(project_fork_target).to be_forked expect(project_fork_target).to be_forked
end end
...@@ -1902,7 +1902,7 @@ describe API::Projects do ...@@ -1902,7 +1902,7 @@ describe API::Projects do
describe 'DELETE /projects/:id/fork' do describe 'DELETE /projects/:id/fork' do
it "is not visible to users outside group" do it "is not visible to users outside group" do
delete api("/projects/#{project_fork_target.id}/fork", user) delete api("/projects/#{project_fork_target.id}/fork", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'when users belong to project group' do context 'when users belong to project group' do
...@@ -1924,7 +1924,7 @@ describe API::Projects do ...@@ -1924,7 +1924,7 @@ describe API::Projects do
it 'makes forked project unforked' do it 'makes forked project unforked' do
delete api("/projects/#{project_fork_target.id}/fork", admin) delete api("/projects/#{project_fork_target.id}/fork", admin)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
project_fork_target.reload project_fork_target.reload
expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target.forked_from_project).to be_nil
expect(project_fork_target).not_to be_forked expect(project_fork_target).not_to be_forked
...@@ -1937,13 +1937,13 @@ describe API::Projects do ...@@ -1937,13 +1937,13 @@ describe API::Projects do
it 'is forbidden to non-owner users' do it 'is forbidden to non-owner users' do
delete api("/projects/#{project_fork_target.id}/fork", user2) delete api("/projects/#{project_fork_target.id}/fork", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'is idempotent if not forked' do it 'is idempotent if not forked' do
expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target.forked_from_project).to be_nil
delete api("/projects/#{project_fork_target.id}/fork", admin) delete api("/projects/#{project_fork_target.id}/fork", admin)
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
expect(project_fork_target.reload.forked_from_project).to be_nil expect(project_fork_target.reload.forked_from_project).to be_nil
end end
end end
...@@ -1973,7 +1973,7 @@ describe API::Projects do ...@@ -1973,7 +1973,7 @@ describe API::Projects do
it 'returns the forks' do it 'returns the forks' do
get api("/projects/#{project_fork_source.id}/forks", member) get api("/projects/#{project_fork_source.id}/forks", member)
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.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response[0]['name']).to eq(private_fork.name) expect(json_response[0]['name']).to eq(private_fork.name)
...@@ -1984,7 +1984,7 @@ describe API::Projects do ...@@ -1984,7 +1984,7 @@ describe API::Projects do
it 'returns an empty array' do it 'returns an empty array' do
get api("/projects/#{project_fork_source.id}/forks", non_member) get api("/projects/#{project_fork_source.id}/forks", non_member)
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.length).to eq(0) expect(json_response.length).to eq(0)
end end
...@@ -1995,7 +1995,7 @@ describe API::Projects do ...@@ -1995,7 +1995,7 @@ describe API::Projects do
it 'returns an empty array' do it 'returns an empty array' do
get api("/projects/#{project_fork_source.id}/forks") get api("/projects/#{project_fork_source.id}/forks")
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.length).to eq(0) expect(json_response.length).to eq(0)
end end
...@@ -2017,7 +2017,7 @@ describe API::Projects do ...@@ -2017,7 +2017,7 @@ describe API::Projects do
post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at } post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at }
end.to change { ProjectGroupLink.count }.by(1) end.to change { ProjectGroupLink.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['group_id']).to eq(group.id) expect(json_response['group_id']).to eq(group.id)
expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER)
expect(json_response['expires_at']).to eq(expires_at.to_s) expect(json_response['expires_at']).to eq(expires_at.to_s)
...@@ -2025,18 +2025,18 @@ describe API::Projects do ...@@ -2025,18 +2025,18 @@ describe API::Projects do
it "returns a 400 error when group id is not given" do it "returns a 400 error when group id is not given" do
post api("/projects/#{project.id}/share", user), params: { group_access: Gitlab::Access::DEVELOPER } post api("/projects/#{project.id}/share", user), params: { group_access: Gitlab::Access::DEVELOPER }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 400 error when access level is not given" do it "returns a 400 error when access level is not given" do
post api("/projects/#{project.id}/share", user), params: { group_id: group.id } post api("/projects/#{project.id}/share", user), params: { group_id: group.id }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 400 error when sharing is disabled" do it "returns a 400 error when sharing is disabled" do
project.namespace.update(share_with_group_lock: true) project.namespace.update(share_with_group_lock: true)
post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER } post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns a 404 error when user cannot read group' do it 'returns a 404 error when user cannot read group' do
...@@ -2044,19 +2044,19 @@ describe API::Projects do ...@@ -2044,19 +2044,19 @@ describe API::Projects do
post api("/projects/#{project.id}/share", user), params: { group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER } post api("/projects/#{project.id}/share", user), params: { group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a 404 error when group does not exist' do it 'returns a 404 error when group does not exist' do
post api("/projects/#{project.id}/share", user), params: { group_id: 1234, group_access: Gitlab::Access::DEVELOPER } post api("/projects/#{project.id}/share", user), params: { group_id: 1234, group_access: Gitlab::Access::DEVELOPER }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns a 400 error when wrong params passed" do it "returns a 400 error when wrong params passed" do
post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: 1234 } post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: 1234 }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq 'group_access does not have a valid value' expect(json_response['error']).to eq 'group_access does not have a valid value'
end end
...@@ -2066,7 +2066,7 @@ describe API::Projects do ...@@ -2066,7 +2066,7 @@ describe API::Projects do
post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER } post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER }
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
end end
end end
...@@ -2081,7 +2081,7 @@ describe API::Projects do ...@@ -2081,7 +2081,7 @@ describe API::Projects do
it 'returns 204 when deleting a group share' do it 'returns 204 when deleting a group share' do
delete api("/projects/#{project.id}/share/#{group.id}", user) delete api("/projects/#{project.id}/share/#{group.id}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(project.project_group_links).to be_empty expect(project.project_group_links).to be_empty
end end
...@@ -2093,19 +2093,19 @@ describe API::Projects do ...@@ -2093,19 +2093,19 @@ describe API::Projects do
it 'returns a 400 when group id is not an integer' do it 'returns a 400 when group id is not an integer' do
delete api("/projects/#{project.id}/share/foo", user) delete api("/projects/#{project.id}/share/foo", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns a 404 error when group link does not exist' do it 'returns a 404 error when group link does not exist' do
delete api("/projects/#{project.id}/share/1234", user) delete api("/projects/#{project.id}/share/1234", 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 when project does not exist' do it 'returns a 404 error when project does not exist' do
delete api("/projects/123/share/1234", user) delete api("/projects/123/share/1234", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -2126,7 +2126,7 @@ describe API::Projects do ...@@ -2126,7 +2126,7 @@ describe API::Projects do
put api("/projects/#{project.id}", user), params: project_param put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to match('at least one parameter must be provided') expect(json_response['error']).to match('at least one parameter must be provided')
end end
...@@ -2136,7 +2136,7 @@ describe API::Projects do ...@@ -2136,7 +2136,7 @@ describe API::Projects do
put api("/projects/#{project.id}"), params: project_param put api("/projects/#{project.id}"), params: project_param
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -2146,7 +2146,7 @@ describe API::Projects do ...@@ -2146,7 +2146,7 @@ describe API::Projects do
put api("/projects/#{project.id}", user), params: project_param put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
...@@ -2158,7 +2158,7 @@ describe API::Projects do ...@@ -2158,7 +2158,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
...@@ -2171,7 +2171,7 @@ describe API::Projects do ...@@ -2171,7 +2171,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
...@@ -2185,7 +2185,7 @@ describe API::Projects do ...@@ -2185,7 +2185,7 @@ describe API::Projects do
put api("/projects/#{project.id}", user), params: project_param put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['name']).to eq(['has already been taken']) expect(json_response['message']['name']).to eq(['has already been taken'])
end end
...@@ -2194,7 +2194,7 @@ describe API::Projects do ...@@ -2194,7 +2194,7 @@ describe API::Projects do
put api("/projects/#{project.id}", user), params: project_param put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['request_access_enabled']).to eq(false) expect(json_response['request_access_enabled']).to eq(false)
end end
...@@ -2203,7 +2203,7 @@ describe API::Projects do ...@@ -2203,7 +2203,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
...@@ -2215,7 +2215,7 @@ describe API::Projects do ...@@ -2215,7 +2215,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
...@@ -2227,7 +2227,7 @@ describe API::Projects do ...@@ -2227,7 +2227,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['builds_access_level']).to eq('private') expect(json_response['builds_access_level']).to eq('private')
end end
...@@ -2247,7 +2247,7 @@ describe API::Projects do ...@@ -2247,7 +2247,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['emails_disabled']).to eq(true) expect(json_response['emails_disabled']).to eq(true)
end end
...@@ -2257,7 +2257,7 @@ describe API::Projects do ...@@ -2257,7 +2257,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['build_git_strategy']).to eq('clone') expect(json_response['build_git_strategy']).to eq('clone')
end end
...@@ -2267,7 +2267,7 @@ describe API::Projects do ...@@ -2267,7 +2267,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'updates merge_method' do it 'updates merge_method' do
...@@ -2275,7 +2275,7 @@ describe API::Projects do ...@@ -2275,7 +2275,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
...@@ -2287,7 +2287,7 @@ describe API::Projects do ...@@ -2287,7 +2287,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'updates avatar' do it 'updates avatar' do
...@@ -2298,7 +2298,7 @@ describe API::Projects do ...@@ -2298,7 +2298,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\ expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\
'-/system/project/avatar/'\ '-/system/project/avatar/'\
"#{project3.id}/banana_sample.gif") "#{project3.id}/banana_sample.gif")
...@@ -2309,7 +2309,7 @@ describe API::Projects do ...@@ -2309,7 +2309,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['auto_devops_deploy_strategy']).to eq('timed_incremental') expect(json_response['auto_devops_deploy_strategy']).to eq('timed_incremental')
end end
...@@ -2319,7 +2319,7 @@ describe API::Projects do ...@@ -2319,7 +2319,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user), params: project_param put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['auto_devops_enabled']).to eq(false) expect(json_response['auto_devops_enabled']).to eq(false)
end end
...@@ -2329,7 +2329,7 @@ describe API::Projects do ...@@ -2329,7 +2329,7 @@ describe API::Projects do
it 'updates path' do it 'updates path' do
project_param = { path: 'bar' } project_param = { path: 'bar' }
put api("/projects/#{project3.id}", user4), params: project_param put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
...@@ -2345,7 +2345,7 @@ describe API::Projects do ...@@ -2345,7 +2345,7 @@ describe API::Projects do
description: 'new description' } description: 'new description' }
put api("/projects/#{project3.id}", user4), params: project_param put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
project_param.each_pair do |k, v| project_param.each_pair do |k, v|
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
...@@ -2354,20 +2354,20 @@ describe API::Projects do ...@@ -2354,20 +2354,20 @@ describe API::Projects do
it 'does not update path to existing path' do it 'does not update path to existing path' do
project_param = { path: project.path } project_param = { path: project.path }
put api("/projects/#{project3.id}", user4), params: project_param put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['path']).to eq(['has already been taken']) expect(json_response['message']['path']).to eq(['has already been taken'])
end end
it 'does not update name' do it 'does not update name' do
project_param = { name: 'bar' } project_param = { name: 'bar' }
put api("/projects/#{project3.id}", user4), params: project_param put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'does not update visibility_level' do it 'does not update visibility_level' do
project_param = { visibility: 'public' } project_param = { visibility: 'public' }
put api("/projects/#{project3.id}", user4), params: project_param put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'updates container_expiration_policy' do it 'updates container_expiration_policy' do
...@@ -2380,7 +2380,7 @@ describe API::Projects do ...@@ -2380,7 +2380,7 @@ describe API::Projects do
put api("/projects/#{project3.id}", user4), params: project_param put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['container_expiration_policy']['cadence']).to eq('1month') expect(json_response['container_expiration_policy']['cadence']).to eq('1month')
expect(json_response['container_expiration_policy']['keep_n']).to eq(1) expect(json_response['container_expiration_policy']['keep_n']).to eq(1)
...@@ -2397,7 +2397,7 @@ describe API::Projects do ...@@ -2397,7 +2397,7 @@ describe API::Projects do
description: 'new description', description: 'new description',
request_access_enabled: true } request_access_enabled: true }
put api("/projects/#{project.id}", user3), params: project_param put api("/projects/#{project.id}", user3), params: project_param
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -2407,7 +2407,7 @@ describe API::Projects do ...@@ -2407,7 +2407,7 @@ describe API::Projects do
it 'archives the project' do it 'archives the project' do
post api("/projects/#{project.id}/archive", user) post api("/projects/#{project.id}/archive", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['archived']).to be_truthy expect(json_response['archived']).to be_truthy
end end
end end
...@@ -2420,7 +2420,7 @@ describe API::Projects do ...@@ -2420,7 +2420,7 @@ describe API::Projects do
it 'remains archived' do it 'remains archived' do
post api("/projects/#{project.id}/archive", user) post api("/projects/#{project.id}/archive", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['archived']).to be_truthy expect(json_response['archived']).to be_truthy
end end
end end
...@@ -2433,7 +2433,7 @@ describe API::Projects do ...@@ -2433,7 +2433,7 @@ describe API::Projects do
it 'rejects the action' do it 'rejects the action' do
post api("/projects/#{project.id}/archive", user3) post api("/projects/#{project.id}/archive", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -2443,7 +2443,7 @@ describe API::Projects do ...@@ -2443,7 +2443,7 @@ describe API::Projects do
it 'remains unarchived' do it 'remains unarchived' do
post api("/projects/#{project.id}/unarchive", user) post api("/projects/#{project.id}/unarchive", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['archived']).to be_falsey expect(json_response['archived']).to be_falsey
end end
end end
...@@ -2456,7 +2456,7 @@ describe API::Projects do ...@@ -2456,7 +2456,7 @@ describe API::Projects do
it 'unarchives the project' do it 'unarchives the project' do
post api("/projects/#{project.id}/unarchive", user) post api("/projects/#{project.id}/unarchive", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['archived']).to be_falsey expect(json_response['archived']).to be_falsey
end end
end end
...@@ -2469,7 +2469,7 @@ describe API::Projects do ...@@ -2469,7 +2469,7 @@ describe API::Projects do
it 'rejects the action' do it 'rejects the action' do
post api("/projects/#{project.id}/unarchive", user3) post api("/projects/#{project.id}/unarchive", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -2479,7 +2479,7 @@ describe API::Projects do ...@@ -2479,7 +2479,7 @@ describe API::Projects do
it 'stars the project' do it 'stars the project' do
expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['star_count']).to eq(1) expect(json_response['star_count']).to eq(1)
end end
end end
...@@ -2493,7 +2493,7 @@ describe API::Projects do ...@@ -2493,7 +2493,7 @@ describe API::Projects do
it 'does not modify the star count' do it 'does not modify the star count' do
expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count }
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
end end
end end
end end
...@@ -2508,7 +2508,7 @@ describe API::Projects do ...@@ -2508,7 +2508,7 @@ describe API::Projects do
it 'unstars the project' do it 'unstars the project' do
expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1) expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['star_count']).to eq(0) expect(json_response['star_count']).to eq(0)
end end
end end
...@@ -2517,7 +2517,7 @@ describe API::Projects do ...@@ -2517,7 +2517,7 @@ describe API::Projects do
it 'does not modify the star count' do it 'does not modify the star count' do
expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count } expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count }
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
end end
end end
end end
...@@ -2527,7 +2527,7 @@ describe API::Projects do ...@@ -2527,7 +2527,7 @@ describe API::Projects do
it 'returns an array of starrers' do it 'returns an array of starrers' do
get api("/projects/#{public_project.id}/starrers", current_user) get api("/projects/#{public_project.id}/starrers", current_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[0]['starred_since']).to be_present expect(json_response[0]['starred_since']).to be_present
...@@ -2642,7 +2642,7 @@ describe API::Projects do ...@@ -2642,7 +2642,7 @@ describe API::Projects do
it 'removes project' do it 'removes project' do
delete api("/projects/#{project.id}", user) delete api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(json_response['message']).to eql('202 Accepted') expect(json_response['message']).to eql('202 Accepted')
end end
...@@ -2655,17 +2655,17 @@ describe API::Projects do ...@@ -2655,17 +2655,17 @@ describe API::Projects do
user3 = create(:user) user3 = create(:user)
project.add_developer(user3) project.add_developer(user3)
delete api("/projects/#{project.id}", user3) delete api("/projects/#{project.id}", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'does not remove a non existing project' do it 'does not remove a non existing project' do
delete api('/projects/1328', user) delete api('/projects/1328', user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'does not remove a project not attached to user' do it 'does not remove a project not attached to user' do
delete api("/projects/#{project.id}", user2) delete api("/projects/#{project.id}", user2)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -2673,13 +2673,13 @@ describe API::Projects do ...@@ -2673,13 +2673,13 @@ describe API::Projects do
it 'removes any existing project' do it 'removes any existing project' do
delete api("/projects/#{project.id}", admin) delete api("/projects/#{project.id}", admin)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(json_response['message']).to eql('202 Accepted') expect(json_response['message']).to eql('202 Accepted')
end end
it 'does not remove a non existing project' do it 'does not remove a non existing project' do
delete api('/projects/1328', admin) delete api('/projects/1328', admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -2906,7 +2906,7 @@ describe API::Projects do ...@@ -2906,7 +2906,7 @@ describe API::Projects do
post api("/projects/#{project.id}/housekeeping", user) post api("/projects/#{project.id}/housekeeping", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
context 'when housekeeping lease is taken' do context 'when housekeeping lease is taken' do
...@@ -2915,7 +2915,7 @@ describe API::Projects do ...@@ -2915,7 +2915,7 @@ describe API::Projects do
post api("/projects/#{project.id}/housekeeping", user) post api("/projects/#{project.id}/housekeeping", user)
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to match(/Somebody already triggered housekeeping for this project/) expect(json_response['message']).to match(/Somebody already triggered housekeeping for this project/)
end end
end end
...@@ -2929,7 +2929,7 @@ describe API::Projects do ...@@ -2929,7 +2929,7 @@ describe API::Projects do
it 'returns forbidden error' do it 'returns forbidden error' do
post api("/projects/#{project.id}/housekeeping", user3) post api("/projects/#{project.id}/housekeeping", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -2937,7 +2937,7 @@ describe API::Projects do ...@@ -2937,7 +2937,7 @@ describe API::Projects do
it 'returns authentication error' do it 'returns authentication error' do
post api("/projects/#{project.id}/housekeeping") post api("/projects/#{project.id}/housekeeping")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -2951,25 +2951,25 @@ describe API::Projects do ...@@ -2951,25 +2951,25 @@ describe API::Projects do
put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'fails when transferring to a non owned namespace' do it 'fails when transferring to a non owned namespace' do
put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'fails when transferring to an unknown namespace' do it 'fails when transferring to an unknown namespace' do
put api("/projects/#{project.id}/transfer", user), params: { namespace: 'unknown' } put api("/projects/#{project.id}/transfer", user), params: { namespace: 'unknown' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'fails on missing namespace' do it 'fails on missing namespace' do
put api("/projects/#{project.id}/transfer", user) put api("/projects/#{project.id}/transfer", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -2984,7 +2984,7 @@ describe API::Projects do ...@@ -2984,7 +2984,7 @@ describe API::Projects do
it 'fails transferring the project to the target namespace' do it 'fails transferring the project to the target namespace' do
put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
......
...@@ -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