Commit e11222ce authored by Imre Farkas's avatar Imre Farkas

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

Add http status cop to api specs a-l

See merge request gitlab-org/gitlab!25170
parents 272d02bf 55c6405b
......@@ -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-f]*.rb'
- 'ee/spec/requests/api/[a-f]*.rb'
- 'spec/requests/api/[a-l]*.rb'
- 'ee/spec/requests/api/[a-l]*.rb'
Style/MultilineWhenThen:
Enabled: false
......
......@@ -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
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')
end
......@@ -38,7 +38,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
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(json_response.size).to eq(1)
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
it 'denies access if not admin' do
get api('/geo_replication/designs', user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -59,14 +59,14 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
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')
end
it 'denies access if not admin' do
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
......@@ -77,7 +77,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
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|
expect(registry.state).to eq('pending')
......@@ -87,7 +87,7 @@ describe API::GeoReplication, :request_store, :geo, :geo_fdw, api: true do
it 'denies access if not admin' do
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
This diff is collapsed.
......@@ -64,7 +64,7 @@ describe API::GroupClusters 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 group' do
......
......@@ -20,7 +20,7 @@ describe API::GroupMilestones 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
......
......@@ -58,7 +58,7 @@ describe API::Groups do
it 'returns 200' do
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
......@@ -70,13 +70,13 @@ describe API::Groups do
it 'returns 404 for request from ip not in the range' do
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
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' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -118,7 +118,7 @@ describe API::Groups do
stub_licensed_features(custom_file_templates_for_namespace: false)
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')
end
......@@ -126,7 +126,7 @@ describe API::Groups do
stub_licensed_features(custom_file_templates_for_namespace: true)
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)
end
end
......@@ -142,7 +142,7 @@ describe API::Groups do
put api("/groups/#{group.id}", user), params: { shared_runners_minutes_limit: 133 }
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
......@@ -153,7 +153,7 @@ describe API::Groups do
expect { subject }.to(
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)
end
end
......@@ -176,7 +176,7 @@ describe API::Groups do
post api("/groups", another_user), params: group
end.not_to change { Group.count }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -191,7 +191,7 @@ describe API::Groups do
created_group = Group.find(json_response['id'])
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)
end
end
......@@ -213,7 +213,7 @@ describe API::Groups do
context 'when the group is ready to sync' do
it 'returns 202 Accepted' do
ldap_sync(group.id, user, :disable!)
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
end
it 'queues a sync job' do
......@@ -233,7 +233,7 @@ describe API::Groups do
it 'returns 202 Accepted' do
ldap_sync(group.id, user, :disable!)
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
end
it 'does not queue a sync job' do
......@@ -251,21 +251,21 @@ describe API::Groups do
non_existent_group_id = Group.maximum(:id).to_i + 1
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
context 'when authenticated as the admin' do
it 'returns 202 Accepted' do
ldap_sync(group.id, admin, :disable!)
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
end
end
context 'when authenticated as a non-owner user that can see the group' do
it 'returns 403' do
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
......@@ -273,7 +273,7 @@ describe API::Groups do
it 'returns 404' do
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
......@@ -286,7 +286,7 @@ describe API::Groups do
it 'returns 404 (same as CE would)' do
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
......@@ -362,7 +362,7 @@ describe API::Groups do
it 'returns 200 response' do
get api(path, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'includes the correct pagination headers' do
......@@ -454,7 +454,7 @@ describe API::Groups do
it 'returns 200 response' do
get api(path, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'response schema' do
......@@ -499,7 +499,7 @@ describe API::Groups do
expect { subject }.to change(GroupDestroyWorker.jobs, :size).by(1)
end
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
end
end
......@@ -518,7 +518,7 @@ describe API::Groups do
subject
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.deleting_user).to eq(user)
end
......@@ -536,7 +536,7 @@ describe API::Groups do
it 'returns error' do
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')
end
end
......@@ -579,7 +579,7 @@ describe API::Groups do
it 'restores the group to original state' do
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
end
end
......@@ -592,7 +592,7 @@ describe API::Groups do
it 'returns error' do
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')
end
end
......@@ -604,7 +604,7 @@ describe API::Groups 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
......@@ -617,7 +617,7 @@ describe API::Groups do
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -16,7 +16,7 @@ describe API::IssueLinks do
it 'returns 401' do
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
......@@ -27,7 +27,7 @@ describe API::IssueLinks do
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.length).to eq(1)
expect(response).to match_response_schema('public_api/v4/issue_links')
......@@ -43,7 +43,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links"),
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
......@@ -55,7 +55,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
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')
end
end
......@@ -67,7 +67,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
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')
end
end
......@@ -81,7 +81,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
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')
end
end
......@@ -94,7 +94,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
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')
end
end
......@@ -107,7 +107,7 @@ describe API::IssueLinks do
post api("/projects/#{project.id}/issues/#{issue.iid}/links", user),
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')
end
end
......@@ -134,7 +134,7 @@ describe API::IssueLinks do
end
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(json_response['link_type']).to eq(link_type)
end
......@@ -149,7 +149,7 @@ describe API::IssueLinks do
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
......@@ -163,7 +163,7 @@ describe API::IssueLinks do
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')
end
end
......@@ -172,7 +172,7 @@ describe API::IssueLinks do
it 'returns 404' do
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')
end
end
......@@ -185,7 +185,7 @@ describe API::IssueLinks do
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')
end
end
......@@ -198,7 +198,7 @@ describe API::IssueLinks do
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')
end
end
......
......@@ -85,7 +85,7 @@ describe API::Issues, :mailer do
it 'matches V4 response schema' do
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')
end
......@@ -185,7 +185,7 @@ describe API::Issues, :mailer do
it 'does not contain epic_iid in response' do
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')
end
end
......@@ -212,7 +212,7 @@ describe API::Issues, :mailer do
it 'does not contain epic_iid in response' do
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')
end
end
......@@ -258,7 +258,7 @@ describe API::Issues, :mailer do
it 'returns an error' do
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')
end
end
......@@ -273,7 +273,7 @@ describe API::Issues, :mailer do
it 'does not set epic on issue' do
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')
end
end
......@@ -284,7 +284,7 @@ describe API::Issues, :mailer do
it 'returns an error' do
request
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -306,7 +306,7 @@ describe API::Issues, :mailer do
post api("/projects/#{project.id}/issues", user),
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['description']).to be_nil
expect(json_response['labels']).to eq(%w(label label2))
......@@ -325,7 +325,7 @@ describe API::Issues, :mailer do
it 'updates an issue with no weight' do
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)
end
......@@ -334,14 +334,14 @@ describe API::Issues, :mailer do
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
end
it 'returns 400 if weight is less than minimum weight' do
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
end
......@@ -360,7 +360,7 @@ describe API::Issues, :mailer do
it 'adds a note when the weight is changed' do
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)
end
......@@ -372,7 +372,7 @@ describe API::Issues, :mailer do
it 'ignores the update' do
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(issue.reload.read_attribute(:weight)).to be_nil
end
......
......@@ -44,7 +44,7 @@ describe API::Jobs do
it 'returns specific job artifacts' do
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.body).to match_file(job.artifacts_file.file.file)
end
......@@ -57,7 +57,7 @@ describe API::Jobs do
subject
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
......@@ -68,7 +68,7 @@ describe API::Jobs do
it 'disallows access to the artifacts' do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -98,7 +98,7 @@ describe API::Jobs do
it 'returns specific job artifacts', :sidekiq_might_not_need_inline do
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.body).to match_file(job.artifacts_file.file.file)
end
......@@ -128,7 +128,7 @@ describe API::Jobs do
it 'does not allow to see that artfiact is present' do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -58,7 +58,7 @@ describe 'GraphQL' do
it 'returns an error' do
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
end
end
......@@ -114,7 +114,7 @@ describe 'GraphQL' do
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')
end
......
......@@ -50,7 +50,7 @@ describe API::GroupBoards do
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
......@@ -26,7 +26,7 @@ describe API::GroupClusters do
it 'responds with 403' do
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
......@@ -36,7 +36,7 @@ describe API::GroupClusters 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
......@@ -70,7 +70,7 @@ describe API::GroupClusters do
it 'responds with 403' do
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
......@@ -140,7 +140,7 @@ describe API::GroupClusters 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
......@@ -179,7 +179,7 @@ describe API::GroupClusters do
it 'responds with 403' do
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
......@@ -190,7 +190,7 @@ describe API::GroupClusters 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
......@@ -238,7 +238,7 @@ describe API::GroupClusters do
let(:api_url) { 'invalid_api_url' }
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
......@@ -260,7 +260,7 @@ describe API::GroupClusters 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
end
......@@ -271,7 +271,7 @@ describe API::GroupClusters 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
......@@ -305,7 +305,7 @@ describe API::GroupClusters do
it 'responds with 403' do
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
......@@ -320,7 +320,7 @@ describe API::GroupClusters 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
......@@ -333,7 +333,7 @@ describe API::GroupClusters do
let(:domain) { 'invalid domain' }
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
......@@ -350,7 +350,7 @@ describe API::GroupClusters 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
......@@ -368,7 +368,7 @@ describe API::GroupClusters 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
......@@ -380,7 +380,7 @@ describe API::GroupClusters do
let(:domain) { 'new-domain.com' }
it 'responds with 200' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -408,7 +408,7 @@ describe API::GroupClusters 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
......@@ -424,7 +424,7 @@ describe API::GroupClusters do
let(:cluster) { create(:cluster, :group, :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
......@@ -442,7 +442,7 @@ describe API::GroupClusters do
it 'responds with 403' do
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
......@@ -452,7 +452,7 @@ describe API::GroupClusters 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
......@@ -463,7 +463,7 @@ describe API::GroupClusters do
let(:cluster) { create(:cluster, :group, :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
......
......@@ -44,7 +44,7 @@ describe API::GroupExport do
it 'downloads exported group archive' do
get api(download_path, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'when export_file.file does not exist' do
......@@ -57,7 +57,7 @@ describe API::GroupExport do
it 'returns 404' do
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
......@@ -66,7 +66,7 @@ describe API::GroupExport do
it 'returns 404' do
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
......@@ -79,7 +79,7 @@ describe API::GroupExport do
it 'responds with 404 Not Found' do
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
......@@ -98,7 +98,7 @@ describe API::GroupExport do
it 'accepts download' do
post api(path, user)
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
end
end
......@@ -110,7 +110,7 @@ describe API::GroupExport do
it 'forbids the request' do
post api(path, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -123,7 +123,7 @@ describe API::GroupExport do
it 'responds with 404 Not Found' do
post api(path, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -42,7 +42,7 @@ describe API::GroupImport do
it 'creates new group and accepts request' do
subject
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
end
it 'creates private group' do
......@@ -63,7 +63,7 @@ describe API::GroupImport do
subject
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
expect(group.children.count).to eq(1)
end
......@@ -81,7 +81,7 @@ describe API::GroupImport do
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)
end
......@@ -90,7 +90,7 @@ describe API::GroupImport do
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)
end
end
......@@ -101,7 +101,7 @@ describe API::GroupImport do
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')
end
......@@ -111,7 +111,7 @@ describe API::GroupImport do
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')
end
end
......@@ -128,7 +128,7 @@ describe API::GroupImport do
it 'returns 400 HTTP status' do
subject
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -139,7 +139,7 @@ describe API::GroupImport do
it 'forbids the request' do
subject
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -154,7 +154,7 @@ describe API::GroupImport do
post api('/groups/import', user), params: params, headers: workhorse_header
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)
end
end
......
This diff is collapsed.
......@@ -17,7 +17,7 @@ describe API::GroupVariables do
it 'returns group variables' do
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)
end
end
......@@ -26,7 +26,7 @@ describe API::GroupVariables do
it 'does not return group variables' do
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
......@@ -34,7 +34,7 @@ describe API::GroupVariables do
it 'does not return group variables' do
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
......@@ -50,7 +50,7 @@ describe API::GroupVariables do
it 'returns group variable details' do
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['protected']).to eq(variable.protected?)
expect(json_response['variable_type']).to eq(variable.variable_type)
......@@ -59,7 +59,7 @@ describe API::GroupVariables do
it 'responds with 404 Not Found if requesting non-existing variable' do
get api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -67,7 +67,7 @@ describe API::GroupVariables do
it 'does not return group variable details' do
get api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -75,7 +75,7 @@ describe API::GroupVariables do
it 'does not return group variable details' do
get api("/groups/#{group.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -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 }
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['value']).to eq('PROTECTED_VALUE_2')
expect(json_response['protected']).to be_truthy
......@@ -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' }
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['value']).to eq('VALUE_2')
expect(json_response['protected']).to be_falsey
......@@ -119,7 +119,7 @@ describe API::GroupVariables do
post api("/groups/#{group.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
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
......@@ -127,7 +127,7 @@ describe API::GroupVariables do
it 'does not create variable' do
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
......@@ -135,7 +135,7 @@ describe API::GroupVariables do
it 'does not create variable' do
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
......@@ -156,7 +156,7 @@ describe API::GroupVariables do
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(updated_variable.value).to eq('VALUE_1_UP')
expect(updated_variable).to be_protected
......@@ -167,7 +167,7 @@ describe API::GroupVariables do
it 'responds with 404 Not Found if requesting non-existing variable' do
put api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -175,7 +175,7 @@ describe API::GroupVariables do
it 'does not update variable' do
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
......@@ -183,7 +183,7 @@ describe API::GroupVariables do
it 'does not update variable' do
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
......@@ -200,14 +200,14 @@ describe API::GroupVariables do
expect do
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
it 'responds with 404 Not Found if requesting non-existing variable' do
delete api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it_behaves_like '412 response' do
......@@ -219,7 +219,7 @@ describe API::GroupVariables do
it 'does not delete variable' do
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
......@@ -227,7 +227,7 @@ describe API::GroupVariables do
it 'does not delete variable' do
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
......
This diff is collapsed.
......@@ -269,7 +269,7 @@ describe API::Helpers do
# The 500 status is expected as we're testing a case where an 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']).to start_with("\nRuntimeError (Runtime Error!):")
end
......
......@@ -36,7 +36,7 @@ describe API::ImportGithub do
personal_access_token: token,
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['name']).to eq(project.name)
end
......@@ -50,7 +50,7 @@ describe API::ImportGithub do
repo_id: 1234
}
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
end
This diff is collapsed.
......@@ -12,21 +12,21 @@ describe API::Keys do
context 'when unauthenticated' do
it 'returns authentication error' do
get api("/keys/#{key.id}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
context 'when authenticated' do
it 'returns 404 for non-existing key' do
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')
end
it 'returns single ssh key with user information' do
user.keys << key
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['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username)
......@@ -44,27 +44,27 @@ describe API::Keys do
it 'returns authentication error' do
get api("/keys?fingerprint=#{key.fingerprint}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns authentication error when authenticated as user' do
get api("/keys?fingerprint=#{key.fingerprint}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'when authenticated as admin' 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)
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')
end
it 'returns 404 for non-existing SSH sha256 fingerprint' do
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')
end
......@@ -73,7 +73,7 @@ describe API::Keys do
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['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username)
......@@ -84,7 +84,7 @@ describe API::Keys do
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['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username)
......@@ -95,7 +95,7 @@ describe API::Keys do
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['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username)
......@@ -125,7 +125,7 @@ describe API::Keys do
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['user']['id']).to eq(user.id)
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ describe API::Lint do
it 'passes validation' do
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['status']).to eq('valid')
expect(json_response['errors']).to eq([])
......@@ -23,7 +23,7 @@ describe API::Lint do
it 'responds with errors about invalid syntax' do
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['errors']).to eq(['Invalid configuration format'])
end
......@@ -31,7 +31,7 @@ describe API::Lint do
it "responds with errors about invalid configuration" do
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['errors']).to eq(['jobs config should contain at least one visible job'])
end
......@@ -41,7 +41,7 @@ describe API::Lint do
it 'responds with validation error about missing content' do
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')
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