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:
- 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-o]*.rb'
- 'ee/spec/requests/api/[a-o]*.rb'
- 'spec/requests/api/[a-p]*.rb'
- 'ee/spec/requests/api/[a-p]*.rb'
Style/MultilineWhenThen:
Enabled: false
......
......@@ -23,13 +23,13 @@ describe API::PackageFiles do
it 'returns 200' do
get api(url)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns 404 if package does not exist' do
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
......@@ -39,7 +39,7 @@ describe API::PackageFiles do
it 'returns 404 for non authenticated user' do
get api(url)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 for a user without access to the project' do
......@@ -47,13 +47,13 @@ describe API::PackageFiles do
get api(url, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 200 and valid response schema' do
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')
end
end
......@@ -94,7 +94,7 @@ describe API::PackageFiles do
it 'returns 403' do
get api(url, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......
......@@ -13,7 +13,7 @@ describe API::ProjectAliases, api: true do
end
it 'returns 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -25,7 +25,7 @@ describe API::ProjectAliases, api: true do
end
it 'returns 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -37,7 +37,7 @@ describe API::ProjectAliases, api: true do
end
it 'returns 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -49,7 +49,7 @@ describe API::ProjectAliases, api: true do
end
it 'returns 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -60,13 +60,13 @@ describe API::ProjectAliases, api: true do
let(:user) { nil }
it 'returns 401' do
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
context 'regular user' do
it 'returns 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -88,7 +88,7 @@ describe API::ProjectAliases, api: true do
let!(:project_alias_2) { create(:project_alias) }
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 include_pagination_headers
end
......@@ -110,7 +110,7 @@ describe API::ProjectAliases, api: true do
context 'existing 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')
end
end
......@@ -119,7 +119,7 @@ describe API::ProjectAliases, api: true do
let(:alias_name) { 'some-project' }
it 'returns 404' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -141,7 +141,7 @@ describe API::ProjectAliases, api: true do
context 'existing project alias' do
it 'returns 400' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -149,7 +149,7 @@ describe API::ProjectAliases, api: true do
let(:alias_name) { 'some-project' }
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')
end
end
......@@ -171,7 +171,7 @@ describe API::ProjectAliases, api: true do
context 'existing project alias' do
it 'returns 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
......@@ -179,7 +179,7 @@ describe API::ProjectAliases, api: true do
let(:alias_name) { 'some-project' }
it 'returns 404' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -29,7 +29,7 @@ describe API::ProjectApprovalRules do
it 'matches the response schema' do
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')
json = json_response
......
......@@ -29,7 +29,7 @@ describe API::ProjectApprovalSettings do
it 'matches the response schema' do
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')
json = json_response
......
......@@ -21,7 +21,7 @@ describe API::ProjectApprovals do
end
it 'returns 200 status' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'matches the response schema' do
......@@ -46,7 +46,7 @@ describe API::ProjectApprovals do
it 'returns 400 status' do
post api(url, current_user)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -54,7 +54,7 @@ describe API::ProjectApprovals do
it 'returns 201 status' do
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
it 'matches the response schema' do
......@@ -169,7 +169,7 @@ describe API::ProjectApprovals do
it 'returns 403' do
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
......@@ -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' }
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['approver_groups']).to be_empty
end
......@@ -198,7 +198,7 @@ describe API::ProjectApprovals do
put api(url, current_user), params: { approver_ids: '', approver_group_ids: '' }
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['approver_groups']).to be_empty
end
......@@ -215,7 +215,7 @@ describe API::ProjectApprovals do
expect(project.approvers.first.user_id).to eq(approver.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['approver_groups'][0]['group']['name']).to eq(group.name)
end
......@@ -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' }
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
......
......@@ -90,7 +90,7 @@ describe API::ProjectClusters do
end
it 'responds with 201' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'allows multiple clusters to be associated to project' do
......
......@@ -17,7 +17,7 @@ describe API::ProjectMilestones do
it 'matches V4 EE-specific response schema for a list of issues' do
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')
end
......
......@@ -127,7 +127,7 @@ describe API::ProjectPackages do
it 'returns 403' do
get api(url, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -160,20 +160,20 @@ describe API::ProjectPackages do
it 'returns 200 and the package information' do
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')
end
it 'returns 404 when the package does not exist' do
get api(no_package_url, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 for the package from a different project' do
get api(wrong_package_url, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it_behaves_like 'no destroy url'
......@@ -185,13 +185,13 @@ describe API::ProjectPackages do
it 'returns 404 for non authenticated user' do
get api(package_url)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 for a user without access to the project' do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'user is a developer' do
......@@ -202,7 +202,7 @@ describe API::ProjectPackages do
it 'returns 200 and the package information' do
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')
end
......@@ -225,7 +225,7 @@ describe API::ProjectPackages do
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')
end
end
......@@ -240,7 +240,7 @@ describe API::ProjectPackages do
it 'returns 403' do
subject
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -255,13 +255,13 @@ describe API::ProjectPackages do
it 'returns 403 for non authenticated user' do
delete api(package_url)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'returns 403 for a user without access to the project' do
delete api(package_url, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -271,13 +271,13 @@ describe API::ProjectPackages do
it 'returns 404 for non authenticated user' do
delete api(package_url)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 for a user without access to the project' do
delete api(package_url, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 when the package does not exist' do
......@@ -285,7 +285,7 @@ describe API::ProjectPackages do
delete api(no_package_url, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 for the package from a different project' do
......@@ -293,7 +293,7 @@ describe API::ProjectPackages do
delete api(wrong_package_url, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 403 for a user without enough permissions' do
......@@ -301,7 +301,7 @@ describe API::ProjectPackages do
delete api(package_url, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'returns 204' do
......@@ -309,7 +309,7 @@ describe API::ProjectPackages do
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
......@@ -322,7 +322,7 @@ describe API::ProjectPackages do
it 'returns 403' do
delete api(package_url, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......
......@@ -35,7 +35,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
end
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['project_id']).to eq(project.id)
end
......@@ -66,7 +66,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false }
it 'succeeds' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'does not return the reject_unsigned_commits information' do
......@@ -78,7 +78,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:push_rules_enabled) { false }
it 'is forbidden' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -87,7 +87,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "does not have access to project push rule" do
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
......@@ -119,7 +119,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ccc_enabled) { false }
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
......@@ -127,12 +127,12 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false }
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
it "is accepted" do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it "indicates that it belongs to the correct project" do
......@@ -147,7 +147,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ccc_enabled) { false }
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
context "without the :commit_committer_check parameter" do
......@@ -172,7 +172,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false }
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
context "without the :reject_unsigned_commits parameter" do
......@@ -198,7 +198,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
post api("/projects/#{project.id}/push_rule", user),
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['commit_message_regex']).to eq('JIRA\-\d+')
expect(json_response['max_file_size']).to eq(0)
......@@ -207,14 +207,14 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it 'returns 400 if no parameter is given' do
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
context "user with developer_access" do
it "does not add push rule to project" do
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
......@@ -228,7 +228,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "does not add push rule to project" do
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
......@@ -246,7 +246,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
end
it "is successful" do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'includes the expected settings' do
......@@ -259,7 +259,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:new_settings) { { commit_committer_check: true } }
it "is successful" do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it "sets the commit_committer_check" do
......@@ -270,7 +270,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ccc_enabled) { false }
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
......@@ -279,7 +279,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:new_settings) { { reject_unsigned_commits: true } }
it "is successful" do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it "sets the reject_unsigned_commits" do
......@@ -290,7 +290,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:ruc_enabled) { false }
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
......@@ -299,7 +299,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
let(:new_settings) { {} }
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
......@@ -309,13 +309,13 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
put api("/projects/#{project.id}/push_rule", user),
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
it "does not update push rule for unauthorized user" do
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
......@@ -328,7 +328,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "deletes push rule from project" do
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
......@@ -336,7 +336,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "returns a 403 error" do
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
......@@ -346,7 +346,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "deletes push rule from project" do
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['message']).to eq('404 Push Rule Not Found')
end
......@@ -354,7 +354,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it "returns a 403 error if not authorized" do
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
......
......@@ -21,7 +21,7 @@ describe API::ProjectSnapshots do
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
......@@ -17,7 +17,7 @@ describe API::Projects do
get api('/projects', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'filters by verification flags' do
......@@ -29,7 +29,7 @@ describe API::Projects do
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(json_response).to be_an Array
expect(json_response.length).to eq(1)
......@@ -42,7 +42,7 @@ describe API::Projects do
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(json_response).to be_an Array
expect(json_response.length).to eq(1)
......@@ -71,7 +71,7 @@ describe API::Projects do
it 'includes the label in the response' do
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')
end
end
......@@ -84,7 +84,7 @@ describe API::Projects do
it 'returns a 404' do
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
......@@ -96,7 +96,7 @@ describe API::Projects do
it 'does not include the label in the response' do
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
end
end
......@@ -118,7 +118,7 @@ describe API::Projects do
it 'returns 200' do
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -130,13 +130,13 @@ describe API::Projects do
it 'returns 404 for request from ip not in the range' do
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 200 for request from ip in the range' do
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
......@@ -205,7 +205,7 @@ describe API::Projects do
it 'returns repository_storage attribute' do
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)
end
end
......@@ -239,7 +239,7 @@ describe API::Projects do
expect { api_call }.to change { Project.count }.by(1)
end
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
project = Project.find(json_response['id'])
expect(project.name).to eq(new_project_name)
......@@ -251,7 +251,7 @@ describe API::Projects do
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"])
end
......@@ -262,7 +262,7 @@ describe API::Projects do
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"])
end
end
......@@ -397,7 +397,7 @@ describe API::Projects do
it 'creates new project with pull mirroring set up' do
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(
mirror: true,
import_url: import_url,
......@@ -412,7 +412,7 @@ describe API::Projects do
expect { post api('/projects', user), params: mirror_params }
.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(
mirror: false,
import_url: import_url,
......@@ -429,7 +429,7 @@ describe API::Projects do
it 'ignores the mirroring options' do
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
end
......@@ -438,7 +438,7 @@ describe API::Projects do
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(
mirror: true,
import_url: import_url,
......@@ -462,7 +462,7 @@ describe API::Projects do
it 'updates the classification label' do
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')
end
end
......@@ -480,7 +480,7 @@ describe API::Projects do
it 'returns 200' do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'enables the service_desk' do
......@@ -500,7 +500,7 @@ describe API::Projects do
end
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(new_project.reload.repository.storage).to eq('default')
end
......@@ -514,7 +514,7 @@ describe API::Projects do
it 'returns 500 when repository storage is unknown' do
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')
end
......@@ -527,7 +527,7 @@ describe API::Projects do
end
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
......@@ -553,7 +553,7 @@ describe API::Projects do
it 'does not update mirror related attributes' do
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
end
......@@ -566,7 +566,7 @@ describe API::Projects do
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(
mirror: true,
import_url: import_url,
......@@ -583,7 +583,7 @@ describe API::Projects do
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(
mirror: true,
import_url: import_url,
......@@ -599,7 +599,7 @@ describe API::Projects do
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
end
......@@ -610,7 +610,7 @@ describe API::Projects do
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")
end
......@@ -637,7 +637,7 @@ describe API::Projects do
it 'disables project packages feature' do
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(json_response['packages_enabled']).to eq(false)
end
......@@ -651,7 +651,7 @@ describe API::Projects do
it 'disables project packages feature but does not return packages_enabled attribute' do
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(json_response['packages_enabled']).to be_nil
end
......@@ -665,7 +665,7 @@ describe API::Projects do
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)
end
end
......@@ -683,7 +683,7 @@ describe API::Projects do
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['marked_for_deletion_at']).to be_falsey
end
......@@ -694,7 +694,7 @@ describe API::Projects do
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)
end
end
......@@ -707,7 +707,7 @@ describe API::Projects do
it 'returns error' do
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
......@@ -721,7 +721,7 @@ describe API::Projects do
it 'marks project for deletion' do
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
end
......@@ -731,7 +731,7 @@ describe API::Projects do
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)
end
......@@ -740,7 +740,7 @@ describe API::Projects do
allow(Gitlab::CurrentSettings).to receive(:deletion_adjourned_period).and_return(0)
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)
end
end
......@@ -754,7 +754,7 @@ describe API::Projects do
it 'deletes project' do
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)
end
end
......
......@@ -18,7 +18,7 @@ describe API::ProtectedBranches do
it 'returns the protected branch' do
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([])
end
......@@ -43,7 +43,7 @@ describe API::ProtectedBranches do
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']}
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(merge_group_ids).to include(merge_group.id)
expect(unprotect_group_ids).to include(unprotect_group.id)
......@@ -100,7 +100,7 @@ describe API::ProtectedBranches do
patch api(route, user), params: { code_owner_approval_required: true }
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)
end
end
......@@ -115,7 +115,7 @@ describe API::ProtectedBranches do
patch api(route, user), params: { code_owner_approval_required: true }
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
......@@ -128,7 +128,7 @@ describe API::ProtectedBranches do
it "returns a 403 response" do
patch api(route, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -138,7 +138,7 @@ describe API::ProtectedBranches do
let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) }
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)
end
......@@ -150,14 +150,14 @@ describe API::ProtectedBranches do
it 'protects a single branch' do
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)
end
it 'protects a single branch and only admins can unprotect' do
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['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)
......@@ -175,7 +175,7 @@ describe API::ProtectedBranches do
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)
new_branch = project.protected_branches.find_by_name(branch_name)
......@@ -188,7 +188,7 @@ describe API::ProtectedBranches do
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)
new_branch = project.protected_branches.find_by_name(branch_name)
......@@ -203,7 +203,7 @@ describe API::ProtectedBranches do
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)
new_branch = project.protected_branches.find_by_name(branch_name)
......@@ -281,7 +281,7 @@ describe API::ProtectedBranches do
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/)
end
......@@ -290,7 +290,7 @@ describe API::ProtectedBranches do
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/)
end
......@@ -299,7 +299,7 @@ describe API::ProtectedBranches do
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['merge_access_levels'].count).to eq(1)
expect(json_response['push_access_levels'][0]['user_id']).to eq(push_user.id)
......
......@@ -32,7 +32,7 @@ describe API::ProtectedEnvironments do
it 'returns the protected environments' do
request
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
......@@ -57,7 +57,7 @@ describe API::ProtectedEnvironments do
it 'returns the protected environment' do
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(json_response['name']).to eq(protected_environment_name)
expect(json_response['deploy_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
......@@ -89,7 +89,7 @@ describe API::ProtectedEnvironments do
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(json_response['name']).to eq('staging')
expect(json_response['deploy_access_levels'].first['user_id']).to eq(deployer.id)
......@@ -100,7 +100,7 @@ describe API::ProtectedEnvironments do
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(json_response['name']).to eq('staging')
expect(json_response['deploy_access_levels'].first['group_id']).to eq(group.id)
......@@ -109,7 +109,7 @@ describe API::ProtectedEnvironments 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 }] }
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(json_response['name']).to eq('staging')
expect(json_response['deploy_access_levels'].first['access_level']).to eq(Gitlab::Access::MAINTAINER)
......@@ -121,7 +121,7 @@ describe API::ProtectedEnvironments do
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
context 'without deploy_access_levels' do
......@@ -133,7 +133,7 @@ describe API::ProtectedEnvironments do
it 'returns error with invalid deploy access level' do
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
......@@ -156,7 +156,7 @@ describe API::ProtectedEnvironments do
request
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
......
......@@ -49,7 +49,7 @@ describe API::PagesDomains do
it 'returns paginated all pages domains' do
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 include_pagination_headers
expect(json_response).to be_an Array
......@@ -76,7 +76,7 @@ describe API::PagesDomains do
it 'returns paginated pages domains' do
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 include_pagination_headers
expect(json_response).to be_an Array
......@@ -147,7 +147,7 @@ describe API::PagesDomains do
it 'returns pages domain' do
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(json_response['domain']).to eq(pages_domain.domain)
expect(json_response['url']).to eq(pages_domain.url)
......@@ -157,7 +157,7 @@ describe API::PagesDomains do
it 'returns pages domain with project path' do
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(json_response['domain']).to eq(pages_domain.domain)
expect(json_response['url']).to eq(pages_domain.url)
......@@ -167,7 +167,7 @@ describe API::PagesDomains do
it 'returns pages domain with a certificate' do
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(json_response['domain']).to eq(pages_domain_secure.domain)
expect(json_response['url']).to eq(pages_domain_secure.url)
......@@ -179,7 +179,7 @@ describe API::PagesDomains do
it 'returns pages domain with an expired certificate' do
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(json_response['certificate']['expired']).to be true
end
......@@ -187,7 +187,7 @@ describe API::PagesDomains do
it 'returns pages domain with letsencrypt' do
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(json_response['domain']).to eq(pages_domain_with_letsencrypt.domain)
expect(json_response['url']).to eq(pages_domain_with_letsencrypt.url)
......@@ -261,7 +261,7 @@ describe API::PagesDomains do
post api(route, user), params: params
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(pages_domain.domain).to eq(params[:domain])
expect(pages_domain.certificate).to be_nil
......@@ -273,7 +273,7 @@ describe API::PagesDomains do
post api(route, user), params: params_secure
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(pages_domain.domain).to eq(params_secure[:domain])
expect(pages_domain.certificate).to eq(params_secure[:certificate])
......@@ -285,7 +285,7 @@ describe API::PagesDomains do
post api(route, user), params: pages_domain_with_letsencrypt_params
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(pages_domain.domain).to eq(pages_domain_with_letsencrypt_params[:domain])
expect(pages_domain.auto_ssl_enabled).to be true
......@@ -295,7 +295,7 @@ describe API::PagesDomains do
post api(route, user), params: params_secure.merge(auto_ssl_enabled: true)
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(pages_domain.domain).to eq(params_secure[:domain])
expect(pages_domain.certificate).to eq(params_secure[:certificate])
......@@ -306,13 +306,13 @@ describe API::PagesDomains do
it 'fails to create pages domain without key' do
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
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)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -370,7 +370,7 @@ describe API::PagesDomains do
put api(route_secure_domain, user), params: { certificate: nil, key: nil }
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(pages_domain_secure.certificate).to be_nil
expect(pages_domain_secure.key).to be_nil
......@@ -381,7 +381,7 @@ describe API::PagesDomains do
put api(route_domain, user), params: params_secure
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(pages_domain.certificate).to eq(params_secure[:certificate])
expect(pages_domain.key).to eq(params_secure[:key])
......@@ -391,7 +391,7 @@ describe API::PagesDomains do
put api(route_domain, user), params: params_secure.merge(auto_ssl_enabled: true)
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(pages_domain.certificate).to eq(params_secure[:certificate])
expect(pages_domain.key).to eq(params_secure[:key])
......@@ -402,7 +402,7 @@ describe API::PagesDomains do
put api(route_domain, user), params: { auto_ssl_enabled: true }
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(pages_domain.auto_ssl_enabled).to be true
end
......@@ -411,7 +411,7 @@ describe API::PagesDomains do
put api(route_letsencrypt_domain, user), params: { auto_ssl_enabled: false }
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(pages_domain_with_letsencrypt.auto_ssl_enabled).to be false
expect(pages_domain_with_letsencrypt.key).to be
......@@ -422,7 +422,7 @@ describe API::PagesDomains do
put api(route_expired_domain, user), params: params_secure
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(pages_domain_expired.certificate).to eq(params_secure[:certificate])
expect(pages_domain_expired.key).to eq(params_secure[:key])
......@@ -432,7 +432,7 @@ describe API::PagesDomains do
put api(route_secure_domain, user), params: params_secure_nokey
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(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate])
end
......@@ -448,19 +448,19 @@ describe API::PagesDomains do
it 'fails to update pages domain adding certificate without key' do
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
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)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
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)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -524,7 +524,7 @@ describe API::PagesDomains do
it 'deletes a pages domain' do
delete api(route_domain, user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
......
......@@ -289,7 +289,7 @@ describe API::PipelineSchedules do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer)
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
it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do
......
......@@ -23,7 +23,7 @@ describe API::Pipelines do
it 'returns project pipelines' do
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(json_response).to be_an Array
expect(json_response.first['sha']).to match /\A\h{40}\z/
......@@ -294,7 +294,7 @@ describe API::Pipelines do
it 'does not return project pipelines' do
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).not_to be_an Array
end
......@@ -323,7 +323,7 @@ describe API::Pipelines do
post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
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['sha']).to eq project.commit.id
end
......@@ -337,7 +337,7 @@ describe API::Pipelines do
end.to change { project.ci_pipelines.count }.by(1)
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['sha']).to eq project.commit.id
expect(json_response).not_to have_key('variables')
......@@ -358,7 +358,7 @@ describe API::Pipelines do
end.to change { project.ci_pipelines.count }.by(1)
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['sha']).to eq project.commit.id
expect(json_response).not_to have_key('variables')
......@@ -372,7 +372,7 @@ describe API::Pipelines do
post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
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
......@@ -380,7 +380,7 @@ describe API::Pipelines do
it 'fails when using an invalid ref' do
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).not_to be_an Array
end
......@@ -395,7 +395,7 @@ describe API::Pipelines do
it 'fails to create pipeline' do
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).not_to be_an Array
end
......@@ -407,7 +407,7 @@ describe API::Pipelines do
it 'does not create pipeline' do
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).not_to be_an Array
end
......@@ -428,21 +428,21 @@ describe API::Pipelines do
it 'exposes known attributes' do
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')
end
it 'returns project pipelines' do
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/
end
it 'returns 404 when it does not exist' do
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['id']).to be nil
end
......@@ -464,7 +464,7 @@ describe API::Pipelines do
it 'does not return a project pipeline' do
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['id']).to be nil
end
......@@ -489,7 +489,7 @@ describe API::Pipelines do
it 'gets the latest pipleine' do
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(json_response['ref']).to eq(project.default_branch)
expect(json_response['sha']).to eq(project.commit.id)
......@@ -500,7 +500,7 @@ describe API::Pipelines do
it 'gets the latest pipleine' do
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(json_response['ref']).to eq(second_branch.name)
expect(json_response['sha']).to eq(second_branch.target)
......@@ -512,7 +512,7 @@ describe API::Pipelines do
it 'does not return a project pipeline' do
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['id']).to be nil
end
......@@ -528,7 +528,7 @@ describe API::Pipelines do
it 'returns pipeline variables empty' do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
......@@ -538,7 +538,7 @@ describe API::Pipelines do
it 'returns pipeline variables' do
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" })
end
end
......@@ -559,7 +559,7 @@ describe API::Pipelines do
it 'returns pipeline variables' do
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" })
end
end
......@@ -570,7 +570,7 @@ describe API::Pipelines do
it 'does not return pipeline variables' do
subject
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -579,7 +579,7 @@ describe API::Pipelines do
it 'does not return pipeline variables' do
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'
end
end
......@@ -592,14 +592,14 @@ describe API::Pipelines do
it 'destroys the pipeline' do
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)
end
it 'returns 404 when it does not exist' do
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'
end
......@@ -613,7 +613,7 @@ describe API::Pipelines do
it 'destroys associated jobs' do
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)
end
end
......@@ -624,7 +624,7 @@ describe API::Pipelines do
it 'returns a 404' do
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'
end
end
......@@ -639,7 +639,7 @@ describe API::Pipelines do
it 'returns a 403' do
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'
end
end
......@@ -660,7 +660,7 @@ describe API::Pipelines do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user)
end.to change { pipeline.builds.count }.from(1).to(2)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(build.reload.retried?).to be true
end
end
......@@ -669,7 +669,7 @@ describe API::Pipelines do
it 'does not return a project pipeline' do
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['id']).to be nil
end
......@@ -688,7 +688,7 @@ describe API::Pipelines do
it 'retries failed builds', :sidekiq_might_not_need_inline do
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')
end
end
......@@ -703,7 +703,7 @@ describe API::Pipelines do
it 'rejects the action' do
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')
end
end
......
......@@ -26,7 +26,7 @@ describe API::ProjectClusters do
it 'responds with 403' do
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
......@@ -36,7 +36,7 @@ describe API::ProjectClusters do
end
it 'responds with 200' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'includes pagination headers' do
......@@ -71,7 +71,7 @@ describe API::ProjectClusters do
it 'responds with 403' do
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
......@@ -142,7 +142,7 @@ describe API::ProjectClusters do
let(:cluster_id) { 123 }
it 'returns 404' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -175,7 +175,7 @@ describe API::ProjectClusters do
it 'responds with 403' do
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
......@@ -186,7 +186,7 @@ describe API::ProjectClusters do
context 'with valid params' do
it 'responds with 201' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'creates a new Cluster::Cluster' do
......@@ -236,7 +236,7 @@ describe API::ProjectClusters do
let(:namespace) { 'invalid_namespace' }
it 'responds with 400' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'does not create a new Clusters::Cluster' do
......@@ -258,7 +258,7 @@ describe API::ProjectClusters do
end
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'))
end
......@@ -270,7 +270,7 @@ describe API::ProjectClusters do
end
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')
end
......@@ -307,7 +307,7 @@ describe API::ProjectClusters do
it 'responds with 403' do
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
......@@ -322,7 +322,7 @@ describe API::ProjectClusters do
context 'with valid params' do
it 'responds with 200' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'updates cluster attributes' do
......@@ -336,7 +336,7 @@ describe API::ProjectClusters do
let(:namespace) { 'invalid_namespace' }
it 'responds with 400' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'does not update cluster attributes' do
......@@ -354,7 +354,7 @@ describe API::ProjectClusters do
let(:management_project_id) { create(:project).id }
it 'responds with 400' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns validation errors' do
......@@ -372,7 +372,7 @@ describe API::ProjectClusters do
end
it 'responds with 400' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns validation error' do
......@@ -384,7 +384,7 @@ describe API::ProjectClusters do
let(:namespace) { 'new-namespace' }
it 'responds with 200' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -413,7 +413,7 @@ describe API::ProjectClusters do
end
it 'responds with 200' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'updates platform kubernetes attributes' do
......@@ -430,7 +430,7 @@ describe API::ProjectClusters do
let(:cluster) { create(:cluster, :project, :provided_by_user) }
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
......@@ -448,7 +448,7 @@ describe API::ProjectClusters do
it 'responds with 403' do
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
......@@ -458,7 +458,7 @@ describe API::ProjectClusters do
end
it 'responds with 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'deletes the cluster' do
......@@ -469,7 +469,7 @@ describe API::ProjectClusters do
let(:cluster) { create(:cluster, :project, :provided_by_user) }
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
......
......@@ -163,7 +163,7 @@ describe API::ProjectContainerRepositories do
stub_exclusive_lease_taken(lease_key, timeout: 1.hour)
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.')
end
......
......@@ -14,7 +14,7 @@ describe API::ProjectEvents do
it 'returns 404 for private project' do
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
it 'returns 200 status for a public project' do
......@@ -22,7 +22,7 @@ describe API::ProjectEvents do
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
......@@ -36,14 +36,14 @@ describe API::ProjectEvents do
it 'returns only accessible events' do
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)
end
it 'returns all events when the user has access' do
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)
end
end
......@@ -92,7 +92,7 @@ describe API::ProjectEvents do
it 'returns 404' do
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
......@@ -100,7 +100,7 @@ describe API::ProjectEvents do
it 'returns project events' do
get api("/projects/#{private_project.id}/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -109,7 +109,7 @@ describe API::ProjectEvents do
it 'returns 404 if project does not exist' do
get api("/projects/1234/events", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'when the requesting token does not have "api" scope' do
......@@ -118,7 +118,7 @@ describe API::ProjectEvents do
it 'returns a "403" response' do
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
......@@ -142,7 +142,7 @@ describe API::ProjectEvents do
get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request }
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(json_response.size).to eq(2)
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
it 'prevents requesting project export' do
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.')
end
end
......@@ -77,7 +77,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is none' do
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(json_response['export_status']).to eq('none')
end
......@@ -85,7 +85,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is started' do
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(json_response['export_status']).to eq('started')
end
......@@ -93,7 +93,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is after_export' do
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(json_response['export_status']).to eq('after_export_action')
end
......@@ -101,7 +101,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is finished' do
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(json_response['export_status']).to eq('finished')
end
......@@ -185,7 +185,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'downloads' do
get api(download_path_finished, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -194,7 +194,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'downloads' do
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
......@@ -324,7 +324,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
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
......@@ -334,7 +334,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
post api(path, user)
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
end
end
end
......@@ -403,7 +403,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute)
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
......
......@@ -25,7 +25,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns project hooks" do
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(response).to include_pagination_headers
expect(json_response.count).to eq(1)
......@@ -49,7 +49,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "does not access project hooks" do
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
......@@ -59,7 +59,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['url']).to eq(hook.url)
expect(json_response['issues_events']).to eq(hook.issues_events)
expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
......@@ -77,14 +77,14 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
context "unauthorized user" do
it "does not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -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' }
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['issues_events']).to eq(true)
expect(json_response['confidential_issues_events']).to eq(true)
......@@ -120,7 +120,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token }
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).not_to include("token")
......@@ -132,17 +132,17 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it "returns a 422 error if url not valid" do
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
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/' }
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
......@@ -151,7 +151,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
put api("/projects/#{project.id}/hooks/#{hook.id}", user),
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['issues_events']).to eq(hook.issues_events)
expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
......@@ -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 }
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).not_to include("token")
......@@ -181,17 +181,17 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns 404 error if hook id not found" do
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
it "returns 400 error if url is not given" do
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
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' }
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
......@@ -200,19 +200,19 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect do
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
it "returns a 404 error when deleting non existent hook" do
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
it "returns a 404 error if hook id not given" do
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
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
other_project.add_maintainer(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
end
......
......@@ -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 }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'schedules an import using the namespace path' 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 }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
context 'when a name is explicitly set' 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 }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'schedules an import using the namespace path and a different name' 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 }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'sets name correctly' do
......@@ -93,7 +93,7 @@ describe API::ProjectImport do
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
it 'does not schedule an import for a namespace that does not exist' 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) }
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')
end
......@@ -116,7 +116,7 @@ describe API::ProjectImport do
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')
end
......@@ -125,7 +125,7 @@ describe API::ProjectImport do
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')
end
......@@ -186,7 +186,7 @@ describe API::ProjectImport do
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')
end
......@@ -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 }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
end
end
......@@ -209,7 +209,7 @@ describe API::ProjectImport 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 }
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.')
end
end
......@@ -276,7 +276,7 @@ describe API::ProjectImport do
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')
end
......@@ -287,7 +287,7 @@ describe API::ProjectImport do
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',
'import_error' => 'error')
end
......
......@@ -27,19 +27,19 @@ describe API::ProjectMilestones do
it 'returns 404 response when the project does not exists' do
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
it 'returns 404 response when the milestone does not exists' do
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
it "returns 404 from guest user deleting a milestone" do
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
......@@ -67,7 +67,7 @@ describe API::ProjectMilestones do
it 'returns 403' do
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
......@@ -79,14 +79,14 @@ describe API::ProjectMilestones do
it 'returns 200' do
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)
end
it 'returns 200 for closed milestone' do
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)
end
end
......@@ -99,13 +99,13 @@ describe API::ProjectMilestones do
it 'returns 404 response when the project does not exist' do
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
it 'returns 404 response when the milestone does not exist' do
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
......@@ -117,7 +117,7 @@ describe API::ProjectMilestones do
it 'returns 403' do
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
......
......@@ -34,26 +34,26 @@ describe API::ProjectSnapshots do
it 'returns authentication error as project owner' do
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
it 'returns authentication error as unauthenticated user' do
get api("/projects/#{project.id}/snapshot", nil)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'requests project repository raw archive as administrator' do
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)
end
it 'requests wiki repository raw archive as administrator' do
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)
end
end
......
......@@ -14,7 +14,7 @@ describe API::ProjectSnippets do
it 'exposes known attributes' do
get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_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['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
......@@ -24,13 +24,13 @@ describe API::ProjectSnippets do
other_project = create(:project)
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
it "returns unauthorized for non-admin users" do
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
......@@ -45,7 +45,7 @@ describe API::ProjectSnippets do
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(json_response).to be_an Array
expect(json_response.size).to eq(3)
......@@ -58,7 +58,7 @@ describe API::ProjectSnippets do
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(json_response).to be_an Array
expect(json_response.size).to eq(0)
......@@ -72,7 +72,7 @@ describe API::ProjectSnippets do
it 'returns snippet json' do
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['description']).to eq(snippet.description)
......@@ -82,7 +82,7 @@ describe API::ProjectSnippets do
it 'returns 404 for invalid snippet id' do
get api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found')
end
end
......@@ -110,7 +110,7 @@ describe API::ProjectSnippets do
it 'creates a new snippet' do
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'])
expect(snippet.content).to eq(params[:code])
expect(snippet.description).to eq(params[:description])
......@@ -123,7 +123,7 @@ describe API::ProjectSnippets do
it 'creates a new snippet' do
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'])
expect(snippet.content).to eq(params[:code])
expect(snippet.description).to eq(params[:description])
......@@ -137,7 +137,7 @@ describe API::ProjectSnippets do
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'])
expect(snippet.content).to eq(params[:content])
expect(snippet.description).to eq(params[:description])
......@@ -151,7 +151,7 @@ describe API::ProjectSnippets do
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')
end
......@@ -160,7 +160,7 @@ describe API::ProjectSnippets do
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
it 'returns 400 for empty code field' do
......@@ -168,7 +168,7 @@ describe API::ProjectSnippets do
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
context 'when the snippet is spam' do
......@@ -196,7 +196,7 @@ describe API::ProjectSnippets do
expect { create_snippet(project, visibility: 'public') }
.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" })
end
......@@ -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' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
snippet.reload
expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description)
......@@ -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 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
snippet.reload
expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description)
......@@ -240,21 +240,21 @@ describe API::ProjectSnippets 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' }
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')
end
it 'returns 404 for invalid snippet id' do
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')
end
it 'returns 400 for missing parameters' do
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
it 'returns 400 for empty code field' do
......@@ -262,7 +262,7 @@ describe API::ProjectSnippets do
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
context 'when the snippet is spam' do
......@@ -306,7 +306,7 @@ describe API::ProjectSnippets do
expect { update_snippet(title: 'Foo', visibility: 'public') }
.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" })
end
......@@ -324,13 +324,13 @@ describe API::ProjectSnippets do
it 'deletes snippet' do
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
it 'returns 404 for invalid snippet id' do
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')
end
......@@ -345,7 +345,7 @@ describe API::ProjectSnippets do
it 'returns raw text' do
get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/plain'
expect(response.body).to eq(snippet.content)
end
......@@ -353,7 +353,7 @@ describe API::ProjectSnippets do
it 'returns 404 for invalid snippet id' do
get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found')
end
end
......
......@@ -21,7 +21,7 @@ describe API::ProjectStatistics do
it 'returns the fetch statistics of the last 30 days' do
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']
expect(fetches['total']).to eq(40)
expect(fetches['days'].length).to eq(5)
......@@ -34,7 +34,7 @@ describe API::ProjectStatistics do
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']
expect(fetches['total']).to eq(40)
expect(fetches['days'].length).to eq(5)
......@@ -47,7 +47,7 @@ describe API::ProjectStatistics do
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')
end
......@@ -56,7 +56,7 @@ describe API::ProjectStatistics do
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
......@@ -15,7 +15,7 @@ describe API::ProjectTemplates do
it 'returns dockerfiles' do
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 match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Binary' }
......@@ -24,7 +24,7 @@ describe API::ProjectTemplates do
it 'returns gitignores' do
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 match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Actionscript' }
......@@ -33,7 +33,7 @@ describe API::ProjectTemplates do
it 'returns gitlab_ci_ymls' do
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 match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Android' }
......@@ -42,7 +42,7 @@ describe API::ProjectTemplates do
it 'returns licenses' do
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 match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'mit' }
......@@ -51,19 +51,19 @@ describe API::ProjectTemplates do
it 'returns 400 for an unknown template type' do
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
it 'denies access to an anonymous user on a private project' do
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
it 'permits access to a developer on a private project' do
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')
end
end
......@@ -72,7 +72,7 @@ describe API::ProjectTemplates do
it 'returns key and name for the listed licenses' do
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')
end
end
......@@ -81,7 +81,7 @@ describe API::ProjectTemplates do
it 'returns a specific dockerfile' do
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(json_response['name']).to eq('Binary')
end
......@@ -89,7 +89,7 @@ describe API::ProjectTemplates do
it 'returns a specific gitignore' do
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(json_response['name']).to eq('Actionscript')
end
......@@ -97,7 +97,7 @@ describe API::ProjectTemplates do
it 'returns C++ gitignore' do
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(json_response['name']).to eq('C++')
end
......@@ -105,7 +105,7 @@ describe API::ProjectTemplates do
it 'returns C++ gitignore for URL-encoded names' do
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(json_response['name']).to eq('C++')
end
......@@ -113,7 +113,7 @@ describe API::ProjectTemplates do
it 'returns a specific gitlab_ci_yml' do
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(json_response['name']).to eq('Android')
end
......@@ -121,26 +121,26 @@ describe API::ProjectTemplates do
it 'returns a specific license' do
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')
end
it 'returns 404 for an unknown specific template' do
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
it 'denies access to an anonymous user on a private project' do
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
it 'permits access to a developer on a private project' do
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')
end
......@@ -148,7 +148,7 @@ describe API::ProjectTemplates do
it 'rejects invalid filenames' do
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
......@@ -165,7 +165,7 @@ describe API::ProjectTemplates do
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')
content = json_response['content']
......
......@@ -110,7 +110,7 @@ describe API::Projects do
it 'returns an array of projects' do
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(json_response).to be_an Array
expect(json_response.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id))
......@@ -210,7 +210,7 @@ describe API::Projects do
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.map { |p| p['id'] }).not_to include(project.id)
end
......@@ -242,7 +242,7 @@ describe API::Projects do
it "does not include statistics by default" do
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(json_response).to be_an Array
expect(json_response.first).not_to include('statistics')
......@@ -251,7 +251,7 @@ describe API::Projects do
it "includes statistics if requested" do
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(json_response).to be_an Array
expect(json_response.first).to include 'statistics'
......@@ -260,7 +260,7 @@ describe API::Projects do
it "does not include license by default" do
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(json_response).to be_an Array
expect(json_response.first).not_to include('license', 'license_url')
......@@ -269,7 +269,7 @@ describe API::Projects do
it "does not include license if requested" do
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(json_response).to be_an Array
expect(json_response.first).not_to include('license', 'license_url')
......@@ -314,7 +314,7 @@ describe API::Projects do
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(json_response).to be_an Array
expect(json_response.first.keys).to match_array expected_keys
......@@ -327,7 +327,7 @@ describe API::Projects do
it 'returns archived projects' do
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(json_response).to be_an Array
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
it 'returns non-archived projects' do
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(json_response).to be_an Array
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
it 'returns every project' do
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(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))
......@@ -398,7 +398,7 @@ describe API::Projects do
it 'filters based on private visibility param' do
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(json_response).to be_an Array
expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id, project2.id, project3.id)
......@@ -409,7 +409,7 @@ describe API::Projects do
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(json_response).to be_an Array
expect(json_response.map { |p| p['id'] }).to contain_exactly(project2.id)
......@@ -418,7 +418,7 @@ describe API::Projects do
it 'filters based on public visibility param' do
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(json_response).to be_an Array
expect(json_response.map { |p| p['id'] }).to contain_exactly(public_project.id)
......@@ -431,7 +431,7 @@ describe API::Projects do
it 'filters case-insensitively by programming language' do
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(json_response).to be_an Array
expect(json_response.map { |p| p['id'] }).to contain_exactly(project3.id)
......@@ -442,7 +442,7 @@ describe API::Projects do
it 'returns the correct order when sorted by id' do
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(json_response).to be_an Array
expect(json_response.first['id']).to eq(project3.id)
......@@ -453,7 +453,7 @@ describe API::Projects do
it 'returns an array of projects the user owns' do
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(json_response).to be_an Array
expect(json_response.first['name']).to eq(project4.name)
......@@ -472,7 +472,7 @@ describe API::Projects do
it 'returns the starred projects viewable by the user' do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id)
......@@ -494,7 +494,7 @@ describe API::Projects do
it 'returns only projects that satisfy all query parameters' do
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(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -513,7 +513,7 @@ describe API::Projects do
it 'returns only projects that satisfy all query parameters' do
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(json_response).to be_an Array
expect(json_response.size).to eq(2)
......@@ -532,7 +532,7 @@ describe API::Projects do
it 'returns an array of projects the user has at least developer access' do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(project2.id, project3.id)
......@@ -587,7 +587,7 @@ describe API::Projects do
it 'contains only the first project with per_page = 1' do
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.map { |p| p['id'] }).to contain_exactly(public_project.id)
end
......@@ -609,14 +609,14 @@ describe API::Projects 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))
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq([])
end
it 'responds with 501 if order_by is different from id' do
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
......@@ -634,7 +634,7 @@ describe API::Projects do
it 'contains only the last project with per_page = 1' do
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.map { |p| p['id'] }).to contain_exactly(project3.id)
end
......@@ -672,14 +672,14 @@ describe API::Projects do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0)
expect { post api('/projects', user2), params: { name: 'foo' } }
.to change {Project.count}.by(0)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
it 'creates new project without path but with name and returns 201' do
expect { post api('/projects', user), 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.first
......@@ -690,7 +690,7 @@ describe API::Projects do
it 'creates new project without name but with path and returns 201' do
expect { post api('/projects', user), params: { path: '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.first
......@@ -701,7 +701,7 @@ describe API::Projects 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' } }
.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
......@@ -712,12 +712,12 @@ describe API::Projects do
it 'creates last project before reaching project limit' do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1)
post api('/projects', user2), params: { name: 'foo' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'does not create new project without name or path and returns 400' do
expect { post api('/projects', user) }.not_to change { Project.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it "assigns attributes to project" do
......@@ -739,7 +739,7 @@ describe API::Projects do
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|
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
expect { post api('/projects', user), params: { template_name: 'rails', name: 'rails-test' } }
.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'])
expect(project).to be_saved
......@@ -769,7 +769,7 @@ describe API::Projects do
expect { post api('/projects', user), params: { template_name: 'unknown', name: 'rails-test' } }
.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"])
end
......@@ -778,7 +778,7 @@ describe API::Projects do
expect { post api('/projects', user), params: project_params }
.not_to change { Project.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'sets a project as public' do
......@@ -931,7 +931,7 @@ describe API::Projects do
post api('/projects', user), params: project
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'ignores import_url when it is nil' do
......@@ -939,7 +939,7 @@ describe API::Projects do
post api('/projects', user), params: project
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
context 'when a visibility level is restricted' do
......@@ -952,7 +952,7 @@ describe API::Projects do
it 'does not allow a non-admin to use a restricted visibility level' do
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(
match('restricted by your GitLab administrator')
)
......@@ -972,14 +972,14 @@ describe API::Projects do
it 'returns error when user not found' do
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')
end
it 'returns projects filtered by user id' do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
......@@ -991,7 +991,7 @@ describe API::Projects do
it 'only returns projects with id_after filter given' do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(another_public_project.id)
......@@ -1000,7 +1000,7 @@ describe API::Projects do
it 'returns both projects without a id_after filter' do
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(json_response).to be_an Array
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
it 'only returns projects with id_before filter given' do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
......@@ -1022,7 +1022,7 @@ describe API::Projects do
it 'returns both projects without a id_before filter' do
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(json_response).to be_an Array
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
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)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(*more_projects[1..-2].map(&:id))
......@@ -1045,7 +1045,7 @@ describe API::Projects do
it 'returns projects filtered by username' do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
......@@ -1059,7 +1059,7 @@ describe API::Projects do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(private_project1.id)
......@@ -1071,7 +1071,7 @@ describe API::Projects do
it 'filters case-insensitively by programming language' do
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(json_response).to be_an Array
expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id)
......@@ -1087,14 +1087,14 @@ describe API::Projects do
it 'returns error when user not found' do
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')
end
it 'returns projects filtered by user' do
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(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, project2.id, project3.id)
......@@ -1104,7 +1104,7 @@ describe API::Projects do
describe 'POST /projects/user/:id' 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(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
project = Project.find(json_response['id'])
......@@ -1115,7 +1115,7 @@ describe API::Projects do
it 'creates new project with name and path and returns 201' do
expect { post api("/projects/user/#{user.id}", admin), params: { path: 'path-project-Foo', 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'])
......@@ -1127,7 +1127,7 @@ describe API::Projects do
expect { post api("/projects/user/#{user.id}", admin) }
.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')
end
......@@ -1142,7 +1142,7 @@ describe API::Projects do
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|
next if %i[has_external_issue_tracker path storage_version].include?(k)
......@@ -1156,7 +1156,7 @@ describe API::Projects do
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')
end
......@@ -1165,7 +1165,7 @@ describe API::Projects do
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')
end
......@@ -1246,7 +1246,7 @@ describe API::Projects 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") }
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['url']).to start_with("/uploads/")
expect(json_response['url']).to end_with("/dk.png")
......@@ -1260,7 +1260,7 @@ describe API::Projects do
get api("/projects/#{private_project.id}")
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns public projects' do
......@@ -1268,7 +1268,7 @@ describe API::Projects do
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['description']).to eq(public_project.description)
expect(json_response['default_branch']).to eq(public_project.default_branch)
......@@ -1283,7 +1283,7 @@ describe API::Projects do
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
end
end
......@@ -1295,7 +1295,7 @@ describe API::Projects do
it 'hides protected attributes of private repositories if user is not a member' do
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|
expect(json_response.keys).not_to include(attribute)
end
......@@ -1306,7 +1306,7 @@ describe API::Projects do
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|
expect(json_response.keys).to include(attribute)
end
......@@ -1323,7 +1323,7 @@ describe API::Projects do
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['description']).to eq(project.description)
expect(json_response['default_branch']).to eq(project.default_branch)
......@@ -1374,7 +1374,7 @@ describe API::Projects do
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['description']).to eq(project.description)
expect(json_response['default_branch']).to eq(project.default_branch)
......@@ -1448,20 +1448,20 @@ describe API::Projects do
it 'returns a project by path name' do
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)
end
it 'returns a 404 error if not found' do
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')
end
it 'returns a 404 error if user is not a member' do
other_user = create(:user)
get api("/projects/#{project.id}", other_user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'handles users with dots' do
......@@ -1469,14 +1469,14 @@ describe API::Projects do
project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace)
get api("/projects/#{CGI.escape(project.full_path)}", dot_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(project.name)
end
it 'exposes namespace fields' do
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({
'id' => user.namespace.id,
'name' => user.namespace.name,
......@@ -1492,14 +1492,14 @@ describe API::Projects do
it "does not include license fields by default" do
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')
end
it 'includes license fields when requested' do
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({
'key' => project.repository.license.key,
'name' => project.repository.license.name,
......@@ -1512,14 +1512,14 @@ describe API::Projects do
it "does not include statistics by default" do
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'
end
it "includes statistics if requested" do
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'
end
......@@ -1529,7 +1529,7 @@ describe API::Projects do
it "does not include statistics if user is not a member" do
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'
end
......@@ -1538,7 +1538,7 @@ describe API::Projects do
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'
end
......@@ -1548,7 +1548,7 @@ describe API::Projects do
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'
end
end
......@@ -1556,14 +1556,14 @@ describe API::Projects do
it "includes import_error if user can admin project" do
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")
end
it "does not include import_error if user cannot admin project" do
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")
end
......@@ -1572,7 +1572,7 @@ describe API::Projects do
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')
end
......@@ -1614,7 +1614,7 @@ describe API::Projects do
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)
end
......@@ -1625,7 +1625,7 @@ describe API::Projects do
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
end
end
......@@ -1639,7 +1639,7 @@ describe API::Projects do
it 'contains permission information' do
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'])
.to eq(Gitlab::Access::MAINTAINER)
expect(json_response.first['permissions']['group_access']).to be_nil
......@@ -1651,7 +1651,7 @@ describe API::Projects do
project.add_maintainer(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'])
.to eq(Gitlab::Access::MAINTAINER)
expect(json_response['permissions']['group_access']).to be_nil
......@@ -1668,7 +1668,7 @@ describe API::Projects do
it 'sets the owner and return 200' do
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']['group_access']['access_level'])
.to eq(Gitlab::Access::OWNER)
......@@ -1687,7 +1687,7 @@ describe API::Projects do
it 'sets group access and return 200' do
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']['group_access']['access_level'])
.to eq(Gitlab::Access::OWNER)
......@@ -1701,7 +1701,7 @@ describe API::Projects do
it 'sets the maximum group access and return 200' do
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']['group_access']['access_level'])
.to eq(Gitlab::Access::OWNER)
......@@ -1718,7 +1718,7 @@ describe API::Projects do
it 'returns group web_url and avatar_url' do
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']
expect(group_data['web_url']).to eq(group.web_url)
......@@ -1733,7 +1733,7 @@ describe API::Projects do
it 'returns user web_url and avatar_url' do
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']
expect(user_data['web_url']).to eq("http://localhost/#{user.username}")
......@@ -1758,7 +1758,7 @@ describe API::Projects do
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(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -1787,7 +1787,7 @@ describe API::Projects do
it 'returns a 404 error if not found' do
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')
end
......@@ -1796,7 +1796,7 @@ describe API::Projects do
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
it 'filters out users listed in skip_users' do
......@@ -1805,7 +1805,7 @@ describe API::Projects do
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[0]['id']).to eq(other_user.id)
end
......@@ -1826,7 +1826,7 @@ describe API::Projects 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)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -1845,7 +1845,7 @@ describe API::Projects do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
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.fork_network_member).to be_present
expect(project_fork_target).to be_forked
......@@ -1854,7 +1854,7 @@ describe API::Projects 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)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -1864,13 +1864,13 @@ describe API::Projects do
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
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)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'refreshes the forks count cachce' do
......@@ -1881,7 +1881,7 @@ describe API::Projects do
it 'fails if forked_from project which does not exist' do
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
it 'fails with 409 if already forked' do
......@@ -1892,7 +1892,7 @@ describe API::Projects do
post api("/projects/#{project_fork_target.id}/fork/#{other_project_fork_source.id}", admin)
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).to be_forked
end
......@@ -1902,7 +1902,7 @@ describe API::Projects do
describe 'DELETE /projects/:id/fork' do
it "is not visible to users outside group" do
delete api("/projects/#{project_fork_target.id}/fork", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'when users belong to project group' do
......@@ -1924,7 +1924,7 @@ describe API::Projects do
it 'makes forked project unforked' do
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
expect(project_fork_target.forked_from_project).to be_nil
expect(project_fork_target).not_to be_forked
......@@ -1937,13 +1937,13 @@ describe API::Projects do
it 'is forbidden to non-owner users' do
delete api("/projects/#{project_fork_target.id}/fork", user2)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'is idempotent if not forked' do
expect(project_fork_target.forked_from_project).to be_nil
delete api("/projects/#{project_fork_target.id}/fork", admin)
expect(response).to have_gitlab_http_status(304)
expect(response).to have_gitlab_http_status(:not_modified)
expect(project_fork_target.reload.forked_from_project).to be_nil
end
end
......@@ -1973,7 +1973,7 @@ describe API::Projects do
it 'returns the forks' do
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(json_response.length).to eq(1)
expect(json_response[0]['name']).to eq(private_fork.name)
......@@ -1984,7 +1984,7 @@ describe API::Projects do
it 'returns an empty array' do
get api("/projects/#{project_fork_source.id}/forks", non_member)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(0)
end
......@@ -1995,7 +1995,7 @@ describe API::Projects do
it 'returns an empty array' do
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(json_response.length).to eq(0)
end
......@@ -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 }
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_access']).to eq(Gitlab::Access::DEVELOPER)
expect(json_response['expires_at']).to eq(expires_at.to_s)
......@@ -2025,18 +2025,18 @@ describe API::Projects 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 }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it "returns a 400 error when access level is not given" do
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
it "returns a 400 error when sharing is disabled" do
project.namespace.update(share_with_group_lock: true)
post api("/projects/#{project.id}/share", user), 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
it 'returns a 404 error when user cannot read group' 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 }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
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 }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
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 }
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'
end
......@@ -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 }
expect(response).to have_gitlab_http_status(409)
expect(response).to have_gitlab_http_status(:conflict)
end
end
......@@ -2081,7 +2081,7 @@ describe API::Projects do
it 'returns 204 when deleting a group share' do
delete api("/projects/#{project.id}/share/#{group.id}", user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
expect(project.project_group_links).to be_empty
end
......@@ -2093,19 +2093,19 @@ describe API::Projects do
it 'returns a 400 when group id is not an integer' do
delete api("/projects/#{project.id}/share/foo", user)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns a 404 error when group link does not exist' do
delete api("/projects/#{project.id}/share/1234", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns a 404 error when project does not exist' do
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
......@@ -2126,7 +2126,7 @@ describe API::Projects do
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')
end
......@@ -2136,7 +2136,7 @@ describe API::Projects do
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
......@@ -2146,7 +2146,7 @@ describe API::Projects do
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|
expect(json_response[k.to_s]).to eq(v)
......@@ -2158,7 +2158,7 @@ describe API::Projects do
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|
expect(json_response[k.to_s]).to eq(v)
......@@ -2171,7 +2171,7 @@ describe API::Projects do
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|
expect(json_response[k.to_s]).to eq(v)
......@@ -2185,7 +2185,7 @@ describe API::Projects do
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'])
end
......@@ -2194,7 +2194,7 @@ describe API::Projects do
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)
end
......@@ -2203,7 +2203,7 @@ describe API::Projects do
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|
expect(json_response[k.to_s]).to eq(v)
......@@ -2215,7 +2215,7 @@ describe API::Projects do
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|
expect(json_response[k.to_s]).to eq(v)
......@@ -2227,7 +2227,7 @@ describe API::Projects do
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')
end
......@@ -2247,7 +2247,7 @@ describe API::Projects do
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)
end
......@@ -2257,7 +2257,7 @@ describe API::Projects do
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')
end
......@@ -2267,7 +2267,7 @@ describe API::Projects do
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
it 'updates merge_method' do
......@@ -2275,7 +2275,7 @@ describe API::Projects do
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|
expect(json_response[k.to_s]).to eq(v)
......@@ -2287,7 +2287,7 @@ describe API::Projects do
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
it 'updates avatar' do
......@@ -2298,7 +2298,7 @@ describe API::Projects do
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/'\
'-/system/project/avatar/'\
"#{project3.id}/banana_sample.gif")
......@@ -2309,7 +2309,7 @@ describe API::Projects do
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')
end
......@@ -2319,7 +2319,7 @@ describe API::Projects do
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)
end
......@@ -2329,7 +2329,7 @@ describe API::Projects do
it 'updates path' do
project_param = { path: 'bar' }
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|
expect(json_response[k.to_s]).to eq(v)
end
......@@ -2345,7 +2345,7 @@ describe API::Projects do
description: 'new description' }
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|
expect(json_response[k.to_s]).to eq(v)
end
......@@ -2354,20 +2354,20 @@ describe API::Projects do
it 'does not update path to existing path' do
project_param = { path: project.path }
put api("/projects/#{project3.id}", user4), 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'])
end
it 'does not update name' do
project_param = { name: 'bar' }
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
it 'does not update visibility_level' do
project_param = { visibility: 'public' }
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
it 'updates container_expiration_policy' do
......@@ -2380,7 +2380,7 @@ describe API::Projects do
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']['keep_n']).to eq(1)
......@@ -2397,7 +2397,7 @@ describe API::Projects do
description: 'new description',
request_access_enabled: true }
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
......@@ -2407,7 +2407,7 @@ describe API::Projects do
it 'archives the project' do
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
end
end
......@@ -2420,7 +2420,7 @@ describe API::Projects do
it 'remains archived' do
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
end
end
......@@ -2433,7 +2433,7 @@ describe API::Projects do
it 'rejects the action' do
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
......@@ -2443,7 +2443,7 @@ describe API::Projects do
it 'remains unarchived' do
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
end
end
......@@ -2456,7 +2456,7 @@ describe API::Projects do
it 'unarchives the project' do
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
end
end
......@@ -2469,7 +2469,7 @@ describe API::Projects do
it 'rejects the action' do
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
......@@ -2479,7 +2479,7 @@ describe API::Projects do
it 'stars the project' do
expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['star_count']).to eq(1)
end
end
......@@ -2493,7 +2493,7 @@ describe API::Projects do
it 'does not modify the star count' do
expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count }
expect(response).to have_gitlab_http_status(304)
expect(response).to have_gitlab_http_status(:not_modified)
end
end
end
......@@ -2508,7 +2508,7 @@ describe API::Projects do
it 'unstars the project' do
expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['star_count']).to eq(0)
end
end
......@@ -2517,7 +2517,7 @@ describe API::Projects do
it 'does not modify the star count' do
expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count }
expect(response).to have_gitlab_http_status(304)
expect(response).to have_gitlab_http_status(:not_modified)
end
end
end
......@@ -2527,7 +2527,7 @@ describe API::Projects do
it 'returns an array of starrers' do
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(json_response).to be_an Array
expect(json_response[0]['starred_since']).to be_present
......@@ -2642,7 +2642,7 @@ describe API::Projects do
it 'removes project' do
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')
end
......@@ -2655,17 +2655,17 @@ describe API::Projects do
user3 = create(:user)
project.add_developer(user3)
delete api("/projects/#{project.id}", user3)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'does not remove a non existing project' do
delete api('/projects/1328', user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not remove a project not attached to user' do
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
......@@ -2673,13 +2673,13 @@ describe API::Projects do
it 'removes any existing project' do
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')
end
it 'does not remove a non existing project' do
delete api('/projects/1328', admin)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it_behaves_like '412 response' do
......@@ -2906,7 +2906,7 @@ describe API::Projects do
post api("/projects/#{project.id}/housekeeping", user)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
context 'when housekeeping lease is taken' do
......@@ -2915,7 +2915,7 @@ describe API::Projects do
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/)
end
end
......@@ -2929,7 +2929,7 @@ describe API::Projects do
it 'returns forbidden error' do
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
......@@ -2937,7 +2937,7 @@ describe API::Projects do
it 'returns authentication error' do
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
......@@ -2951,25 +2951,25 @@ describe API::Projects do
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
it 'fails when transferring to a non owned namespace' do
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
it 'fails when transferring to an unknown namespace' do
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
it 'fails on missing namespace' do
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
......@@ -2984,7 +2984,7 @@ describe API::Projects do
it 'fails transferring the project to the target namespace' do
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
......
......@@ -19,7 +19,7 @@ describe API::ProtectedBranches do
it 'returns the protected branches' do
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(json_response).to be_an Array
......@@ -66,7 +66,7 @@ describe API::ProtectedBranches do
it 'returns the protected branch' do
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['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)
......@@ -118,7 +118,7 @@ describe API::ProtectedBranches do
let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) }
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)
end
......@@ -130,7 +130,7 @@ describe API::ProtectedBranches do
it 'protects a single branch' do
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['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)
......@@ -139,7 +139,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can push' do
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['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)
......@@ -148,7 +148,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can merge' do
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['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)
......@@ -157,7 +157,7 @@ describe API::ProtectedBranches 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 }
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['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)
......@@ -166,7 +166,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can push' do
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['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)
......@@ -175,7 +175,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can merge' do
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['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)
......@@ -184,7 +184,7 @@ describe API::ProtectedBranches 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 }
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['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)
......@@ -193,7 +193,7 @@ describe API::ProtectedBranches do
it 'returns a 409 error if the same branch is protected twice' do
post post_endpoint, params: { name: protected_name }
expect(response).to have_gitlab_http_status(409)
expect(response).to have_gitlab_http_status(:conflict)
end
context 'when branch has a wildcard in its name' do
......@@ -217,7 +217,7 @@ describe API::ProtectedBranches do
it "prevents deletion of the protected branch rule" do
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
......@@ -230,7 +230,7 @@ describe API::ProtectedBranches do
it "returns a 403 error if guest" do
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
......@@ -245,7 +245,7 @@ describe API::ProtectedBranches do
it "unprotects a single branch" do
delete delete_endpoint
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it_behaves_like '412 response' do
......@@ -255,7 +255,7 @@ describe API::ProtectedBranches do
it "returns 404 if branch does not exist" do
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
context 'when a policy restricts rule deletion' do
......@@ -267,7 +267,7 @@ describe API::ProtectedBranches do
it "prevents deletion of the protected branch rule" do
delete delete_endpoint
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -277,7 +277,7 @@ describe API::ProtectedBranches do
it "unprotects a wildcard branch" do
delete delete_endpoint
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
end
......
......@@ -19,7 +19,7 @@ describe API::ProtectedTags do
it 'returns the protected tags' do
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(json_response).to be_an Array
......@@ -55,7 +55,7 @@ describe API::ProtectedTags do
it 'returns the protected tag' do
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['create_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
end
......@@ -106,7 +106,7 @@ describe API::ProtectedTags do
it 'protects a single tag with maintainers can create tags' do
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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
end
......@@ -115,7 +115,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user),
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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
end
......@@ -124,7 +124,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user),
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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
end
......@@ -132,7 +132,7 @@ describe API::ProtectedTags 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 }
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')
end
......@@ -140,7 +140,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.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)
end
......@@ -150,7 +150,7 @@ describe API::ProtectedTags do
it 'protects multiple tags with a wildcard in the name' do
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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
end
......@@ -165,7 +165,7 @@ describe API::ProtectedTags do
it 'returns a 403 error if guest' do
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
......@@ -178,7 +178,7 @@ describe API::ProtectedTags do
it 'unprotects a single tag' do
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
it_behaves_like '412 response' do
......@@ -188,7 +188,7 @@ describe API::ProtectedTags do
it "returns 404 if tag does not exist" do
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
context 'when tag has a wildcard in its name' do
......@@ -197,7 +197,7 @@ describe API::ProtectedTags do
it 'unprotects a wildcard tag' do
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
......
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