Commit 55c6405b authored by Peter Leitzen's avatar Peter Leitzen

Add http status cop to api specs a-l

243 files inspected, 391 offenses detected, 391 offenses corrected
parent c5e575e5
...@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus: ...@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/requests/{groups,projects,repositories}/**/*' - 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb' - 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb' - 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-f]*.rb' - 'spec/requests/api/[a-l]*.rb'
- 'ee/spec/requests/api/[a-f]*.rb' - 'ee/spec/requests/api/[a-l]*.rb'
Style/MultilineWhenThen: Style/MultilineWhenThen:
Enabled: false Enabled: false
......
...@@ -23,7 +23,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do ...@@ -23,7 +23,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
it 'retrieves the designs if admin is logged in' do it 'retrieves the designs if admin is logged in' do
get api("/geo_replication/designs", admin) get api("/geo_replication/designs", 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/geo_designs', dir: 'ee') expect(response).to match_response_schema('public_api/v4/geo_designs', dir: 'ee')
end end
...@@ -38,7 +38,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do ...@@ -38,7 +38,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
get api("/geo_replication/designs", admin), params: { search: 'bla' } get api("/geo_replication/designs", admin), params: { search: 'bla' }
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/geo_designs', dir: 'ee') expect(response).to match_response_schema('public_api/v4/geo_designs', dir: 'ee')
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
expect(json_response.first['project_id']).to eq(project.id) expect(json_response.first['project_id']).to eq(project.id)
...@@ -47,7 +47,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do ...@@ -47,7 +47,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
it 'denies access if not admin' do it 'denies access if not admin' do
get api('/geo_replication/designs', user) get api('/geo_replication/designs', user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -59,14 +59,14 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do ...@@ -59,14 +59,14 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
put api("/geo_replication/designs/#{project.id}/resync", admin) put api("/geo_replication/designs/#{project.id}/resync", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(design_registry.reload.state).to eq('pending') expect(design_registry.reload.state).to eq('pending')
end end
it 'denies access if not admin' do it 'denies access if not admin' do
put api('/geo_replication/designs/1/resync', user) put api('/geo_replication/designs/1/resync', user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -77,7 +77,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do ...@@ -77,7 +77,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
post api("/geo_replication/designs/resync", admin) post api("/geo_replication/designs/resync", admin)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
::Geo::DesignRegistry.all.each do |registry| ::Geo::DesignRegistry.all.each do |registry|
expect(registry.state).to eq('pending') expect(registry.state).to eq('pending')
...@@ -87,7 +87,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do ...@@ -87,7 +87,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
it 'denies access if not admin' do it 'denies access if not admin' do
post api('/geo_replication/designs/resync', user) post api('/geo_replication/designs/resync', user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
This diff is collapsed.
...@@ -64,7 +64,7 @@ describe API::GroupClusters do ...@@ -64,7 +64,7 @@ describe API::GroupClusters do
end end
it 'responds with 201' do it 'responds with 201' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'allows multiple clusters to be associated to group' do it 'allows multiple clusters to be associated to group' do
......
...@@ -20,7 +20,7 @@ describe API::GroupMilestones do ...@@ -20,7 +20,7 @@ describe API::GroupMilestones do
it 'matches V4 EE-specific response schema for a list of issues' do it 'matches V4 EE-specific response schema for a list of issues' do
get api(issues_route, user) get api(issues_route, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/issues', dir: 'ee') expect(response).to match_response_schema('public_api/v4/issues', dir: 'ee')
end end
......
...@@ -58,7 +58,7 @@ describe API::Groups do ...@@ -58,7 +58,7 @@ describe API::Groups do
it 'returns 200' do it 'returns 200' do
get api("/groups/#{private_group.id}", user) get api("/groups/#{private_group.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -70,13 +70,13 @@ describe API::Groups do ...@@ -70,13 +70,13 @@ describe API::Groups do
it 'returns 404 for request from ip not in the range' do it 'returns 404 for request from ip not in the range' do
get api("/groups/#{private_group.id}", user) get api("/groups/#{private_group.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 200 for request from ip in the range' do it 'returns 200 for request from ip in the range' do
get api("/groups/#{private_group.id}", user), headers: { 'REMOTE_ADDR' => '192.168.0.0' } get api("/groups/#{private_group.id}", user), headers: { 'REMOTE_ADDR' => '192.168.0.0' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -118,7 +118,7 @@ describe API::Groups do ...@@ -118,7 +118,7 @@ describe API::Groups do
stub_licensed_features(custom_file_templates_for_namespace: false) stub_licensed_features(custom_file_templates_for_namespace: false)
expect { subject }.not_to change { group.reload.file_template_project_id } expect { subject }.not_to change { group.reload.file_template_project_id }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to have_key('file_template_project_id') expect(json_response).not_to have_key('file_template_project_id')
end end
...@@ -126,7 +126,7 @@ describe API::Groups do ...@@ -126,7 +126,7 @@ describe API::Groups do
stub_licensed_features(custom_file_templates_for_namespace: true) stub_licensed_features(custom_file_templates_for_namespace: true)
expect { subject }.to change { group.reload.file_template_project_id }.to(project.id) expect { subject }.to change { group.reload.file_template_project_id }.to(project.id)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['file_template_project_id']).to eq(project.id) expect(json_response['file_template_project_id']).to eq(project.id)
end end
end end
...@@ -142,7 +142,7 @@ describe API::Groups do ...@@ -142,7 +142,7 @@ describe API::Groups do
put api("/groups/#{group.id}", user), params: { shared_runners_minutes_limit: 133 } put api("/groups/#{group.id}", user), params: { shared_runners_minutes_limit: 133 }
end.not_to change { group.shared_runners_minutes_limit } end.not_to change { group.shared_runners_minutes_limit }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -153,7 +153,7 @@ describe API::Groups do ...@@ -153,7 +153,7 @@ describe API::Groups do
expect { subject }.to( expect { subject }.to(
change { group.reload.shared_runners_minutes_limit }.from(nil).to(133)) change { group.reload.shared_runners_minutes_limit }.from(nil).to(133))
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['shared_runners_minutes_limit']).to eq(133) expect(json_response['shared_runners_minutes_limit']).to eq(133)
end end
end end
...@@ -176,7 +176,7 @@ describe API::Groups do ...@@ -176,7 +176,7 @@ describe API::Groups do
post api("/groups", another_user), params: group post api("/groups", another_user), params: group
end.not_to change { Group.count } end.not_to change { Group.count }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -191,7 +191,7 @@ describe API::Groups do ...@@ -191,7 +191,7 @@ describe API::Groups do
created_group = Group.find(json_response['id']) created_group = Group.find(json_response['id'])
expect(created_group.shared_runners_minutes_limit).to eq(133) expect(created_group.shared_runners_minutes_limit).to eq(133)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['shared_runners_minutes_limit']).to eq(133) expect(json_response['shared_runners_minutes_limit']).to eq(133)
end end
end end
...@@ -213,7 +213,7 @@ describe API::Groups do ...@@ -213,7 +213,7 @@ describe API::Groups do
context 'when the group is ready to sync' do context 'when the group is ready to sync' do
it 'returns 202 Accepted' do it 'returns 202 Accepted' do
ldap_sync(group.id, user, :disable!) ldap_sync(group.id, user, :disable!)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
it 'queues a sync job' do it 'queues a sync job' do
...@@ -233,7 +233,7 @@ describe API::Groups do ...@@ -233,7 +233,7 @@ describe API::Groups do
it 'returns 202 Accepted' do it 'returns 202 Accepted' do
ldap_sync(group.id, user, :disable!) ldap_sync(group.id, user, :disable!)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
it 'does not queue a sync job' do it 'does not queue a sync job' do
...@@ -251,21 +251,21 @@ describe API::Groups do ...@@ -251,21 +251,21 @@ describe API::Groups do
non_existent_group_id = Group.maximum(:id).to_i + 1 non_existent_group_id = Group.maximum(:id).to_i + 1
ldap_sync(non_existent_group_id, user, :disable!) ldap_sync(non_existent_group_id, user, :disable!)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
context 'when authenticated as the admin' do context 'when authenticated as the admin' do
it 'returns 202 Accepted' do it 'returns 202 Accepted' do
ldap_sync(group.id, admin, :disable!) ldap_sync(group.id, admin, :disable!)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
context 'when authenticated as a non-owner user that can see the group' do context 'when authenticated as a non-owner user that can see the group' do
it 'returns 403' do it 'returns 403' do
ldap_sync(group.id, another_user, :disable!) ldap_sync(group.id, another_user, :disable!)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -273,7 +273,7 @@ describe API::Groups do ...@@ -273,7 +273,7 @@ describe API::Groups do
it 'returns 404' do it 'returns 404' do
ldap_sync(private_group.id, user, :disable!) ldap_sync(private_group.id, user, :disable!)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -286,7 +286,7 @@ describe API::Groups do ...@@ -286,7 +286,7 @@ describe API::Groups do
it 'returns 404 (same as CE would)' do it 'returns 404 (same as CE would)' do
ldap_sync(group.id, admin, :disable!) ldap_sync(group.id, admin, :disable!)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -362,7 +362,7 @@ describe API::Groups do ...@@ -362,7 +362,7 @@ describe API::Groups do
it 'returns 200 response' do it 'returns 200 response' do
get api(path, user) get api(path, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'includes the correct pagination headers' do it 'includes the correct pagination headers' do
...@@ -454,7 +454,7 @@ describe API::Groups do ...@@ -454,7 +454,7 @@ describe API::Groups do
it 'returns 200 response' do it 'returns 200 response' do
get api(path, user) get api(path, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
context 'response schema' do context 'response schema' do
...@@ -499,7 +499,7 @@ describe API::Groups do ...@@ -499,7 +499,7 @@ describe API::Groups do
expect { subject }.to change(GroupDestroyWorker.jobs, :size).by(1) expect { subject }.to change(GroupDestroyWorker.jobs, :size).by(1)
end end
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
...@@ -518,7 +518,7 @@ describe API::Groups do ...@@ -518,7 +518,7 @@ describe API::Groups do
subject subject
group.reload group.reload
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(group.marked_for_deletion_on).to eq(Date.today) expect(group.marked_for_deletion_on).to eq(Date.today)
expect(group.deleting_user).to eq(user) expect(group.deleting_user).to eq(user)
end end
...@@ -536,7 +536,7 @@ describe API::Groups do ...@@ -536,7 +536,7 @@ describe API::Groups do
it 'returns error' do it 'returns error' do
subject subject
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('error') expect(json_response['message']).to eq('error')
end end
end end
...@@ -579,7 +579,7 @@ describe API::Groups do ...@@ -579,7 +579,7 @@ describe API::Groups do
it 'restores the group to original state' do it 'restores the group to original state' do
subject subject
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['marked_for_deletion_on']).to be_falsey expect(json_response['marked_for_deletion_on']).to be_falsey
end end
end end
...@@ -592,7 +592,7 @@ describe API::Groups do ...@@ -592,7 +592,7 @@ describe API::Groups do
it 'returns error' do it 'returns error' do
subject subject
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('error') expect(json_response['message']).to eq('error')
end end
end end
...@@ -604,7 +604,7 @@ describe API::Groups do ...@@ -604,7 +604,7 @@ describe API::Groups do
it 'returns 403' do it 'returns 403' do
subject subject
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -617,7 +617,7 @@ describe API::Groups do ...@@ -617,7 +617,7 @@ describe API::Groups do
it 'returns 404' do it 'returns 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -16,7 +16,7 @@ describe API::IssueLinks do ...@@ -16,7 +16,7 @@ describe API::IssueLinks do
it 'returns 401' do it 'returns 401' do
get api("/projects/#{project.id}/issues/#{issue.iid}/links") get api("/projects/#{project.id}/issues/#{issue.iid}/links")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -27,7 +27,7 @@ describe API::IssueLinks do ...@@ -27,7 +27,7 @@ describe API::IssueLinks do
get api("/projects/#{project.id}/issues/#{issue.iid}/links", user) get api("/projects/#{project.id}/issues/#{issue.iid}/links", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(response).to match_response_schema('public_api/v4/issue_links') expect(response).to match_response_schema('public_api/v4/issue_links')
...@@ -43,7 +43,7 @@ describe API::IssueLinks do ...@@ -43,7 +43,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links"), post api("/projects/#{project.id}/issues/#{issue.iid}/links"),
params: { target_project_id: target_issue.project.id, target_issue_iid: target_issue.iid } params: { target_project_id: target_issue.project.id, target_issue_iid: target_issue.iid }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -55,7 +55,7 @@ describe API::IssueLinks do ...@@ -55,7 +55,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user), post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
params: { target_project_id: -1, target_issue_iid: target_issue.iid } params: { target_project_id: -1, target_issue_iid: target_issue.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
end end
...@@ -67,7 +67,7 @@ describe API::IssueLinks do ...@@ -67,7 +67,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user), post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
params: { target_project_id: target_project.id, target_issue_iid: 999 } params: { target_project_id: target_project.id, target_issue_iid: 999 }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
end end
...@@ -81,7 +81,7 @@ describe API::IssueLinks do ...@@ -81,7 +81,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user), post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
params: { target_project_id: unauthorized_project.id, target_issue_iid: target_issue.iid } params: { target_project_id: unauthorized_project.id, target_issue_iid: target_issue.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('No Issue found for given params') expect(json_response['message']).to eq('No Issue found for given params')
end end
end end
...@@ -94,7 +94,7 @@ describe API::IssueLinks do ...@@ -94,7 +94,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user), post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
params: { target_project_id: project.id, target_issue_iid: target_issue.iid } params: { target_project_id: project.id, target_issue_iid: target_issue.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
end end
...@@ -107,7 +107,7 @@ describe API::IssueLinks do ...@@ -107,7 +107,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user), post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
params: { target_project_id: project.id, target_issue_iid: target_issue.iid } params: { target_project_id: project.id, target_issue_iid: target_issue.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
end end
...@@ -134,7 +134,7 @@ describe API::IssueLinks do ...@@ -134,7 +134,7 @@ describe API::IssueLinks do
end end
def expect_link_response(link_type: 'relates_to') def expect_link_response(link_type: 'relates_to')
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/issue_link') expect(response).to match_response_schema('public_api/v4/issue_link')
expect(json_response['link_type']).to eq(link_type) expect(json_response['link_type']).to eq(link_type)
end end
...@@ -149,7 +149,7 @@ describe API::IssueLinks do ...@@ -149,7 +149,7 @@ describe API::IssueLinks do
delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}") delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -163,7 +163,7 @@ describe API::IssueLinks do ...@@ -163,7 +163,7 @@ describe API::IssueLinks do
delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}", user) delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.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('No Issue Link found') expect(json_response['message']).to eq('No Issue Link found')
end end
end end
...@@ -172,7 +172,7 @@ describe API::IssueLinks do ...@@ -172,7 +172,7 @@ describe API::IssueLinks do
it 'returns 404' do it 'returns 404' do
delete api("/projects/#{project.id}/issues/#{issue.iid}/links/999", user) delete api("/projects/#{project.id}/issues/#{issue.iid}/links/999", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
end end
...@@ -185,7 +185,7 @@ describe API::IssueLinks do ...@@ -185,7 +185,7 @@ describe API::IssueLinks do
delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}", user) delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
end end
...@@ -198,7 +198,7 @@ describe API::IssueLinks do ...@@ -198,7 +198,7 @@ describe API::IssueLinks do
delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}", user) delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.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/issue_link') expect(response).to match_response_schema('public_api/v4/issue_link')
end end
end end
......
...@@ -85,7 +85,7 @@ describe API::Issues, :mailer do ...@@ -85,7 +85,7 @@ describe API::Issues, :mailer do
it 'matches V4 response schema' do it 'matches V4 response schema' do
get api('/issues', user) get api('/issues', user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/issues', dir: 'ee') expect(response).to match_response_schema('public_api/v4/issues', dir: 'ee')
end end
...@@ -185,7 +185,7 @@ describe API::Issues, :mailer do ...@@ -185,7 +185,7 @@ describe API::Issues, :mailer do
it 'does not contain epic_iid in response' do it 'does not contain epic_iid in response' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(epic_issue_response_for(epic_issue)).not_to have_key('epic_iid') expect(epic_issue_response_for(epic_issue)).not_to have_key('epic_iid')
end end
end end
...@@ -212,7 +212,7 @@ describe API::Issues, :mailer do ...@@ -212,7 +212,7 @@ describe API::Issues, :mailer do
it 'does not contain epic_iid in response' do it 'does not contain epic_iid in response' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(epic_issue_response_for(epic_issue)).not_to have_key('epic_iid') expect(epic_issue_response_for(epic_issue)).not_to have_key('epic_iid')
end end
end end
...@@ -258,7 +258,7 @@ describe API::Issues, :mailer do ...@@ -258,7 +258,7 @@ describe API::Issues, :mailer do
it 'returns an error' do it 'returns an error' do
request request
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
end end
...@@ -273,7 +273,7 @@ describe API::Issues, :mailer do ...@@ -273,7 +273,7 @@ describe API::Issues, :mailer do
it 'does not set epic on issue' do it 'does not set epic on issue' do
request request
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
end end
...@@ -284,7 +284,7 @@ describe API::Issues, :mailer do ...@@ -284,7 +284,7 @@ describe API::Issues, :mailer do
it 'returns an error' do it 'returns an error' do
request request
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -306,7 +306,7 @@ describe API::Issues, :mailer do ...@@ -306,7 +306,7 @@ describe API::Issues, :mailer do
post api("/projects/#{project.id}/issues", user), post api("/projects/#{project.id}/issues", user),
params: { title: 'new issue', labels: 'label, label2', weight: 101, assignee_ids: [user2.id] } params: { title: 'new issue', labels: 'label, label2', weight: 101, assignee_ids: [user2.id] }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq('new issue') expect(json_response['title']).to eq('new issue')
expect(json_response['description']).to be_nil expect(json_response['description']).to be_nil
expect(json_response['labels']).to eq(%w(label label2)) expect(json_response['labels']).to eq(%w(label label2))
...@@ -325,7 +325,7 @@ describe API::Issues, :mailer do ...@@ -325,7 +325,7 @@ describe API::Issues, :mailer do
it 'updates an issue with no weight' do it 'updates an issue with no weight' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 101 } put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 101 }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['weight']).to eq(101) expect(json_response['weight']).to eq(101)
end end
...@@ -334,14 +334,14 @@ describe API::Issues, :mailer do ...@@ -334,14 +334,14 @@ describe API::Issues, :mailer do
put api("/projects/#{project.id}/issues/#{weighted_issue.iid}", user), params: { weight: nil } put api("/projects/#{project.id}/issues/#{weighted_issue.iid}", user), params: { weight: nil }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['weight']).to be_nil expect(json_response['weight']).to be_nil
end end
it 'returns 400 if weight is less than minimum weight' do it 'returns 400 if weight is less than minimum weight' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: -1 } put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: -1 }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['weight']).to be_present expect(json_response['message']['weight']).to be_present
end end
...@@ -360,7 +360,7 @@ describe API::Issues, :mailer do ...@@ -360,7 +360,7 @@ describe API::Issues, :mailer do
it 'adds a note when the weight is changed' do it 'adds a note when the weight is changed' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 9 } put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 9 }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['weight']).to eq(9) expect(json_response['weight']).to eq(9)
end end
...@@ -372,7 +372,7 @@ describe API::Issues, :mailer do ...@@ -372,7 +372,7 @@ describe API::Issues, :mailer do
it 'ignores the update' do it 'ignores the update' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 5 } put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 5 }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['weight']).to be_nil expect(json_response['weight']).to be_nil
expect(issue.reload.read_attribute(:weight)).to be_nil expect(issue.reload.read_attribute(:weight)).to be_nil
end end
......
...@@ -44,7 +44,7 @@ describe API::Jobs do ...@@ -44,7 +44,7 @@ describe API::Jobs do
it 'returns specific job artifacts' do it 'returns specific job artifacts' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h).to include(download_headers) expect(response.headers.to_h).to include(download_headers)
expect(response.body).to match_file(job.artifacts_file.file.file) expect(response.body).to match_file(job.artifacts_file.file.file)
end end
...@@ -57,7 +57,7 @@ describe API::Jobs do ...@@ -57,7 +57,7 @@ describe API::Jobs do
subject subject
expect(project).to be_private expect(project).to be_private
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -68,7 +68,7 @@ describe API::Jobs do ...@@ -68,7 +68,7 @@ describe API::Jobs do
it 'disallows access to the artifacts' do it 'disallows access to the artifacts' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -98,7 +98,7 @@ describe API::Jobs do ...@@ -98,7 +98,7 @@ describe API::Jobs do
it 'returns specific job artifacts', :sidekiq_might_not_need_inline do it 'returns specific job artifacts', :sidekiq_might_not_need_inline do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h).to include(download_headers) expect(response.headers.to_h).to include(download_headers)
expect(response.body).to match_file(job.artifacts_file.file.file) expect(response.body).to match_file(job.artifacts_file.file.file)
end end
...@@ -128,7 +128,7 @@ describe API::Jobs do ...@@ -128,7 +128,7 @@ describe API::Jobs do
it 'does not allow to see that artfiact is present' do it 'does not allow to see that artfiact is present' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -58,7 +58,7 @@ describe 'GraphQL' do ...@@ -58,7 +58,7 @@ describe 'GraphQL' do
it 'returns an error' do it 'returns an error' do
post_graphql(query, variables: "This is not JSON") post_graphql(query, variables: "This is not JSON")
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['errors'].first['message']).not_to be_nil expect(json_response['errors'].first['message']).not_to be_nil
end end
end end
...@@ -114,7 +114,7 @@ describe 'GraphQL' do ...@@ -114,7 +114,7 @@ describe 'GraphQL' do
post_graphql(query, headers: { 'PRIVATE-TOKEN' => token.token }) post_graphql(query, headers: { 'PRIVATE-TOKEN' => token.token })
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(graphql_data['echo']).to eq('nil says: Hello world') expect(graphql_data['echo']).to eq('nil says: Hello world')
end end
......
...@@ -50,7 +50,7 @@ describe API::GroupBoards do ...@@ -50,7 +50,7 @@ describe API::GroupBoards do
post api(url, user), params: { label_id: project_label.id } post api(url, user), params: { label_id: project_label.id }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -26,7 +26,7 @@ describe API::GroupClusters do ...@@ -26,7 +26,7 @@ describe API::GroupClusters do
it 'responds with 403' do it 'responds with 403' do
get api("/groups/#{group.id}/clusters", developer_user) get api("/groups/#{group.id}/clusters", developer_user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -36,7 +36,7 @@ describe API::GroupClusters do ...@@ -36,7 +36,7 @@ describe API::GroupClusters do
end end
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'includes pagination headers' do it 'includes pagination headers' do
...@@ -70,7 +70,7 @@ describe API::GroupClusters do ...@@ -70,7 +70,7 @@ describe API::GroupClusters do
it 'responds with 403' do it 'responds with 403' do
get api("/groups/#{group.id}/clusters/#{cluster_id}", developer_user) get api("/groups/#{group.id}/clusters/#{cluster_id}", developer_user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -140,7 +140,7 @@ describe API::GroupClusters do ...@@ -140,7 +140,7 @@ describe API::GroupClusters do
let(:cluster_id) { 123 } let(:cluster_id) { 123 }
it 'returns 404' do it 'returns 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -179,7 +179,7 @@ describe API::GroupClusters do ...@@ -179,7 +179,7 @@ describe API::GroupClusters do
it 'responds with 403' do it 'responds with 403' do
post api("/groups/#{group.id}/clusters/user", developer_user), params: cluster_params post api("/groups/#{group.id}/clusters/user", developer_user), params: cluster_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -190,7 +190,7 @@ describe API::GroupClusters do ...@@ -190,7 +190,7 @@ describe API::GroupClusters do
context 'with valid params' do context 'with valid params' do
it 'responds with 201' do it 'responds with 201' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'creates a new Cluster::Cluster' do it 'creates a new Cluster::Cluster' do
...@@ -238,7 +238,7 @@ describe API::GroupClusters do ...@@ -238,7 +238,7 @@ describe API::GroupClusters do
let(:api_url) { 'invalid_api_url' } let(:api_url) { 'invalid_api_url' }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not create a new Clusters::Cluster' do it 'does not create a new Clusters::Cluster' do
...@@ -260,7 +260,7 @@ describe API::GroupClusters do ...@@ -260,7 +260,7 @@ describe API::GroupClusters do
end end
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters')) expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters'))
end end
end end
...@@ -271,7 +271,7 @@ describe API::GroupClusters do ...@@ -271,7 +271,7 @@ describe API::GroupClusters do
end end
it 'responds with 403' do it 'responds with 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
...@@ -305,7 +305,7 @@ describe API::GroupClusters do ...@@ -305,7 +305,7 @@ describe API::GroupClusters do
it 'responds with 403' do it 'responds with 403' do
put api("/groups/#{group.id}/clusters/#{cluster.id}", developer_user), params: update_params put api("/groups/#{group.id}/clusters/#{cluster.id}", developer_user), params: update_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -320,7 +320,7 @@ describe API::GroupClusters do ...@@ -320,7 +320,7 @@ describe API::GroupClusters do
context 'with valid params' do context 'with valid params' do
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'updates cluster attributes' do it 'updates cluster attributes' do
...@@ -333,7 +333,7 @@ describe API::GroupClusters do ...@@ -333,7 +333,7 @@ describe API::GroupClusters do
let(:domain) { 'invalid domain' } let(:domain) { 'invalid domain' }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not update cluster attributes' do it 'does not update cluster attributes' do
...@@ -350,7 +350,7 @@ describe API::GroupClusters do ...@@ -350,7 +350,7 @@ describe API::GroupClusters do
let(:management_project_id) { create(:project).id } let(:management_project_id) { create(:project).id }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns validation errors' do it 'returns validation errors' do
...@@ -368,7 +368,7 @@ describe API::GroupClusters do ...@@ -368,7 +368,7 @@ describe API::GroupClusters do
end end
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns validation error' do it 'returns validation error' do
...@@ -380,7 +380,7 @@ describe API::GroupClusters do ...@@ -380,7 +380,7 @@ describe API::GroupClusters do
let(:domain) { 'new-domain.com' } let(:domain) { 'new-domain.com' }
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -408,7 +408,7 @@ describe API::GroupClusters do ...@@ -408,7 +408,7 @@ describe API::GroupClusters do
end end
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'updates platform kubernetes attributes' do it 'updates platform kubernetes attributes' do
...@@ -424,7 +424,7 @@ describe API::GroupClusters do ...@@ -424,7 +424,7 @@ describe API::GroupClusters do
let(:cluster) { create(:cluster, :group, :provided_by_user) } let(:cluster) { create(:cluster, :group, :provided_by_user) }
it 'responds with 404' do it 'responds with 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -442,7 +442,7 @@ describe API::GroupClusters do ...@@ -442,7 +442,7 @@ describe API::GroupClusters do
it 'responds with 403' do it 'responds with 403' do
delete api("/groups/#{group.id}/clusters/#{cluster.id}", developer_user), params: cluster_params delete api("/groups/#{group.id}/clusters/#{cluster.id}", developer_user), params: cluster_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -452,7 +452,7 @@ describe API::GroupClusters do ...@@ -452,7 +452,7 @@ describe API::GroupClusters do
end end
it 'responds with 204' do it 'responds with 204' do
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'deletes the cluster' do it 'deletes the cluster' do
...@@ -463,7 +463,7 @@ describe API::GroupClusters do ...@@ -463,7 +463,7 @@ describe API::GroupClusters do
let(:cluster) { create(:cluster, :group, :provided_by_user) } let(:cluster) { create(:cluster, :group, :provided_by_user) }
it 'responds with 404' do it 'responds with 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -44,7 +44,7 @@ describe API::GroupExport do ...@@ -44,7 +44,7 @@ describe API::GroupExport do
it 'downloads exported group archive' do it 'downloads exported group archive' do
get api(download_path, user) get api(download_path, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
context 'when export_file.file does not exist' do context 'when export_file.file does not exist' do
...@@ -57,7 +57,7 @@ describe API::GroupExport do ...@@ -57,7 +57,7 @@ describe API::GroupExport do
it 'returns 404' do it 'returns 404' do
get api(download_path, user) get api(download_path, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -66,7 +66,7 @@ describe API::GroupExport do ...@@ -66,7 +66,7 @@ describe API::GroupExport do
it 'returns 404' do it 'returns 404' do
get api(download_path, user) get api(download_path, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -79,7 +79,7 @@ describe API::GroupExport do ...@@ -79,7 +79,7 @@ describe API::GroupExport do
it 'responds with 404 Not Found' do it 'responds with 404 Not Found' do
get api(download_path, user) get api(download_path, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -98,7 +98,7 @@ describe API::GroupExport do ...@@ -98,7 +98,7 @@ describe API::GroupExport do
it 'accepts download' do it 'accepts download' do
post api(path, user) post api(path, user)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
...@@ -110,7 +110,7 @@ describe API::GroupExport do ...@@ -110,7 +110,7 @@ describe API::GroupExport do
it 'forbids the request' do it 'forbids the request' do
post api(path, user) post api(path, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -123,7 +123,7 @@ describe API::GroupExport do ...@@ -123,7 +123,7 @@ describe API::GroupExport do
it 'responds with 404 Not Found' do it 'responds with 404 Not Found' do
post api(path, user) post api(path, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -42,7 +42,7 @@ describe API::GroupImport do ...@@ -42,7 +42,7 @@ describe API::GroupImport do
it 'creates new group and accepts request' do it 'creates new group and accepts request' do
subject subject
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
it 'creates private group' do it 'creates private group' do
...@@ -63,7 +63,7 @@ describe API::GroupImport do ...@@ -63,7 +63,7 @@ describe API::GroupImport do
subject subject
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(group.children.count).to eq(1) expect(group.children.count).to eq(1)
end end
...@@ -81,7 +81,7 @@ describe API::GroupImport do ...@@ -81,7 +81,7 @@ describe API::GroupImport do
subject subject
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(public_parent_group.children.first.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC) expect(public_parent_group.children.first.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
end end
...@@ -90,7 +90,7 @@ describe API::GroupImport do ...@@ -90,7 +90,7 @@ describe API::GroupImport do
subject subject
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
expect(internal_parent_group.children.first.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) expect(internal_parent_group.children.first.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL)
end end
end end
...@@ -101,7 +101,7 @@ describe API::GroupImport do ...@@ -101,7 +101,7 @@ describe API::GroupImport do
expect { subject }.not_to change { Group.count } expect { subject }.not_to change { Group.count }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Group Not Found') expect(json_response['message']).to eq('404 Group Not Found')
end end
...@@ -111,7 +111,7 @@ describe API::GroupImport do ...@@ -111,7 +111,7 @@ describe API::GroupImport do
subject subject
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
end end
...@@ -128,7 +128,7 @@ describe API::GroupImport do ...@@ -128,7 +128,7 @@ describe API::GroupImport do
it 'returns 400 HTTP status' do it 'returns 400 HTTP status' do
subject subject
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -139,7 +139,7 @@ describe API::GroupImport do ...@@ -139,7 +139,7 @@ describe API::GroupImport do
it 'forbids the request' do it 'forbids the request' do
subject subject
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -154,7 +154,7 @@ describe API::GroupImport do ...@@ -154,7 +154,7 @@ describe API::GroupImport do
post api('/groups/import', user), params: params, headers: workhorse_header post api('/groups/import', user), params: params, headers: workhorse_header
end.not_to change { Group.count }.from(1) end.not_to change { Group.count }.from(1)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq(error_message) expect(json_response['error']).to eq(error_message)
end end
end end
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ describe API::GroupVariables do ...@@ -17,7 +17,7 @@ describe API::GroupVariables do
it 'returns group variables' do it 'returns group variables' do
get api("/groups/#{group.id}/variables", user) get api("/groups/#{group.id}/variables", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a(Array) expect(json_response).to be_a(Array)
end end
end end
...@@ -26,7 +26,7 @@ describe API::GroupVariables do ...@@ -26,7 +26,7 @@ describe API::GroupVariables do
it 'does not return group variables' do it 'does not return group variables' do
get api("/groups/#{group.id}/variables", user) get api("/groups/#{group.id}/variables", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -34,7 +34,7 @@ describe API::GroupVariables do ...@@ -34,7 +34,7 @@ describe API::GroupVariables do
it 'does not return group variables' do it 'does not return group variables' do
get api("/groups/#{group.id}/variables") get api("/groups/#{group.id}/variables")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -50,7 +50,7 @@ describe API::GroupVariables do ...@@ -50,7 +50,7 @@ describe API::GroupVariables do
it 'returns group variable details' do it 'returns group variable details' do
get api("/groups/#{group.id}/variables/#{variable.key}", user) get api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['value']).to eq(variable.value) expect(json_response['value']).to eq(variable.value)
expect(json_response['protected']).to eq(variable.protected?) expect(json_response['protected']).to eq(variable.protected?)
expect(json_response['variable_type']).to eq(variable.variable_type) expect(json_response['variable_type']).to eq(variable.variable_type)
...@@ -59,7 +59,7 @@ describe API::GroupVariables do ...@@ -59,7 +59,7 @@ describe API::GroupVariables do
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do
get api("/groups/#{group.id}/variables/non_existing_variable", user) get api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -67,7 +67,7 @@ describe API::GroupVariables do ...@@ -67,7 +67,7 @@ describe API::GroupVariables do
it 'does not return group variable details' do it 'does not return group variable details' do
get api("/groups/#{group.id}/variables/#{variable.key}", user) get api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -75,7 +75,7 @@ describe API::GroupVariables do ...@@ -75,7 +75,7 @@ describe API::GroupVariables do
it 'does not return group variable details' do it 'does not return group variable details' do
get api("/groups/#{group.id}/variables/#{variable.key}") get api("/groups/#{group.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -93,7 +93,7 @@ describe API::GroupVariables do ...@@ -93,7 +93,7 @@ describe API::GroupVariables do
post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, masked: true } post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, masked: true }
end.to change {group.variables.count}.by(1) end.to change {group.variables.count}.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('PROTECTED_VALUE_2') expect(json_response['value']).to eq('PROTECTED_VALUE_2')
expect(json_response['protected']).to be_truthy expect(json_response['protected']).to be_truthy
...@@ -106,7 +106,7 @@ describe API::GroupVariables do ...@@ -106,7 +106,7 @@ describe API::GroupVariables do
post api("/groups/#{group.id}/variables", user), params: { variable_type: 'file', key: 'TEST_VARIABLE_2', value: 'VALUE_2' } post api("/groups/#{group.id}/variables", user), params: { variable_type: 'file', key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
end.to change {group.variables.count}.by(1) end.to change {group.variables.count}.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('VALUE_2') expect(json_response['value']).to eq('VALUE_2')
expect(json_response['protected']).to be_falsey expect(json_response['protected']).to be_falsey
...@@ -119,7 +119,7 @@ describe API::GroupVariables do ...@@ -119,7 +119,7 @@ describe API::GroupVariables do
post api("/groups/#{group.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' } post api("/groups/#{group.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
end.to change {group.variables.count}.by(0) end.to change {group.variables.count}.by(0)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -127,7 +127,7 @@ describe API::GroupVariables do ...@@ -127,7 +127,7 @@ describe API::GroupVariables do
it 'does not create variable' do it 'does not create variable' do
post api("/groups/#{group.id}/variables", user) post api("/groups/#{group.id}/variables", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -135,7 +135,7 @@ describe API::GroupVariables do ...@@ -135,7 +135,7 @@ describe API::GroupVariables do
it 'does not create variable' do it 'does not create variable' do
post api("/groups/#{group.id}/variables") post api("/groups/#{group.id}/variables")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -156,7 +156,7 @@ describe API::GroupVariables do ...@@ -156,7 +156,7 @@ describe API::GroupVariables do
updated_variable = group.variables.reload.first updated_variable = group.variables.reload.first
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(value_before).to eq(variable.value) expect(value_before).to eq(variable.value)
expect(updated_variable.value).to eq('VALUE_1_UP') expect(updated_variable.value).to eq('VALUE_1_UP')
expect(updated_variable).to be_protected expect(updated_variable).to be_protected
...@@ -167,7 +167,7 @@ describe API::GroupVariables do ...@@ -167,7 +167,7 @@ describe API::GroupVariables do
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do
put api("/groups/#{group.id}/variables/non_existing_variable", user) put api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -175,7 +175,7 @@ describe API::GroupVariables do ...@@ -175,7 +175,7 @@ describe API::GroupVariables do
it 'does not update variable' do it 'does not update variable' do
put api("/groups/#{group.id}/variables/#{variable.key}", user) put api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -183,7 +183,7 @@ describe API::GroupVariables do ...@@ -183,7 +183,7 @@ describe API::GroupVariables do
it 'does not update variable' do it 'does not update variable' do
put api("/groups/#{group.id}/variables/#{variable.key}") put api("/groups/#{group.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -200,14 +200,14 @@ describe API::GroupVariables do ...@@ -200,14 +200,14 @@ describe API::GroupVariables do
expect do expect do
delete api("/groups/#{group.id}/variables/#{variable.key}", user) delete api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change {group.variables.count}.by(-1) end.to change {group.variables.count}.by(-1)
end end
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do
delete api("/groups/#{group.id}/variables/non_existing_variable", user) delete api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -219,7 +219,7 @@ describe API::GroupVariables do ...@@ -219,7 +219,7 @@ describe API::GroupVariables do
it 'does not delete variable' do it 'does not delete variable' do
delete api("/groups/#{group.id}/variables/#{variable.key}", user) delete api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -227,7 +227,7 @@ describe API::GroupVariables do ...@@ -227,7 +227,7 @@ describe API::GroupVariables do
it 'does not delete variable' do it 'does not delete variable' do
delete api("/groups/#{group.id}/variables/#{variable.key}") delete api("/groups/#{group.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
......
This diff is collapsed.
...@@ -269,7 +269,7 @@ describe API::Helpers do ...@@ -269,7 +269,7 @@ describe API::Helpers do
# The 500 status is expected as we're testing a case where an exception # The 500 status is expected as we're testing a case where an exception
# is raised, but Grape shouldn't raise an additional exception # is raised, but Grape shouldn't raise an additional exception
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response['message']).not_to include("undefined local variable or method `request'") expect(json_response['message']).not_to include("undefined local variable or method `request'")
expect(json_response['message']).to start_with("\nRuntimeError (Runtime Error!):") expect(json_response['message']).to start_with("\nRuntimeError (Runtime Error!):")
end end
......
...@@ -36,7 +36,7 @@ describe API::ImportGithub do ...@@ -36,7 +36,7 @@ describe API::ImportGithub do
personal_access_token: token, personal_access_token: token,
repo_id: 1234 repo_id: 1234
} }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response).to be_a Hash expect(json_response).to be_a Hash
expect(json_response['name']).to eq(project.name) expect(json_response['name']).to eq(project.name)
end end
...@@ -50,7 +50,7 @@ describe API::ImportGithub do ...@@ -50,7 +50,7 @@ describe API::ImportGithub do
repo_id: 1234 repo_id: 1234
} }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
end end
This diff is collapsed.
...@@ -12,21 +12,21 @@ describe API::Keys do ...@@ -12,21 +12,21 @@ describe API::Keys do
context 'when unauthenticated' do context 'when unauthenticated' do
it 'returns authentication error' do it 'returns authentication error' do
get api("/keys/#{key.id}") get api("/keys/#{key.id}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
context 'when authenticated' do context 'when authenticated' do
it 'returns 404 for non-existing key' do it 'returns 404 for non-existing key' do
get api('/keys/0', admin) get api('/keys/0', 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 Not found') expect(json_response['message']).to eq('404 Not found')
end end
it 'returns single ssh key with user information' do it 'returns single ssh key with user information' do
user.keys << key user.keys << key
get api("/keys/#{key.id}", admin) get api("/keys/#{key.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(key.title) expect(json_response['title']).to eq(key.title)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username) expect(json_response['user']['username']).to eq(user.username)
...@@ -44,27 +44,27 @@ describe API::Keys do ...@@ -44,27 +44,27 @@ describe API::Keys do
it 'returns authentication error' do it 'returns authentication error' do
get api("/keys?fingerprint=#{key.fingerprint}") get api("/keys?fingerprint=#{key.fingerprint}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'returns authentication error when authenticated as user' do it 'returns authentication error when authenticated as user' do
get api("/keys?fingerprint=#{key.fingerprint}", user) get api("/keys?fingerprint=#{key.fingerprint}", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
context 'when authenticated as admin' do context 'when authenticated as admin' do
it 'returns 404 for non-existing SSH md5 fingerprint' do it 'returns 404 for non-existing SSH md5 fingerprint' do
get api("/keys?fingerprint=11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11", admin) get api("/keys?fingerprint=11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11", 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 Key Not Found') expect(json_response['message']).to eq('404 Key Not Found')
end end
it 'returns 404 for non-existing SSH sha256 fingerprint' do it 'returns 404 for non-existing SSH sha256 fingerprint' do
get api("/keys?fingerprint=#{URI.encode_www_form_component("SHA256:nUhzNyftwADy8AH3wFY31tAKs7HufskYTte2aXo1lCg")}", admin) get api("/keys?fingerprint=#{URI.encode_www_form_component("SHA256:nUhzNyftwADy8AH3wFY31tAKs7HufskYTte2aXo1lCg")}", 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 Key Not Found') expect(json_response['message']).to eq('404 Key Not Found')
end end
...@@ -73,7 +73,7 @@ describe API::Keys do ...@@ -73,7 +73,7 @@ describe API::Keys do
get api("/keys?fingerprint=#{key.fingerprint}", admin) get api("/keys?fingerprint=#{key.fingerprint}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(key.title) expect(json_response['title']).to eq(key.title)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username) expect(json_response['user']['username']).to eq(user.username)
...@@ -84,7 +84,7 @@ describe API::Keys do ...@@ -84,7 +84,7 @@ describe API::Keys do
get api("/keys?fingerprint=#{URI.encode_www_form_component("SHA256:" + key.fingerprint_sha256)}", admin) get api("/keys?fingerprint=#{URI.encode_www_form_component("SHA256:" + key.fingerprint_sha256)}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(key.title) expect(json_response['title']).to eq(key.title)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username) expect(json_response['user']['username']).to eq(user.username)
...@@ -95,7 +95,7 @@ describe API::Keys do ...@@ -95,7 +95,7 @@ describe API::Keys do
get api("/keys?fingerprint=#{URI.encode_www_form_component("sha256:" + key.fingerprint_sha256)}", admin) get api("/keys?fingerprint=#{URI.encode_www_form_component("sha256:" + key.fingerprint_sha256)}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(key.title) expect(json_response['title']).to eq(key.title)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username) expect(json_response['user']['username']).to eq(user.username)
...@@ -125,7 +125,7 @@ describe API::Keys do ...@@ -125,7 +125,7 @@ describe API::Keys do
get api("/keys?fingerprint=#{URI.encode_www_form_component("SHA256:" + deploy_key.fingerprint_sha256)}", admin) get api("/keys?fingerprint=#{URI.encode_www_form_component("SHA256:" + deploy_key.fingerprint_sha256)}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(deploy_key.title) expect(json_response['title']).to eq(deploy_key.title)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ describe API::Lint do ...@@ -12,7 +12,7 @@ describe API::Lint do
it 'passes validation' do it 'passes validation' do
post api('/ci/lint'), params: { content: yaml_content } post api('/ci/lint'), params: { content: yaml_content }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash expect(json_response).to be_an Hash
expect(json_response['status']).to eq('valid') expect(json_response['status']).to eq('valid')
expect(json_response['errors']).to eq([]) expect(json_response['errors']).to eq([])
...@@ -23,7 +23,7 @@ describe API::Lint do ...@@ -23,7 +23,7 @@ describe API::Lint do
it 'responds with errors about invalid syntax' do it 'responds with errors about invalid syntax' do
post api('/ci/lint'), params: { content: 'invalid content' } post api('/ci/lint'), params: { content: 'invalid content' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('invalid') expect(json_response['status']).to eq('invalid')
expect(json_response['errors']).to eq(['Invalid configuration format']) expect(json_response['errors']).to eq(['Invalid configuration format'])
end end
...@@ -31,7 +31,7 @@ describe API::Lint do ...@@ -31,7 +31,7 @@ describe API::Lint do
it "responds with errors about invalid configuration" do it "responds with errors about invalid configuration" do
post api('/ci/lint'), params: { content: '{ image: "ruby:2.1", services: ["postgres"] }' } post api('/ci/lint'), params: { content: '{ image: "ruby:2.1", services: ["postgres"] }' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('invalid') expect(json_response['status']).to eq('invalid')
expect(json_response['errors']).to eq(['jobs config should contain at least one visible job']) expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
end end
...@@ -41,7 +41,7 @@ describe API::Lint do ...@@ -41,7 +41,7 @@ describe API::Lint do
it 'responds with validation error about missing content' do it 'responds with validation error about missing content' do
post api('/ci/lint') post api('/ci/lint')
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('content is missing') expect(json_response['error']).to eq('content is missing')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment