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
...@@ -51,7 +51,7 @@ describe API::Geo do ...@@ -51,7 +51,7 @@ describe API::Geo do
get api("/geo/transfers/attachment/#{upload.id}"), headers: req_header get api("/geo/transfers/attachment/#{upload.id}"), headers: req_header
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'responds with 200 when IP is allowed' do it 'responds with 200 when IP is allowed' do
...@@ -59,7 +59,7 @@ describe API::Geo do ...@@ -59,7 +59,7 @@ describe API::Geo do
get api("/geo/transfers/attachment/#{upload.id}"), headers: req_header get api("/geo/transfers/attachment/#{upload.id}"), headers: req_header
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -78,7 +78,7 @@ describe API::Geo do ...@@ -78,7 +78,7 @@ describe API::Geo do
it 'responds with 401 with invalid auth header' do it 'responds with 401 with invalid auth header' do
get api("/geo/transfers/attachment/#{upload.id}"), headers: { Authorization: 'Test' } get api("/geo/transfers/attachment/#{upload.id}"), headers: { Authorization: 'Test' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
context 'attachment file exists' do context 'attachment file exists' do
...@@ -87,7 +87,7 @@ describe API::Geo do ...@@ -87,7 +87,7 @@ describe API::Geo do
it 'responds with 200 with X-Sendfile' do it 'responds with 200 with X-Sendfile' do
request request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Content-Type']).to eq('application/octet-stream') expect(response.headers['Content-Type']).to eq('application/octet-stream')
expect(response.headers['X-Sendfile']).to eq(note.attachment.path) expect(response.headers['X-Sendfile']).to eq(note.attachment.path)
end end
...@@ -99,7 +99,7 @@ describe API::Geo do ...@@ -99,7 +99,7 @@ describe API::Geo do
it 'responds with 404' do it 'responds with 404' do
get api("/geo/transfers/attachment/100000"), headers: not_found_req_header get api("/geo/transfers/attachment/100000"), headers: not_found_req_header
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -119,7 +119,7 @@ describe API::Geo do ...@@ -119,7 +119,7 @@ describe API::Geo do
it 'responds with 401 with invalid auth header' do it 'responds with 401 with invalid auth header' do
get api("/geo/transfers/avatar/#{upload.id}"), headers: { Authorization: 'Test' } get api("/geo/transfers/avatar/#{upload.id}"), headers: { Authorization: 'Test' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
context 'avatar file exists' do context 'avatar file exists' do
...@@ -128,7 +128,7 @@ describe API::Geo do ...@@ -128,7 +128,7 @@ describe API::Geo do
it 'responds with 200 with X-Sendfile' do it 'responds with 200 with X-Sendfile' do
request request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Content-Type']).to eq('application/octet-stream') expect(response.headers['Content-Type']).to eq('application/octet-stream')
expect(response.headers['X-Sendfile']).to eq(user.avatar.path) expect(response.headers['X-Sendfile']).to eq(user.avatar.path)
end end
...@@ -140,7 +140,7 @@ describe API::Geo do ...@@ -140,7 +140,7 @@ describe API::Geo do
it 'responds with 404' do it 'responds with 404' do
get api("/geo/transfers/avatar/100000"), headers: not_found_req_header get api("/geo/transfers/avatar/100000"), headers: not_found_req_header
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -150,7 +150,7 @@ describe API::Geo do ...@@ -150,7 +150,7 @@ describe API::Geo do
get api("/geo/transfers/avatar/#{upload.id}"), headers: req_header get api("/geo/transfers/avatar/#{upload.id}"), headers: req_header
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Content-Type']).to eq('application/octet-stream') expect(response.headers['Content-Type']).to eq('application/octet-stream')
expect(response.headers['X-Sendfile']).to eq(user.avatar.path) expect(response.headers['X-Sendfile']).to eq(user.avatar.path)
end end
...@@ -173,7 +173,7 @@ describe API::Geo do ...@@ -173,7 +173,7 @@ describe API::Geo do
it 'responds with 401 with invalid auth header' do it 'responds with 401 with invalid auth header' do
get api("/geo/transfers/file/#{upload.id}"), headers: { Authorization: 'Test' } get api("/geo/transfers/file/#{upload.id}"), headers: { Authorization: 'Test' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
context 'when the Upload record exists' do context 'when the Upload record exists' do
...@@ -183,7 +183,7 @@ describe API::Geo do ...@@ -183,7 +183,7 @@ describe API::Geo do
it 'responds with 200 with X-Sendfile' do it 'responds with 200 with X-Sendfile' do
request request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Content-Type']).to eq('application/octet-stream') expect(response.headers['Content-Type']).to eq('application/octet-stream')
expect(response.headers['X-Sendfile']).to end_with('dk.png') expect(response.headers['X-Sendfile']).to end_with('dk.png')
end end
...@@ -197,7 +197,7 @@ describe API::Geo do ...@@ -197,7 +197,7 @@ describe API::Geo do
get api("/geo/transfers/file/#{upload.id}"), headers: req_header get api("/geo/transfers/file/#{upload.id}"), headers: req_header
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['geo_code']).to eq(Gitlab::Geo::Replication::FILE_NOT_FOUND_GEO_CODE) expect(json_response['geo_code']).to eq(Gitlab::Geo::Replication::FILE_NOT_FOUND_GEO_CODE)
end end
end end
...@@ -207,7 +207,7 @@ describe API::Geo do ...@@ -207,7 +207,7 @@ describe API::Geo do
it 'responds with 404' do it 'responds with 404' do
get api("/geo/transfers/file/100000"), headers: not_found_req_header get api("/geo/transfers/file/100000"), headers: not_found_req_header
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -226,7 +226,7 @@ describe API::Geo do ...@@ -226,7 +226,7 @@ describe API::Geo do
it 'responds with 401 with invalid auth header' do it 'responds with 401 with invalid auth header' do
get api("/geo/transfers/lfs/#{lfs_object.id}"), headers: { Authorization: 'Test' } get api("/geo/transfers/lfs/#{lfs_object.id}"), headers: { Authorization: 'Test' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
context 'LFS object exists' do context 'LFS object exists' do
...@@ -236,7 +236,7 @@ describe API::Geo do ...@@ -236,7 +236,7 @@ describe API::Geo do
it 'responds with 200 with X-Sendfile' do it 'responds with 200 with X-Sendfile' do
request request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Content-Type']).to eq('application/octet-stream') expect(response.headers['Content-Type']).to eq('application/octet-stream')
expect(response.headers['X-Sendfile']).to eq(lfs_object.file.path) expect(response.headers['X-Sendfile']).to eq(lfs_object.file.path)
end end
...@@ -250,7 +250,7 @@ describe API::Geo do ...@@ -250,7 +250,7 @@ describe API::Geo do
get api("/geo/transfers/lfs/#{lfs_object.id}"), headers: req_header get api("/geo/transfers/lfs/#{lfs_object.id}"), headers: req_header
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['geo_code']).to eq(Gitlab::Geo::Replication::FILE_NOT_FOUND_GEO_CODE) expect(json_response['geo_code']).to eq(Gitlab::Geo::Replication::FILE_NOT_FOUND_GEO_CODE)
end end
end end
...@@ -260,7 +260,7 @@ describe API::Geo do ...@@ -260,7 +260,7 @@ describe API::Geo do
it 'responds with 404' do it 'responds with 404' do
get api("/geo/transfers/lfs/100000"), headers: not_found_req_header get api("/geo/transfers/lfs/100000"), headers: not_found_req_header
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -315,7 +315,7 @@ describe API::Geo do ...@@ -315,7 +315,7 @@ describe API::Geo do
it 'responds with 401 with invalid auth header' do it 'responds with 401 with invalid auth header' do
post api('/geo/status'), headers: { Authorization: 'Test' } post api('/geo/status'), headers: { Authorization: 'Test' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'responds with 401 when the db_key_base is wrong' do it 'responds with 401 when the db_key_base is wrong' do
...@@ -325,7 +325,7 @@ describe API::Geo do ...@@ -325,7 +325,7 @@ describe API::Geo do
request request
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
describe 'allowed IPs' do describe 'allowed IPs' do
...@@ -334,7 +334,7 @@ describe API::Geo do ...@@ -334,7 +334,7 @@ describe API::Geo do
request request
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'responds with 201 when IP is allowed' do it 'responds with 201 when IP is allowed' do
...@@ -342,7 +342,7 @@ describe API::Geo do ...@@ -342,7 +342,7 @@ describe API::Geo do
request request
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
...@@ -355,7 +355,7 @@ describe API::Geo do ...@@ -355,7 +355,7 @@ describe API::Geo do
it 'updates the status and responds with 201' do it 'updates the status and responds with 201' do
expect { request }.to change { GeoNodeStatus.count }.by(1) expect { request }.to change { GeoNodeStatus.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(secondary_node.reload.status.projects_count).to eq(10) expect(secondary_node.reload.status.projects_count).to eq(10)
end end
...@@ -370,7 +370,7 @@ describe API::Geo do ...@@ -370,7 +370,7 @@ describe API::Geo do
post api('/geo/status'), params: data, headers: geo_base_request.headers post api('/geo/status'), params: data, headers: geo_base_request.headers
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it_behaves_like 'with terms enforced' it_behaves_like 'with terms enforced'
...@@ -391,7 +391,7 @@ describe API::Geo do ...@@ -391,7 +391,7 @@ describe API::Geo do
it 'responds with 400' do it 'responds with 400' do
post api('/geo/proxy_git_push_ssh/info_refs'), params: nil post api('/geo/proxy_git_push_ssh/info_refs'), params: nil
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eql('secret_token is missing, data is missing, data[gl_id] is missing, data[primary_repo] is missing') expect(json_response['error']).to eql('secret_token is missing, data is missing, data[gl_id] is missing, data[primary_repo] is missing')
end end
end end
...@@ -407,7 +407,7 @@ describe API::Geo do ...@@ -407,7 +407,7 @@ describe API::Geo do
it 'responds with 401' do it 'responds with 401' do
post(api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: 'invalid', data: data }) post(api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: 'invalid', data: data })
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['error']).to be_nil expect(json_response['error']).to be_nil
end end
end end
...@@ -418,7 +418,7 @@ describe API::Geo do ...@@ -418,7 +418,7 @@ describe API::Geo do
post api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: secret_token, data: data } post api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: secret_token, data: data }
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response['message']).to include('RuntimeError (deliberate exception raised)') expect(json_response['message']).to include('RuntimeError (deliberate exception raised)')
expect(json_response['result']).to be_nil expect(json_response['result']).to be_nil
end end
...@@ -439,7 +439,7 @@ describe API::Geo do ...@@ -439,7 +439,7 @@ describe API::Geo do
post api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: secret_token, data: data } post api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: secret_token, data: data }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(Base64.decode64(json_response['result'])).to eql('something here') expect(Base64.decode64(json_response['result'])).to eql('something here')
end end
end end
...@@ -451,7 +451,7 @@ describe API::Geo do ...@@ -451,7 +451,7 @@ describe API::Geo do
it 'responds with 400' do it 'responds with 400' do
post api('/geo/proxy_git_push_ssh/push'), params: nil post api('/geo/proxy_git_push_ssh/push'), params: nil
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eql('secret_token is missing, data is missing, data[gl_id] is missing, data[primary_repo] is missing, output is missing') expect(json_response['error']).to eql('secret_token is missing, data is missing, data[gl_id] is missing, data[primary_repo] is missing, output is missing')
end end
end end
...@@ -468,7 +468,7 @@ describe API::Geo do ...@@ -468,7 +468,7 @@ describe API::Geo do
it 'responds with 401' do it 'responds with 401' do
post(api('/geo/proxy_git_push_ssh/push'), params: { secret_token: 'invalid', data: data, output: output }) post(api('/geo/proxy_git_push_ssh/push'), params: { secret_token: 'invalid', data: data, output: output })
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['error']).to be_nil expect(json_response['error']).to be_nil
end end
end end
...@@ -478,7 +478,7 @@ describe API::Geo do ...@@ -478,7 +478,7 @@ describe API::Geo do
expect(git_push_ssh_proxy).to receive(:push).and_raise('deliberate exception raised') expect(git_push_ssh_proxy).to receive(:push).and_raise('deliberate exception raised')
post api('/geo/proxy_git_push_ssh/push'), params: { secret_token: secret_token, data: data, output: output } post api('/geo/proxy_git_push_ssh/push'), params: { secret_token: secret_token, data: data, output: output }
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response['message']).to include('RuntimeError (deliberate exception raised)') expect(json_response['message']).to include('RuntimeError (deliberate exception raised)')
expect(json_response['result']).to be_nil expect(json_response['result']).to be_nil
end end
...@@ -499,7 +499,7 @@ describe API::Geo do ...@@ -499,7 +499,7 @@ describe API::Geo do
post api('/geo/proxy_git_push_ssh/push'), params: { secret_token: secret_token, data: data, output: output } post api('/geo/proxy_git_push_ssh/push'), params: { secret_token: secret_token, data: data, output: output }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(Base64.decode64(json_response['result'])).to eql('something here') expect(Base64.decode64(json_response['result'])).to eql('something here')
end end
end end
......
...@@ -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
......
...@@ -15,7 +15,7 @@ describe API::GroupLabels do ...@@ -15,7 +15,7 @@ describe API::GroupLabels do
it 'returns all available labels for the group' do it 'returns all available labels for the group' do
get api("/groups/#{group.id}/labels", user) get api("/groups/#{group.id}/labels", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label')) expect(json_response).to all(match_schema('public_api/v4/labels/label'))
...@@ -27,7 +27,7 @@ describe API::GroupLabels do ...@@ -27,7 +27,7 @@ describe API::GroupLabels do
it 'includes counts in the response' do it 'includes counts in the response' do
get api("/groups/#{group.id}/labels", user), params: { with_counts: true } get api("/groups/#{group.id}/labels", user), params: { with_counts: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label_with_counts')) expect(json_response).to all(match_schema('public_api/v4/labels/label_with_counts'))
...@@ -42,7 +42,7 @@ describe API::GroupLabels do ...@@ -42,7 +42,7 @@ describe API::GroupLabels do
it 'returns all available labels for the group and ancestor groups' do it 'returns all available labels for the group and ancestor groups' do
get api("/groups/#{subgroup.id}/labels", user) get api("/groups/#{subgroup.id}/labels", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label')) expect(json_response).to all(match_schema('public_api/v4/labels/label'))
...@@ -55,7 +55,7 @@ describe API::GroupLabels do ...@@ -55,7 +55,7 @@ describe API::GroupLabels do
it 'returns all available labels for the group but not for ancestor groups' do it 'returns all available labels for the group but not for ancestor groups' do
get api("/groups/#{subgroup.id}/labels", user), params: { include_ancestor_groups: false } get api("/groups/#{subgroup.id}/labels", user), params: { include_ancestor_groups: false }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label')) expect(json_response).to all(match_schema('public_api/v4/labels/label'))
...@@ -69,7 +69,7 @@ describe API::GroupLabels do ...@@ -69,7 +69,7 @@ describe API::GroupLabels do
it 'returns a single label for the group' do it 'returns a single label for the group' do
get api("/groups/#{group.id}/labels/#{group_label1.name}", user) get api("/groups/#{group.id}/labels/#{group_label1.name}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(group_label1.name) expect(json_response['name']).to eq(group_label1.name)
expect(json_response['color']).to eq(group_label1.color) expect(json_response['color']).to eq(group_label1.color)
expect(json_response['description']).to eq(group_label1.description) expect(json_response['description']).to eq(group_label1.description)
...@@ -85,7 +85,7 @@ describe API::GroupLabels do ...@@ -85,7 +85,7 @@ describe API::GroupLabels do
description: 'test' description: 'test'
} }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq('Foo') expect(json_response['name']).to eq('Foo')
expect(json_response['color']).to eq('#FFAABB') expect(json_response['color']).to eq('#FFAABB')
expect(json_response['description']).to eq('test') expect(json_response['description']).to eq('test')
...@@ -107,13 +107,13 @@ describe API::GroupLabels do ...@@ -107,13 +107,13 @@ describe API::GroupLabels do
it 'returns a 400 bad request if name not given' do it 'returns a 400 bad request if name not given' do
post api("/groups/#{group.id}/labels", user), params: { color: '#FFAABB' } post api("/groups/#{group.id}/labels", user), params: { color: '#FFAABB' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns a 400 bad request if color is not given' do it 'returns a 400 bad request if color is not given' do
post api("/groups/#{group.id}/labels", user), params: { name: 'Foobar' } post api("/groups/#{group.id}/labels", user), params: { name: 'Foobar' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 409 if label already exists' do it 'returns 409 if label already exists' do
...@@ -123,7 +123,7 @@ describe API::GroupLabels do ...@@ -123,7 +123,7 @@ describe API::GroupLabels do
color: '#FFAABB' color: '#FFAABB'
} }
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Label already exists') expect(json_response['message']).to eq('Label already exists')
end end
end end
...@@ -132,20 +132,20 @@ describe API::GroupLabels do ...@@ -132,20 +132,20 @@ describe API::GroupLabels do
it 'returns 204 for existing label' do it 'returns 204 for existing label' do
delete api("/groups/#{group.id}/labels", user), params: { name: group_label1.name } delete api("/groups/#{group.id}/labels", user), params: { name: group_label1.name }
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'returns 404 for non existing label' do it 'returns 404 for non existing label' do
delete api("/groups/#{group.id}/labels", user), params: { name: 'not_exists' } delete api("/groups/#{group.id}/labels", user), params: { name: 'not_exists' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Label Not Found') expect(json_response['message']).to eq('404 Label Not Found')
end end
it 'returns 400 for wrong parameters' do it 'returns 400 for wrong parameters' do
delete api("/groups/#{group.id}/labels", user) delete api("/groups/#{group.id}/labels", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "does not delete parent's group labels" do it "does not delete parent's group labels" do
...@@ -154,7 +154,7 @@ describe API::GroupLabels do ...@@ -154,7 +154,7 @@ describe API::GroupLabels do
delete api("/groups/#{subgroup.id}/labels", user), params: { name: subgroup_label.name } delete api("/groups/#{subgroup.id}/labels", user), params: { name: subgroup_label.name }
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(subgroup.labels.size).to eq(0) expect(subgroup.labels.size).to eq(0)
expect(group.labels).to include(group_label1) expect(group.labels).to include(group_label1)
end end
...@@ -169,13 +169,13 @@ describe API::GroupLabels do ...@@ -169,13 +169,13 @@ describe API::GroupLabels do
it 'returns 204 for existing label' do it 'returns 204 for existing label' do
delete api("/groups/#{group.id}/labels/#{group_label1.name}", user) delete api("/groups/#{group.id}/labels/#{group_label1.name}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'returns 404 for non existing label' do it 'returns 404 for non existing label' do
delete api("/groups/#{group.id}/labels/not_exists", user) delete api("/groups/#{group.id}/labels/not_exists", 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 Label Not Found') expect(json_response['message']).to eq('404 Label Not Found')
end end
...@@ -185,7 +185,7 @@ describe API::GroupLabels do ...@@ -185,7 +185,7 @@ describe API::GroupLabels do
delete api("/groups/#{subgroup.id}/labels/#{subgroup_label.name}", user) delete api("/groups/#{subgroup.id}/labels/#{subgroup_label.name}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(subgroup.labels.size).to eq(0) expect(subgroup.labels.size).to eq(0)
expect(group.labels).to include(group_label1) expect(group.labels).to include(group_label1)
end end
...@@ -205,7 +205,7 @@ describe API::GroupLabels do ...@@ -205,7 +205,7 @@ describe API::GroupLabels do
description: 'test' description: 'test'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('New Label') expect(json_response['name']).to eq('New Label')
expect(json_response['color']).to eq('#FFFFFF') expect(json_response['color']).to eq('#FFFFFF')
expect(json_response['description']).to eq('test') expect(json_response['description']).to eq('test')
...@@ -221,7 +221,7 @@ describe API::GroupLabels do ...@@ -221,7 +221,7 @@ describe API::GroupLabels do
new_name: 'New Label' new_name: 'New Label'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(subgroup.labels[0].name).to eq('New Label') expect(subgroup.labels[0].name).to eq('New Label')
expect(group_label1.name).to eq('feature') expect(group_label1.name).to eq('feature')
end end
...@@ -233,20 +233,20 @@ describe API::GroupLabels do ...@@ -233,20 +233,20 @@ describe API::GroupLabels do
new_name: 'label3' new_name: 'label3'
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 400 if no label name given' do it 'returns 400 if no label name given' do
put api("/groups/#{group.id}/labels", user), params: { new_name: group_label1.name } put api("/groups/#{group.id}/labels", user), params: { new_name: group_label1.name }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('label_id, name are missing, exactly one parameter must be provided') expect(json_response['error']).to eq('label_id, name are missing, exactly one parameter must be provided')
end end
it 'returns 400 if no new parameters given' do it 'returns 400 if no new parameters given' do
put api("/groups/#{group.id}/labels", user), params: { name: group_label1.name } put api("/groups/#{group.id}/labels", user), params: { name: group_label1.name }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('new_name, color, description are missing, '\ expect(json_response['error']).to eq('new_name, color, description are missing, '\
'at least one parameter must be provided') 'at least one parameter must be provided')
end end
...@@ -261,7 +261,7 @@ describe API::GroupLabels do ...@@ -261,7 +261,7 @@ describe API::GroupLabels do
description: 'test' description: 'test'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('New Label') expect(json_response['name']).to eq('New Label')
expect(json_response['color']).to eq('#FFFFFF') expect(json_response['color']).to eq('#FFFFFF')
expect(json_response['description']).to eq('test') expect(json_response['description']).to eq('test')
...@@ -276,7 +276,7 @@ describe API::GroupLabels do ...@@ -276,7 +276,7 @@ describe API::GroupLabels do
new_name: 'New Label' new_name: 'New Label'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(subgroup.labels[0].name).to eq('New Label') expect(subgroup.labels[0].name).to eq('New Label')
expect(group_label1.name).to eq('feature') expect(group_label1.name).to eq('feature')
end end
...@@ -287,13 +287,13 @@ describe API::GroupLabels do ...@@ -287,13 +287,13 @@ describe API::GroupLabels do
new_name: 'label3' new_name: 'label3'
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 400 if no new parameters given' do it 'returns 400 if no new parameters given' do
put api("/groups/#{group.id}/labels/#{group_label1.name}", user) put api("/groups/#{group.id}/labels/#{group_label1.name}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('new_name, color, description are missing, '\ expect(json_response['error']).to eq('new_name, color, description are missing, '\
'at least one parameter must be provided') 'at least one parameter must be provided')
end end
...@@ -304,7 +304,7 @@ describe API::GroupLabels do ...@@ -304,7 +304,7 @@ describe API::GroupLabels do
it 'subscribes to the label' do it 'subscribes to the label' do
post api("/groups/#{group.id}/labels/#{group_label1.title}/subscribe", user) post api("/groups/#{group.id}/labels/#{group_label1.title}/subscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(group_label1.title) expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_truthy expect(json_response['subscribed']).to be_truthy
end end
...@@ -314,7 +314,7 @@ describe API::GroupLabels do ...@@ -314,7 +314,7 @@ describe API::GroupLabels do
it 'subscribes to the label' do it 'subscribes to the label' do
post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user) post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(group_label1.title) expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_truthy expect(json_response['subscribed']).to be_truthy
end end
...@@ -328,7 +328,7 @@ describe API::GroupLabels do ...@@ -328,7 +328,7 @@ describe API::GroupLabels do
it 'returns 304' do it 'returns 304' do
post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user) post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user)
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
end end
end end
...@@ -336,7 +336,7 @@ describe API::GroupLabels do ...@@ -336,7 +336,7 @@ describe API::GroupLabels do
it 'returns 404 error' do it 'returns 404 error' do
post api("/groups/#{group.id}/labels/1234/subscribe", user) post api("/groups/#{group.id}/labels/1234/subscribe", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -350,7 +350,7 @@ describe API::GroupLabels do ...@@ -350,7 +350,7 @@ describe API::GroupLabels do
it 'unsubscribes from the label' do it 'unsubscribes from the label' do
post api("/groups/#{group.id}/labels/#{group_label1.title}/unsubscribe", user) post api("/groups/#{group.id}/labels/#{group_label1.title}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(group_label1.title) expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_falsey expect(json_response['subscribed']).to be_falsey
end end
...@@ -360,7 +360,7 @@ describe API::GroupLabels do ...@@ -360,7 +360,7 @@ describe API::GroupLabels do
it 'unsubscribes from the label' do it 'unsubscribes from the label' do
post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user) post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(group_label1.title) expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_falsey expect(json_response['subscribed']).to be_falsey
end end
...@@ -374,7 +374,7 @@ describe API::GroupLabels do ...@@ -374,7 +374,7 @@ describe API::GroupLabels do
it 'returns 304' do it 'returns 304' do
post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user) post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
end end
end end
...@@ -382,7 +382,7 @@ describe API::GroupLabels do ...@@ -382,7 +382,7 @@ describe API::GroupLabels do
it 'returns 404 error' do it 'returns 404 error' do
post api("/groups/#{group.id}/labels/1234/unsubscribe", user) post api("/groups/#{group.id}/labels/1234/unsubscribe", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -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
......
...@@ -26,7 +26,7 @@ describe API::Groups do ...@@ -26,7 +26,7 @@ describe API::Groups do
it "returns public groups" do it "returns public groups" do
get api("/groups") get api("/groups")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -54,7 +54,7 @@ describe API::Groups do ...@@ -54,7 +54,7 @@ describe API::Groups do
it "normal user: returns an array of groups of user1" do it "normal user: returns an array of groups of user1" do
get api("/groups", user1) get api("/groups", user1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -65,7 +65,7 @@ describe API::Groups do ...@@ -65,7 +65,7 @@ describe API::Groups do
it "does not include runners_token information" do it "does not include runners_token information" do
get api("/groups", user1) get api("/groups", user1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -75,7 +75,7 @@ describe API::Groups do ...@@ -75,7 +75,7 @@ describe API::Groups do
it "does not include statistics" do it "does not include statistics" do
get api("/groups", user1), params: { statistics: true } get api("/groups", user1), params: { statistics: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first).not_to include 'statistics' expect(json_response.first).not_to include 'statistics'
...@@ -86,7 +86,7 @@ describe API::Groups do ...@@ -86,7 +86,7 @@ describe API::Groups do
it "admin: returns an array of all groups" do it "admin: returns an array of all groups" do
get api("/groups", admin) get api("/groups", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
...@@ -95,7 +95,7 @@ describe API::Groups do ...@@ -95,7 +95,7 @@ describe API::Groups do
it "does not include runners_token information" do it "does not include runners_token information" do
get api("/groups", admin) get api("/groups", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
...@@ -105,7 +105,7 @@ describe API::Groups do ...@@ -105,7 +105,7 @@ describe API::Groups do
it "does not include statistics by default" do it "does not include statistics by default" do
get api("/groups", admin) get api("/groups", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first).not_to include('statistics') expect(json_response.first).not_to include('statistics')
...@@ -126,7 +126,7 @@ describe API::Groups do ...@@ -126,7 +126,7 @@ describe API::Groups do
get api("/groups", admin), params: { statistics: true } get api("/groups", admin), params: { statistics: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response) expect(json_response)
...@@ -138,7 +138,7 @@ describe API::Groups do ...@@ -138,7 +138,7 @@ describe API::Groups do
it "returns all groups excluding skipped groups" do it "returns all groups excluding skipped groups" do
get api("/groups", admin), params: { skip_groups: [group2.id] } get api("/groups", admin), params: { skip_groups: [group2.id] }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -153,7 +153,7 @@ describe API::Groups do ...@@ -153,7 +153,7 @@ describe API::Groups do
get api("/groups", user1), params: { all_available: true } get api("/groups", user1), params: { all_available: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups).to contain_exactly(public_group.name, group1.name) expect(response_groups).to contain_exactly(public_group.name, group1.name)
...@@ -176,7 +176,7 @@ describe API::Groups do ...@@ -176,7 +176,7 @@ describe API::Groups do
it "sorts by name ascending by default" do it "sorts by name ascending by default" do
get api("/groups", user1) get api("/groups", user1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups).to eq(groups_visible_to_user(user1).order(:name).pluck(:name)) expect(response_groups).to eq(groups_visible_to_user(user1).order(:name).pluck(:name))
...@@ -185,7 +185,7 @@ describe API::Groups do ...@@ -185,7 +185,7 @@ describe API::Groups do
it "sorts in descending order when passed" do it "sorts in descending order when passed" do
get api("/groups", user1), params: { sort: "desc" } get api("/groups", user1), params: { sort: "desc" }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups).to eq(groups_visible_to_user(user1).order(name: :desc).pluck(:name)) expect(response_groups).to eq(groups_visible_to_user(user1).order(name: :desc).pluck(:name))
...@@ -194,7 +194,7 @@ describe API::Groups do ...@@ -194,7 +194,7 @@ describe API::Groups do
it "sorts by path in order_by param" do it "sorts by path in order_by param" do
get api("/groups", user1), params: { order_by: "path" } get api("/groups", user1), params: { order_by: "path" }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups).to eq(groups_visible_to_user(user1).order(:path).pluck(:name)) expect(response_groups).to eq(groups_visible_to_user(user1).order(:path).pluck(:name))
...@@ -203,7 +203,7 @@ describe API::Groups do ...@@ -203,7 +203,7 @@ describe API::Groups do
it "sorts by id in the order_by param" do it "sorts by id in the order_by param" do
get api("/groups", user1), params: { order_by: "id" } get api("/groups", user1), params: { order_by: "id" }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups).to eq(groups_visible_to_user(user1).order(:id).pluck(:name)) expect(response_groups).to eq(groups_visible_to_user(user1).order(:id).pluck(:name))
...@@ -212,7 +212,7 @@ describe API::Groups do ...@@ -212,7 +212,7 @@ describe API::Groups do
it "sorts also by descending id with pagination fix" do it "sorts also by descending id with pagination fix" do
get api("/groups", user1), params: { order_by: "id", sort: "desc" } get api("/groups", user1), params: { order_by: "id", sort: "desc" }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups).to eq(groups_visible_to_user(user1).order(id: :desc).pluck(:name)) expect(response_groups).to eq(groups_visible_to_user(user1).order(id: :desc).pluck(:name))
...@@ -221,7 +221,7 @@ describe API::Groups do ...@@ -221,7 +221,7 @@ describe API::Groups do
it "sorts identical keys by id for good pagination" do it "sorts identical keys by id for good pagination" do
get api("/groups", user1), params: { search: "same-name", order_by: "name" } get api("/groups", user1), params: { search: "same-name", order_by: "name" }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups_ids).to eq(Group.select { |group| group['name'] == 'same-name' }.map { |group| group['id'] }.sort) expect(response_groups_ids).to eq(Group.select { |group| group['name'] == 'same-name' }.map { |group| group['id'] }.sort)
...@@ -230,7 +230,7 @@ describe API::Groups do ...@@ -230,7 +230,7 @@ describe API::Groups do
it "sorts descending identical keys by id for good pagination" do it "sorts descending identical keys by id for good pagination" do
get api("/groups", user1), params: { search: "same-name", order_by: "name", sort: "desc" } get api("/groups", user1), params: { search: "same-name", order_by: "name", sort: "desc" }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups_ids).to eq(Group.select { |group| group['name'] == 'same-name' }.map { |group| group['id'] }.sort) expect(response_groups_ids).to eq(Group.select { |group| group['name'] == 'same-name' }.map { |group| group['id'] }.sort)
...@@ -247,7 +247,7 @@ describe API::Groups do ...@@ -247,7 +247,7 @@ describe API::Groups do
get api('/groups', user2), params: { owned: true } get api('/groups', user2), params: { owned: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -267,7 +267,7 @@ describe API::Groups do ...@@ -267,7 +267,7 @@ describe API::Groups do
it 'returns an array of groups the user has at least master access' do it 'returns an array of groups the user has at least master access' do
get api('/groups', user2), params: { min_access_level: 40 } get api('/groups', user2), params: { min_access_level: 40 }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response_groups).to eq([group2.id, group3.id]) expect(response_groups).to eq([group2.id, group3.id])
...@@ -308,13 +308,13 @@ describe API::Groups do ...@@ -308,13 +308,13 @@ describe API::Groups do
it 'returns 404 for a private group' do it 'returns 404 for a private group' do
get api("/groups/#{group2.id}") get api("/groups/#{group2.id}")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 200 for a public group' do it 'returns 200 for a public group' do
get api("/groups/#{group1.id}") get api("/groups/#{group1.id}")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include('runners_token') expect(json_response).not_to include('runners_token')
end end
...@@ -346,7 +346,7 @@ describe API::Groups do ...@@ -346,7 +346,7 @@ describe API::Groups do
get api("/groups/#{group1.id}", user1) get api("/groups/#{group1.id}", user1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(group1.id) expect(json_response['id']).to eq(group1.id)
expect(json_response['name']).to eq(group1.name) expect(json_response['name']).to eq(group1.name)
expect(json_response['path']).to eq(group1.path) expect(json_response['path']).to eq(group1.path)
...@@ -379,7 +379,7 @@ describe API::Groups do ...@@ -379,7 +379,7 @@ describe API::Groups do
get api("/groups/#{group1.id}", user1), params: { with_projects: false } get api("/groups/#{group1.id}", user1), params: { with_projects: false }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['projects']).to be_nil expect(json_response['projects']).to be_nil
expect(json_response['shared_projects']).to be_nil expect(json_response['shared_projects']).to be_nil
expect(json_response).not_to include('runners_token') expect(json_response).not_to include('runners_token')
...@@ -388,7 +388,7 @@ describe API::Groups do ...@@ -388,7 +388,7 @@ describe API::Groups do
it "doesn't return runners_token if the user is not the owner of the group" do it "doesn't return runners_token if the user is not the owner of the group" do
get api("/groups/#{group1.id}", user3) get api("/groups/#{group1.id}", user3)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include('runners_token') expect(json_response).not_to include('runners_token')
end end
...@@ -396,20 +396,20 @@ describe API::Groups do ...@@ -396,20 +396,20 @@ describe API::Groups do
group1.add_owner(user3) group1.add_owner(user3)
get api("/groups/#{group1.id}", user3) get api("/groups/#{group1.id}", user3)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('runners_token') expect(json_response).to include('runners_token')
end end
it "does not return a non existing group" do it "does not return a non existing group" do
get api("/groups/1328", user1) get api("/groups/1328", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "does not return a group not attached to user1" do it "does not return a group not attached to user1" do
get api("/groups/#{group2.id}", user1) get api("/groups/#{group2.id}", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns only public and internal projects in the group' do it 'returns only public and internal projects in the group' do
...@@ -451,21 +451,21 @@ describe API::Groups do ...@@ -451,21 +451,21 @@ describe API::Groups do
it "returns any existing group" do it "returns any existing group" do
get api("/groups/#{group2.id}", admin) get api("/groups/#{group2.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(group2.name) expect(json_response['name']).to eq(group2.name)
end end
it "returns information of the runners_token for the group" do it "returns information of the runners_token for the group" do
get api("/groups/#{group2.id}", admin) get api("/groups/#{group2.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('runners_token') expect(json_response).to include('runners_token')
end end
it "does not return a non existing group" do it "does not return a non existing group" do
get api("/groups/1328", admin) get api("/groups/1328", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -473,20 +473,20 @@ describe API::Groups do ...@@ -473,20 +473,20 @@ describe API::Groups do
it 'returns any existing group' do it 'returns any existing group' do
get api("/groups/#{group1.path}", admin) get api("/groups/#{group1.path}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(group1.name) expect(json_response['name']).to eq(group1.name)
end end
it 'does not return a non existing group' do it 'does not return a non existing group' do
get api('/groups/unknown', admin) get api('/groups/unknown', admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'does not return a group not attached to user1' do it 'does not return a group not attached to user1' do
get api("/groups/#{group2.path}", user1) get api("/groups/#{group2.path}", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -548,7 +548,7 @@ describe API::Groups do ...@@ -548,7 +548,7 @@ describe API::Groups do
subgroup_creation_level: "maintainer" subgroup_creation_level: "maintainer"
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(new_group_name) expect(json_response['name']).to eq(new_group_name)
expect(json_response['description']).to eq('') expect(json_response['description']).to eq('')
expect(json_response['visibility']).to eq('public') expect(json_response['visibility']).to eq('public')
...@@ -571,7 +571,7 @@ describe API::Groups do ...@@ -571,7 +571,7 @@ describe API::Groups do
it 'returns 404 for a non existing group' do it 'returns 404 for a non existing group' do
put api('/groups/1328', user1), params: { name: new_group_name } put api('/groups/1328', user1), params: { name: new_group_name }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'within a subgroup' do context 'within a subgroup' do
...@@ -585,14 +585,14 @@ describe API::Groups do ...@@ -585,14 +585,14 @@ describe API::Groups do
it 'does not change visibility when not requested' do it 'does not change visibility when not requested' do
put api("/groups/#{group3.id}", user3), params: { description: 'Bug #23083' } put api("/groups/#{group3.id}", user3), params: { description: 'Bug #23083' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['visibility']).to eq('public') expect(json_response['visibility']).to eq('public')
end end
it 'prevents making private a group containing public subgroups' do it 'prevents making private a group containing public subgroups' do
put api("/groups/#{group3.id}", user3), params: { visibility: 'private' } put api("/groups/#{group3.id}", user3), params: { visibility: 'private' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['visibility_level']).to contain_exactly('private is not allowed since there are sub-groups with higher visibility.') expect(json_response['message']['visibility_level']).to contain_exactly('private is not allowed since there are sub-groups with higher visibility.')
end end
end end
...@@ -602,7 +602,7 @@ describe API::Groups do ...@@ -602,7 +602,7 @@ describe API::Groups do
it 'updates the group' do it 'updates the group' do
put api("/groups/#{group1.id}", admin), params: { name: new_group_name } put api("/groups/#{group1.id}", admin), params: { name: new_group_name }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(new_group_name) expect(json_response['name']).to eq(new_group_name)
end end
end end
...@@ -611,7 +611,7 @@ describe API::Groups do ...@@ -611,7 +611,7 @@ describe API::Groups do
it 'does not updates the group' do it 'does not updates the group' do
put api("/groups/#{group1.id}", user2), params: { name: new_group_name } put api("/groups/#{group1.id}", user2), params: { name: new_group_name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -619,7 +619,7 @@ describe API::Groups do ...@@ -619,7 +619,7 @@ describe API::Groups do
it 'returns 404 when trying to update the group' do it 'returns 404 when trying to update the group' do
put api("/groups/#{group2.id}", user1), params: { name: new_group_name } put api("/groups/#{group2.id}", user1), params: { name: new_group_name }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -645,7 +645,7 @@ describe API::Groups do ...@@ -645,7 +645,7 @@ describe API::Groups do
it "returns the group's projects" do it "returns the group's projects" do
get api("/groups/#{group1.id}/projects", user1) get api("/groups/#{group1.id}/projects", user1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
project_names = json_response.map { |proj| proj['name'] } project_names = json_response.map { |proj| proj['name'] }
...@@ -656,7 +656,7 @@ describe API::Groups do ...@@ -656,7 +656,7 @@ describe API::Groups do
it "returns the group's projects with simple representation" do it "returns the group's projects with simple representation" do
get api("/groups/#{group1.id}/projects", user1), params: { simple: true } get api("/groups/#{group1.id}/projects", user1), params: { simple: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
project_names = json_response.map { |proj| proj['name'] } project_names = json_response.map { |proj| proj['name'] }
...@@ -669,7 +669,7 @@ describe API::Groups do ...@@ -669,7 +669,7 @@ describe API::Groups do
get api("/groups/#{group1.id}/projects", user1), params: { visibility: 'public' } get api("/groups/#{group1.id}/projects", user1), params: { visibility: 'public' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an(Array) expect(json_response).to be_an(Array)
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -683,7 +683,7 @@ describe API::Groups do ...@@ -683,7 +683,7 @@ describe API::Groups do
get api("/groups/#{group1.id}/projects", user1), params: { with_shared: false } get api("/groups/#{group1.id}/projects", user1), params: { with_shared: false }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an(Array) expect(json_response).to be_an(Array)
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
...@@ -696,7 +696,7 @@ describe API::Groups do ...@@ -696,7 +696,7 @@ describe API::Groups do
get api("/groups/#{group1.id}/projects", user1), params: { include_subgroups: true } get api("/groups/#{group1.id}/projects", user1), params: { include_subgroups: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an(Array) expect(json_response).to be_an(Array)
expect(json_response.length).to eq(4) expect(json_response.length).to eq(4)
...@@ -705,13 +705,13 @@ describe API::Groups do ...@@ -705,13 +705,13 @@ describe API::Groups do
it "does not return a non existing group" do it "does not return a non existing group" do
get api("/groups/1328/projects", user1) get api("/groups/1328/projects", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "does not return a group not attached to user1" do it "does not return a group not attached to user1" do
get api("/groups/#{group2.id}/projects", user1) get api("/groups/#{group2.id}/projects", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "only returns projects to which user has access" do it "only returns projects to which user has access" do
...@@ -719,7 +719,7 @@ describe API::Groups do ...@@ -719,7 +719,7 @@ describe API::Groups do
get api("/groups/#{group1.id}/projects", user3) get api("/groups/#{group1.id}/projects", user3)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['name']).to eq(project3.name) expect(json_response.first['name']).to eq(project3.name)
...@@ -730,7 +730,7 @@ describe API::Groups do ...@@ -730,7 +730,7 @@ describe API::Groups do
get api("/groups/#{project2.group.id}/projects", user3), params: { owned: true } get api("/groups/#{project2.group.id}/projects", user3), params: { owned: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['name']).to eq(project2.name) expect(json_response.first['name']).to eq(project2.name)
end end
...@@ -740,7 +740,7 @@ describe API::Groups do ...@@ -740,7 +740,7 @@ describe API::Groups do
get api("/groups/#{group1.id}/projects", user1), params: { starred: true } get api("/groups/#{group1.id}/projects", user1), params: { starred: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['name']).to eq(project1.name) expect(json_response.first['name']).to eq(project1.name)
end end
...@@ -750,7 +750,7 @@ describe API::Groups do ...@@ -750,7 +750,7 @@ describe API::Groups do
it "returns any existing group" do it "returns any existing group" do
get api("/groups/#{group2.id}/projects", admin) get api("/groups/#{group2.id}/projects", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['name']).to eq(project2.name) expect(json_response.first['name']).to eq(project2.name)
...@@ -759,7 +759,7 @@ describe API::Groups do ...@@ -759,7 +759,7 @@ describe API::Groups do
it "does not return a non existing group" do it "does not return a non existing group" do
get api("/groups/1328/projects", admin) get api("/groups/1328/projects", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'avoids N+1 queries' do it 'avoids N+1 queries' do
...@@ -781,7 +781,7 @@ describe API::Groups do ...@@ -781,7 +781,7 @@ describe API::Groups do
it 'returns any existing group' do it 'returns any existing group' do
get api("/groups/#{group1.path}/projects", admin) get api("/groups/#{group1.path}/projects", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
project_names = json_response.map { |proj| proj['name'] } project_names = json_response.map { |proj| proj['name'] }
expect(project_names).to match_array([project1.name, project3.name]) expect(project_names).to match_array([project1.name, project3.name])
...@@ -790,13 +790,13 @@ describe API::Groups do ...@@ -790,13 +790,13 @@ describe API::Groups do
it 'does not return a non existing group' do it 'does not return a non existing group' do
get api('/groups/unknown/projects', admin) get api('/groups/unknown/projects', admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'does not return a group not attached to user1' do it 'does not return a group not attached to user1' do
get api("/groups/#{group2.path}/projects", user1) get api("/groups/#{group2.path}/projects", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -810,7 +810,7 @@ describe API::Groups do ...@@ -810,7 +810,7 @@ describe API::Groups do
it 'returns only public subgroups' do it 'returns only public subgroups' do
get api("/groups/#{group1.id}/subgroups") get api("/groups/#{group1.id}/subgroups")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -821,7 +821,7 @@ describe API::Groups do ...@@ -821,7 +821,7 @@ describe API::Groups do
it 'returns 404 for a private group' do it 'returns 404 for a private group' do
get api("/groups/#{group2.id}/subgroups") get api("/groups/#{group2.id}/subgroups")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -830,7 +830,7 @@ describe API::Groups do ...@@ -830,7 +830,7 @@ describe API::Groups do
it 'returns no subgroups for the public group' do it 'returns no subgroups for the public group' do
get api("/groups/#{group1.id}/subgroups", user2) get api("/groups/#{group1.id}/subgroups", user2)
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(0) expect(json_response.length).to eq(0)
end end
...@@ -839,7 +839,7 @@ describe API::Groups do ...@@ -839,7 +839,7 @@ describe API::Groups do
it 'returns public subgroups' do it 'returns public subgroups' do
get api("/groups/#{group1.id}/subgroups", user2), params: { all_available: true } get api("/groups/#{group1.id}/subgroups", user2), params: { all_available: true }
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(json_response[0]['id']).to eq(subgroup1.id) expect(json_response[0]['id']).to eq(subgroup1.id)
...@@ -852,7 +852,7 @@ describe API::Groups do ...@@ -852,7 +852,7 @@ describe API::Groups do
it 'returns 404 for the private group' do it 'returns 404 for the private group' do
get api("/groups/#{group2.id}/subgroups", user1) get api("/groups/#{group2.id}/subgroups", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -864,7 +864,7 @@ describe API::Groups do ...@@ -864,7 +864,7 @@ describe API::Groups do
it 'returns private subgroups' do it 'returns private subgroups' do
get api("/groups/#{group1.id}/subgroups", user2) get api("/groups/#{group1.id}/subgroups", user2)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
...@@ -878,7 +878,7 @@ describe API::Groups do ...@@ -878,7 +878,7 @@ describe API::Groups do
it 'does not include statistics' do it 'does not include statistics' do
get api("/groups/#{group1.id}/subgroups", user2), params: { statistics: true } get api("/groups/#{group1.id}/subgroups", user2), params: { statistics: true }
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.first).not_to include 'statistics' expect(json_response.first).not_to include 'statistics'
end end
...@@ -893,7 +893,7 @@ describe API::Groups do ...@@ -893,7 +893,7 @@ describe API::Groups do
it 'returns subgroups' do it 'returns subgroups' do
get api("/groups/#{group2.id}/subgroups", user1) get api("/groups/#{group2.id}/subgroups", user1)
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(json_response.first['id']).to eq(subgroup3.id) expect(json_response.first['id']).to eq(subgroup3.id)
...@@ -906,7 +906,7 @@ describe API::Groups do ...@@ -906,7 +906,7 @@ describe API::Groups do
it 'returns private subgroups of a public group' do it 'returns private subgroups of a public group' do
get api("/groups/#{group1.id}/subgroups", admin) get api("/groups/#{group1.id}/subgroups", admin)
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(2) expect(json_response.length).to eq(2)
end end
...@@ -914,7 +914,7 @@ describe API::Groups do ...@@ -914,7 +914,7 @@ describe API::Groups do
it 'returns subgroups of a private group' do it 'returns subgroups of a private group' do
get api("/groups/#{group2.id}/subgroups", admin) get api("/groups/#{group2.id}/subgroups", admin)
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)
end end
...@@ -922,7 +922,7 @@ describe API::Groups do ...@@ -922,7 +922,7 @@ describe API::Groups do
it 'does not include statistics by default' do it 'does not include statistics by default' do
get api("/groups/#{group1.id}/subgroups", admin) get api("/groups/#{group1.id}/subgroups", admin)
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.first).not_to include('statistics') expect(json_response.first).not_to include('statistics')
end end
...@@ -930,7 +930,7 @@ describe API::Groups do ...@@ -930,7 +930,7 @@ describe API::Groups do
it 'includes statistics if requested' do it 'includes statistics if requested' do
get api("/groups/#{group1.id}/subgroups", admin), params: { statistics: true } get api("/groups/#{group1.id}/subgroups", admin), params: { statistics: true }
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.first).to include('statistics') expect(json_response.first).to include('statistics')
end end
...@@ -944,7 +944,7 @@ describe API::Groups do ...@@ -944,7 +944,7 @@ describe API::Groups do
post api("/groups", user1), params: group post api("/groups", user1), params: group
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
context 'as owner' do context 'as owner' do
...@@ -955,7 +955,7 @@ describe API::Groups do ...@@ -955,7 +955,7 @@ describe API::Groups do
it 'can create subgroups' do it 'can create subgroups' do
post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' } post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
...@@ -967,7 +967,7 @@ describe API::Groups do ...@@ -967,7 +967,7 @@ describe API::Groups do
it 'can create subgroups' do it 'can create subgroups' do
post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' } post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
end end
...@@ -978,7 +978,7 @@ describe API::Groups do ...@@ -978,7 +978,7 @@ describe API::Groups do
post api("/groups", user3), params: group post api("/groups", user3), params: group
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["name"]).to eq(group[:name]) expect(json_response["name"]).to eq(group[:name])
expect(json_response["path"]).to eq(group[:path]) expect(json_response["path"]).to eq(group[:path])
...@@ -993,7 +993,7 @@ describe API::Groups do ...@@ -993,7 +993,7 @@ describe API::Groups do
post api("/groups", user3), params: group post api("/groups", user3), params: group
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["full_path"]).to eq("#{parent.path}/#{group[:path]}") expect(json_response["full_path"]).to eq("#{parent.path}/#{group[:path]}")
expect(json_response["parent_id"]).to eq(parent.id) expect(json_response["parent_id"]).to eq(parent.id)
...@@ -1002,20 +1002,20 @@ describe API::Groups do ...@@ -1002,20 +1002,20 @@ describe API::Groups do
it "does not create group, duplicate" do it "does not create group, duplicate" do
post api("/groups", user3), params: { name: 'Duplicate Test', path: group2.path } post api("/groups", user3), params: { name: 'Duplicate Test', path: group2.path }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(response.message).to eq("Bad Request") expect(response.message).to eq("Bad Request")
end end
it "returns 400 bad request error if name not given" do it "returns 400 bad request error if name not given" do
post api("/groups", user3), params: { path: group2.path } post api("/groups", user3), params: { path: group2.path }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns 400 bad request error if path not given" do it "returns 400 bad request error if path not given" do
post api("/groups", user3), params: { name: 'test' } post api("/groups", user3), params: { name: 'test' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -1027,7 +1027,7 @@ describe API::Groups do ...@@ -1027,7 +1027,7 @@ describe API::Groups do
expect { delete api("/groups/#{group1.id}", user1) }.to change(GroupDestroyWorker.jobs, :size).by(1) expect { delete api("/groups/#{group1.id}", user1) }.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
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -1041,19 +1041,19 @@ describe API::Groups do ...@@ -1041,19 +1041,19 @@ describe API::Groups do
delete api("/groups/#{group1.id}", user3) delete api("/groups/#{group1.id}", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it "does not remove a non existing group" do it "does not remove a non existing group" do
delete api("/groups/1328", user1) delete api("/groups/1328", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "does not remove a group not attached to user1" do it "does not remove a group not attached to user1" do
delete api("/groups/#{group2.id}", user1) delete api("/groups/#{group2.id}", user1)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -1061,13 +1061,13 @@ describe API::Groups do ...@@ -1061,13 +1061,13 @@ describe API::Groups do
it "removes any existing group" do it "removes any existing group" do
delete api("/groups/#{group2.id}", admin) delete api("/groups/#{group2.id}", admin)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
it "does not remove a non existing group" do it "does not remove a non existing group" do
delete api("/groups/1328", admin) delete api("/groups/1328", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -1086,7 +1086,7 @@ describe API::Groups do ...@@ -1086,7 +1086,7 @@ describe API::Groups do
it "does not transfer project to group" do it "does not transfer project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", user2) post api("/groups/#{group1.id}/projects/#{project.id}", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -1094,7 +1094,7 @@ describe API::Groups do ...@@ -1094,7 +1094,7 @@ describe API::Groups do
it "transfers project to group" do it "transfers project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", admin) post api("/groups/#{group1.id}/projects/#{project.id}", admin)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
context 'when using project path in URL' do context 'when using project path in URL' do
...@@ -1102,7 +1102,7 @@ describe API::Groups do ...@@ -1102,7 +1102,7 @@ describe API::Groups do
it "transfers project to group" do it "transfers project to group" do
post api("/groups/#{group1.id}/projects/#{project_path}", admin) post api("/groups/#{group1.id}/projects/#{project_path}", admin)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
...@@ -1110,7 +1110,7 @@ describe API::Groups do ...@@ -1110,7 +1110,7 @@ describe API::Groups do
it "does not transfer project to group" do it "does not transfer project to group" do
post api("/groups/#{group1.id}/projects/nogroup%2Fnoproject", admin) post api("/groups/#{group1.id}/projects/nogroup%2Fnoproject", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -1120,7 +1120,7 @@ describe API::Groups do ...@@ -1120,7 +1120,7 @@ describe API::Groups do
it "transfers project to group" do it "transfers project to group" do
post api("/groups/#{group1.path}/projects/#{project_path}", admin) post api("/groups/#{group1.path}/projects/#{project_path}", admin)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
...@@ -1128,7 +1128,7 @@ describe API::Groups do ...@@ -1128,7 +1128,7 @@ describe API::Groups do
it "does not transfer project to group" do it "does not transfer project to group" do
post api("/groups/noexist/projects/#{project_path}", admin) post api("/groups/noexist/projects/#{project_path}", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -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
...@@ -66,7 +66,7 @@ describe API::Jobs do ...@@ -66,7 +66,7 @@ describe API::Jobs do
context 'authorized user' do context 'authorized user' do
it 'returns project jobs' do it 'returns project jobs' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
end end
...@@ -122,7 +122,7 @@ describe API::Jobs do ...@@ -122,7 +122,7 @@ describe API::Jobs do
let(:query) { { 'scope' => 'pending' } } let(:query) { { 'scope' => 'pending' } }
it do it do
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
end end
end end
...@@ -131,7 +131,7 @@ describe API::Jobs do ...@@ -131,7 +131,7 @@ describe API::Jobs do
let(:query) { { scope: %w(pending running) } } let(:query) { { scope: %w(pending running) } }
it do it do
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
end end
end end
...@@ -139,7 +139,7 @@ describe API::Jobs do ...@@ -139,7 +139,7 @@ describe API::Jobs do
context 'respond 400 when scope contains invalid state' do context 'respond 400 when scope contains invalid state' do
let(:query) { { scope: %w(unknown running) } } let(:query) { { scope: %w(unknown running) } }
it { expect(response).to have_gitlab_http_status(400) } it { expect(response).to have_gitlab_http_status(:bad_request) }
end end
end end
...@@ -148,7 +148,7 @@ describe API::Jobs do ...@@ -148,7 +148,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not return project jobs' do it 'does not return project jobs' do
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -156,7 +156,7 @@ describe API::Jobs do ...@@ -156,7 +156,7 @@ describe API::Jobs do
let(:api_user) { guest } let(:api_user) { guest }
it 'does not return project jobs' do it 'does not return project jobs' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -178,7 +178,7 @@ describe API::Jobs do ...@@ -178,7 +178,7 @@ describe API::Jobs do
context 'authorized user' do context 'authorized user' do
it 'returns pipeline jobs' do it 'returns pipeline jobs' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
end end
...@@ -210,7 +210,7 @@ describe API::Jobs do ...@@ -210,7 +210,7 @@ describe API::Jobs do
let(:query) { { 'scope' => 'pending' } } let(:query) { { 'scope' => 'pending' } }
it do it do
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
end end
end end
...@@ -219,7 +219,7 @@ describe API::Jobs do ...@@ -219,7 +219,7 @@ describe API::Jobs do
let(:query) { { scope: %w(pending running) } } let(:query) { { scope: %w(pending running) } }
it do it do
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
end end
end end
...@@ -227,7 +227,7 @@ describe API::Jobs do ...@@ -227,7 +227,7 @@ describe API::Jobs do
context 'respond 400 when scope contains invalid state' do context 'respond 400 when scope contains invalid state' do
let(:query) { { scope: %w(unknown running) } } let(:query) { { scope: %w(unknown running) } }
it { expect(response).to have_gitlab_http_status(400) } it { expect(response).to have_gitlab_http_status(:bad_request) }
end end
context 'jobs in different pipelines' do context 'jobs in different pipelines' do
...@@ -257,7 +257,7 @@ describe API::Jobs do ...@@ -257,7 +257,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not return jobs' do it 'does not return jobs' do
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -265,7 +265,7 @@ describe API::Jobs do ...@@ -265,7 +265,7 @@ describe API::Jobs do
let(:api_user) { guest } let(:api_user) { guest }
it 'does not return jobs' do it 'does not return jobs' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -280,7 +280,7 @@ describe API::Jobs do ...@@ -280,7 +280,7 @@ describe API::Jobs do
context 'authorized user' do context 'authorized user' do
it 'returns specific job data' do it 'returns specific job data' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(job.id) expect(json_response['id']).to eq(job.id)
expect(json_response['status']).to eq(job.status) expect(json_response['status']).to eq(job.status)
expect(json_response['stage']).to eq(job.stage) expect(json_response['stage']).to eq(job.stage)
...@@ -319,7 +319,7 @@ describe API::Jobs do ...@@ -319,7 +319,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not return specific job data' do it 'does not return specific job data' do
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -339,7 +339,7 @@ describe API::Jobs do ...@@ -339,7 +339,7 @@ describe API::Jobs do
end end
it 'returns status 401 (unauthorized)' do it 'returns status 401 (unauthorized)' do
expect(response).to have_http_status :unauthorized expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -349,7 +349,7 @@ describe API::Jobs do ...@@ -349,7 +349,7 @@ describe API::Jobs do
end end
it 'returns status 403 (forbidden)' do it 'returns status 403 (forbidden)' do
expect(response).to have_http_status :forbidden expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -362,7 +362,7 @@ describe API::Jobs do ...@@ -362,7 +362,7 @@ describe API::Jobs do
end end
it 'returns status 204 (no content)' do it 'returns status 204 (no content)' do
expect(response).to have_http_status :no_content expect(response).to have_gitlab_http_status(:no_content)
end end
end end
end end
...@@ -386,7 +386,7 @@ describe API::Jobs do ...@@ -386,7 +386,7 @@ describe API::Jobs do
get_artifact_file(artifact) get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -398,7 +398,7 @@ describe API::Jobs do ...@@ -398,7 +398,7 @@ describe API::Jobs do
get_artifact_file(artifact) get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -410,7 +410,7 @@ describe API::Jobs do ...@@ -410,7 +410,7 @@ describe API::Jobs do
get_artifact_file(artifact) get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -423,7 +423,7 @@ describe API::Jobs do ...@@ -423,7 +423,7 @@ describe API::Jobs do
get_artifact_file(artifact) get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h) expect(response.headers.to_h)
.to include('Content-Type' => 'application/json', .to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
...@@ -435,7 +435,7 @@ describe API::Jobs do ...@@ -435,7 +435,7 @@ describe API::Jobs do
it 'does not return job artifact file' do it 'does not return job artifact file' do
get_artifact_file('some/artifact') get_artifact_file('some/artifact')
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -453,7 +453,7 @@ describe API::Jobs do ...@@ -453,7 +453,7 @@ describe API::Jobs do
end end
it 'returns specific job artifacts' do it 'returns specific job artifacts' do
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
...@@ -476,7 +476,7 @@ describe API::Jobs do ...@@ -476,7 +476,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not return specific job artifacts' do it 'does not return specific job artifacts' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -507,7 +507,7 @@ describe API::Jobs do ...@@ -507,7 +507,7 @@ describe API::Jobs do
context 'when proxy download is disabled' do context 'when proxy download is disabled' do
it 'returns location redirect' do it 'returns location redirect' do
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -521,7 +521,7 @@ describe API::Jobs do ...@@ -521,7 +521,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not return specific job artifacts' do it 'does not return specific job artifacts' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -557,7 +557,7 @@ describe API::Jobs do ...@@ -557,7 +557,7 @@ describe API::Jobs do
it 'does not find a resource in a private project' do it 'does not find a resource in a private project' do
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
...@@ -569,7 +569,7 @@ describe API::Jobs do ...@@ -569,7 +569,7 @@ describe API::Jobs do
end end
it 'gives 403' do it 'gives 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -604,7 +604,7 @@ describe API::Jobs do ...@@ -604,7 +604,7 @@ describe API::Jobs do
%Q(attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}) } %Q(attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}) }
end end
it { expect(response).to have_http_status(:ok) } it { expect(response).to have_gitlab_http_status(:ok) }
it { expect(response.headers.to_h).to include(download_headers) } it { expect(response.headers.to_h).to include(download_headers) }
end end
...@@ -619,7 +619,7 @@ describe API::Jobs do ...@@ -619,7 +619,7 @@ describe API::Jobs do
end end
it 'returns location redirect' do it 'returns location redirect' do
expect(response).to have_http_status(:found) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -677,7 +677,7 @@ describe API::Jobs do ...@@ -677,7 +677,7 @@ describe API::Jobs do
let(:public_builds) { true } let(:public_builds) { true }
it 'allows to access artifacts', :sidekiq_might_not_need_inline do it 'allows to access artifacts', :sidekiq_might_not_need_inline do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h) expect(response.headers.to_h)
.to include('Content-Type' => 'application/json', .to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
...@@ -689,7 +689,7 @@ describe API::Jobs do ...@@ -689,7 +689,7 @@ describe API::Jobs do
let(:public_builds) { false } let(:public_builds) { false }
it 'rejects access to artifacts' do it 'rejects access to artifacts' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response).to have_key('message') expect(json_response).to have_key('message')
expect(response.headers.to_h) expect(response.headers.to_h)
.not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/) .not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
...@@ -701,7 +701,7 @@ describe API::Jobs do ...@@ -701,7 +701,7 @@ describe API::Jobs do
let(:public_builds) { true } let(:public_builds) { true }
it 'rejects access and hides existence of artifacts' do it 'rejects access and hides existence of artifacts' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response).to have_key('message') expect(json_response).to have_key('message')
expect(response.headers.to_h) expect(response.headers.to_h)
.not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/) .not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
...@@ -720,7 +720,7 @@ describe API::Jobs do ...@@ -720,7 +720,7 @@ describe API::Jobs do
get_artifact_file(artifact) get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h) expect(response.headers.to_h)
.to include('Content-Type' => 'application/json', .to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
...@@ -737,7 +737,7 @@ describe API::Jobs do ...@@ -737,7 +737,7 @@ describe API::Jobs do
it 'returns a specific artifact file for a valid path', :sidekiq_might_not_need_inline do it 'returns a specific artifact file for a valid path', :sidekiq_might_not_need_inline do
get_artifact_file(artifact, 'improve/awesome') get_artifact_file(artifact, 'improve/awesome')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h) expect(response.headers.to_h)
.to include('Content-Type' => 'application/json', .to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
...@@ -773,7 +773,7 @@ describe API::Jobs do ...@@ -773,7 +773,7 @@ describe API::Jobs do
it 'does not return job artifact file' do it 'does not return job artifact file' do
get_artifact_file('some/artifact') get_artifact_file('some/artifact')
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -803,7 +803,7 @@ describe API::Jobs do ...@@ -803,7 +803,7 @@ describe API::Jobs do
end end
it 'returns specific job trace' do it 'returns specific job trace' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(job.trace.raw) expect(response.body).to eq(job.trace.raw)
end end
end end
...@@ -812,7 +812,7 @@ describe API::Jobs do ...@@ -812,7 +812,7 @@ describe API::Jobs do
let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) } let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
it 'returns specific job trace' do it 'returns specific job trace' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(job.trace.raw) expect(response.body).to eq(job.trace.raw)
end end
end end
...@@ -821,7 +821,7 @@ describe API::Jobs do ...@@ -821,7 +821,7 @@ describe API::Jobs do
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) } let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
it 'returns specific job trace' do it 'returns specific job trace' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(job.trace.raw) expect(response.body).to eq(job.trace.raw)
end end
end end
...@@ -831,7 +831,7 @@ describe API::Jobs do ...@@ -831,7 +831,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not return specific job trace' do it 'does not return specific job trace' do
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -844,7 +844,7 @@ describe API::Jobs do ...@@ -844,7 +844,7 @@ describe API::Jobs do
context 'authorized user' do context 'authorized user' do
context 'user with :update_build persmission' do context 'user with :update_build persmission' do
it 'cancels running or pending job' do it 'cancels running or pending job' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(project.builds.first.status).to eq('success') expect(project.builds.first.status).to eq('success')
end end
end end
...@@ -853,7 +853,7 @@ describe API::Jobs do ...@@ -853,7 +853,7 @@ describe API::Jobs do
let(:api_user) { reporter } let(:api_user) { reporter }
it 'does not cancel job' do it 'does not cancel job' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -862,7 +862,7 @@ describe API::Jobs do ...@@ -862,7 +862,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not cancel job' do it 'does not cancel job' do
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -877,7 +877,7 @@ describe API::Jobs do ...@@ -877,7 +877,7 @@ describe API::Jobs do
context 'authorized user' do context 'authorized user' do
context 'user with :update_build permission' do context 'user with :update_build permission' do
it 'retries non-running job' do it 'retries non-running job' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(project.builds.first.status).to eq('canceled') expect(project.builds.first.status).to eq('canceled')
expect(json_response['status']).to eq('pending') expect(json_response['status']).to eq('pending')
end end
...@@ -887,7 +887,7 @@ describe API::Jobs do ...@@ -887,7 +887,7 @@ describe API::Jobs do
let(:api_user) { reporter } let(:api_user) { reporter }
it 'does not retry job' do it 'does not retry job' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -896,7 +896,7 @@ describe API::Jobs do ...@@ -896,7 +896,7 @@ describe API::Jobs do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not retry job' do it 'does not retry job' do
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -914,7 +914,7 @@ describe API::Jobs do ...@@ -914,7 +914,7 @@ describe API::Jobs do
let(:job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, :success, project: project, pipeline: pipeline) } let(:job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, :success, project: project, pipeline: pipeline) }
it 'erases job content' do it 'erases job content' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.job_artifacts.count).to eq(0) expect(job.job_artifacts.count).to eq(0)
expect(job.trace.exist?).to be_falsy expect(job.trace.exist?).to be_falsy
expect(job.artifacts_file.present?).to be_falsy expect(job.artifacts_file.present?).to be_falsy
...@@ -934,7 +934,7 @@ describe API::Jobs do ...@@ -934,7 +934,7 @@ describe API::Jobs do
let(:job) { create(:ci_build, :trace_live, project: project, pipeline: pipeline) } let(:job) { create(:ci_build, :trace_live, project: project, pipeline: pipeline) }
it 'responds with forbidden' do it 'responds with forbidden' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -945,13 +945,13 @@ describe API::Jobs do ...@@ -945,13 +945,13 @@ describe API::Jobs do
context 'when the build was created by the developer' do context 'when the build was created by the developer' do
let(:owner) { user } let(:owner) { user }
it { expect(response).to have_gitlab_http_status(201) } it { expect(response).to have_gitlab_http_status(:created) }
end end
context 'when the build was created by the other' do context 'when the build was created by the other' do
let(:owner) { create(:user) } let(:owner) { create(:user) }
it { expect(response).to have_gitlab_http_status(403) } it { expect(response).to have_gitlab_http_status(:forbidden) }
end end
end end
end end
...@@ -968,7 +968,7 @@ describe API::Jobs do ...@@ -968,7 +968,7 @@ describe API::Jobs do
end end
it 'keeps artifacts' do it 'keeps artifacts' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(job.reload.artifacts_expire_at).to be_nil expect(job.reload.artifacts_expire_at).to be_nil
end end
end end
...@@ -977,7 +977,7 @@ describe API::Jobs do ...@@ -977,7 +977,7 @@ describe API::Jobs do
let(:job) { create(:ci_build, project: project, pipeline: pipeline) } let(:job) { create(:ci_build, project: project, pipeline: pipeline) }
it 'responds with not found' do it 'responds with not found' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -992,7 +992,7 @@ describe API::Jobs do ...@@ -992,7 +992,7 @@ describe API::Jobs do
context 'when user is authorized to trigger a manual action' do context 'when user is authorized to trigger a manual action' do
it 'plays the job' do it 'plays the job' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
expect(json_response['id']).to eq(job.id) expect(json_response['id']).to eq(job.id)
expect(job.reload).to be_pending expect(job.reload).to be_pending
...@@ -1005,7 +1005,7 @@ describe API::Jobs do ...@@ -1005,7 +1005,7 @@ describe API::Jobs do
it 'does not trigger a manual action' do it 'does not trigger a manual action' do
expect(job.reload).to be_manual expect(job.reload).to be_manual
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -1014,7 +1014,7 @@ describe API::Jobs do ...@@ -1014,7 +1014,7 @@ describe API::Jobs do
it 'does not trigger a manual action' do it 'does not trigger a manual action' do
expect(job.reload).to be_manual expect(job.reload).to be_manual
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -1022,7 +1022,7 @@ describe API::Jobs do ...@@ -1022,7 +1022,7 @@ describe API::Jobs do
context 'on a non-playable job' do context 'on a non-playable job' do
it 'returns a status code 400, Bad Request' do it 'returns a status code 400, Bad Request' do
expect(response).to have_gitlab_http_status 400 expect(response).to have_gitlab_http_status(:bad_request)
expect(response.body).to match("Unplayable Job") expect(response.body).to match("Unplayable Job")
end end
end end
......
...@@ -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)
......
...@@ -27,7 +27,7 @@ describe API::Labels do ...@@ -27,7 +27,7 @@ describe API::Labels do
it "returns 200 if name is changed (#{route_type} route)" do it "returns 200 if name is changed (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, new_name: 'New Label') put_labels_api(route_type, user, spec_params, new_name: 'New Label')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('New Label') expect(json_response['name']).to eq('New Label')
expect(json_response['color']).to eq(label1.color) expect(json_response['color']).to eq(label1.color)
end end
...@@ -35,7 +35,7 @@ describe API::Labels do ...@@ -35,7 +35,7 @@ describe API::Labels do
it "returns 200 if colors is changed (#{route_type} route)" do it "returns 200 if colors is changed (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, color: '#FFFFFF') put_labels_api(route_type, user, spec_params, color: '#FFFFFF')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(label1.name) expect(json_response['name']).to eq(label1.name)
expect(json_response['color']).to eq('#FFFFFF') expect(json_response['color']).to eq('#FFFFFF')
end end
...@@ -51,7 +51,7 @@ describe API::Labels do ...@@ -51,7 +51,7 @@ describe API::Labels do
it "returns 400 if no new parameters given (#{route_type} route)" do it "returns 400 if no new parameters given (#{route_type} route)" do
put_labels_api(route_type, user, spec_params) put_labels_api(route_type, user, spec_params)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('new_name, color, description, priority are missing, '\ expect(json_response['error']).to eq('new_name, color, description, priority are missing, '\
'at least one parameter must be provided') 'at least one parameter must be provided')
end end
...@@ -59,27 +59,27 @@ describe API::Labels do ...@@ -59,27 +59,27 @@ describe API::Labels do
it "returns 400 when color code is too short (#{route_type} route)" do it "returns 400 when color code is too short (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, color: '#FF') put_labels_api(route_type, user, spec_params, color: '#FF')
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['color']).to eq(['must be a valid color code']) expect(json_response['message']['color']).to eq(['must be a valid color code'])
end end
it "returns 400 for too long color code (#{route_type} route)" do it "returns 400 for too long color code (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, color: '#FFAAFFFF') put_labels_api(route_type, user, spec_params, color: '#FFAAFFFF')
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['color']).to eq(['must be a valid color code']) expect(json_response['message']['color']).to eq(['must be a valid color code'])
end end
it "returns 400 for invalid priority (#{route_type} route)" do it "returns 400 for invalid priority (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, priority: 'foo') put_labels_api(route_type, user, spec_params, priority: 'foo')
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns 200 if name and colors and description are changed (#{route_type} route)" do it "returns 200 if name and colors and description are changed (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, new_name: 'New Label', color: '#FFFFFF', description: 'test') put_labels_api(route_type, user, spec_params, new_name: 'New Label', color: '#FFFFFF', description: 'test')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('New Label') expect(json_response['name']).to eq('New Label')
expect(json_response['color']).to eq('#FFFFFF') expect(json_response['color']).to eq('#FFFFFF')
expect(json_response['description']).to eq('test') expect(json_response['description']).to eq('test')
...@@ -88,14 +88,14 @@ describe API::Labels do ...@@ -88,14 +88,14 @@ describe API::Labels do
it "returns 400 for invalid name (#{route_type} route)" do it "returns 400 for invalid name (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, new_name: ',', color: '#FFFFFF') put_labels_api(route_type, user, spec_params, new_name: ',', color: '#FFFFFF')
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['title']).to eq(['is invalid']) expect(json_response['message']['title']).to eq(['is invalid'])
end end
it "returns 200 if description is changed (#{route_type} route)" do it "returns 200 if description is changed (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, description: 'test') put_labels_api(route_type, user, spec_params, description: 'test')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(expected_response_label_id) expect(json_response['id']).to eq(expected_response_label_id)
expect(json_response['description']).to eq('test') expect(json_response['description']).to eq('test')
end end
...@@ -162,14 +162,14 @@ describe API::Labels do ...@@ -162,14 +162,14 @@ describe API::Labels do
it 'returns 204 for existing label (deprecated route)' do it 'returns 204 for existing label (deprecated route)' do
delete api("/projects/#{project.id}/labels", user), params: spec_params delete api("/projects/#{project.id}/labels", user), params: spec_params
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'returns 204 for existing label (rest route)' do it 'returns 204 for existing label (rest route)' do
label_id = spec_params[:name] || spec_params[:label_id] label_id = spec_params[:name] || spec_params[:label_id]
delete api("/projects/#{project.id}/labels/#{label_id}", user), params: spec_params.except(:name, :label_id) delete api("/projects/#{project.id}/labels/#{label_id}", user), params: spec_params.except(:name, :label_id)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
...@@ -188,7 +188,7 @@ describe API::Labels do ...@@ -188,7 +188,7 @@ describe API::Labels do
it 'returns all available labels to the project' do it 'returns all available labels to the project' do
get api("/projects/#{project.id}/labels", user) get api("/projects/#{project.id}/labels", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to all(match_schema('public_api/v4/labels/project_label')) expect(json_response).to all(match_schema('public_api/v4/labels/project_label'))
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
...@@ -205,7 +205,7 @@ describe API::Labels do ...@@ -205,7 +205,7 @@ describe API::Labels do
it 'includes counts in the response' do it 'includes counts in the response' do
get api("/projects/#{project.id}/labels", user), params: { with_counts: true } get api("/projects/#{project.id}/labels", user), params: { with_counts: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to all(match_schema('public_api/v4/labels/project_label_with_counts')) expect(json_response).to all(match_schema('public_api/v4/labels/project_label_with_counts'))
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
...@@ -264,7 +264,7 @@ describe API::Labels do ...@@ -264,7 +264,7 @@ describe API::Labels do
it 'returns all available labels for the project, parent group and ancestor groups' do it 'returns all available labels for the project, parent group and ancestor groups' do
get api("/projects/#{project.id}/labels", user) get api("/projects/#{project.id}/labels", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label')) expect(json_response).to all(match_schema('public_api/v4/labels/label'))
...@@ -287,7 +287,7 @@ describe API::Labels do ...@@ -287,7 +287,7 @@ describe API::Labels do
it 'returns all available labels for the project and the parent group only' do it 'returns all available labels for the project and the parent group only' do
get api("/projects/#{project.id}/labels", user), params: { include_ancestor_groups: false } get api("/projects/#{project.id}/labels", user), params: { include_ancestor_groups: false }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label')) expect(json_response).to all(match_schema('public_api/v4/labels/label'))
...@@ -307,7 +307,7 @@ describe API::Labels do ...@@ -307,7 +307,7 @@ describe API::Labels do
priority: 2 priority: 2
} }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq('Foo') expect(json_response['name']).to eq('Foo')
expect(json_response['color']).to eq('#FFAABB') expect(json_response['color']).to eq('#FFAABB')
expect(json_response['description']).to eq('test') expect(json_response['description']).to eq('test')
...@@ -345,12 +345,12 @@ describe API::Labels do ...@@ -345,12 +345,12 @@ describe API::Labels do
it 'returns a 400 bad request if name not given' do it 'returns a 400 bad request if name not given' do
post api("/projects/#{project.id}/labels", user), params: { color: '#FFAABB' } post api("/projects/#{project.id}/labels", user), params: { color: '#FFAABB' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns a 400 bad request if color not given' do it 'returns a 400 bad request if color not given' do
post api("/projects/#{project.id}/labels", user), params: { name: 'Foobar' } post api("/projects/#{project.id}/labels", user), params: { name: 'Foobar' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 400 for invalid color' do it 'returns 400 for invalid color' do
...@@ -359,7 +359,7 @@ describe API::Labels do ...@@ -359,7 +359,7 @@ describe API::Labels do
name: 'Foo', name: 'Foo',
color: '#FFAA' color: '#FFAA'
} }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['color']).to eq(['must be a valid color code']) expect(json_response['message']['color']).to eq(['must be a valid color code'])
end end
...@@ -369,7 +369,7 @@ describe API::Labels do ...@@ -369,7 +369,7 @@ describe API::Labels do
name: 'Foo', name: 'Foo',
color: '#FFAAFFFF' color: '#FFAAFFFF'
} }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['color']).to eq(['must be a valid color code']) expect(json_response['message']['color']).to eq(['must be a valid color code'])
end end
...@@ -379,7 +379,7 @@ describe API::Labels do ...@@ -379,7 +379,7 @@ describe API::Labels do
name: ',', name: ',',
color: '#FFAABB' color: '#FFAABB'
} }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['title']).to eq(['is invalid']) expect(json_response['message']['title']).to eq(['is invalid'])
end end
...@@ -394,7 +394,7 @@ describe API::Labels do ...@@ -394,7 +394,7 @@ describe API::Labels do
color: '#FFAABB' color: '#FFAABB'
} }
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Label already exists') expect(json_response['message']).to eq('Label already exists')
end end
...@@ -406,7 +406,7 @@ describe API::Labels do ...@@ -406,7 +406,7 @@ describe API::Labels do
priority: 'foo' priority: 'foo'
} }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 409 if label already exists in project' do it 'returns 409 if label already exists in project' do
...@@ -415,7 +415,7 @@ describe API::Labels do ...@@ -415,7 +415,7 @@ describe API::Labels do
name: 'label1', name: 'label1',
color: '#FFAABB' color: '#FFAABB'
} }
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Label already exists') expect(json_response['message']).to eq('Label already exists')
end end
end end
...@@ -432,14 +432,14 @@ describe API::Labels do ...@@ -432,14 +432,14 @@ describe API::Labels do
it 'returns 404 for non existing label' do it 'returns 404 for non existing label' do
delete api("/projects/#{project.id}/labels", user), params: { name: 'label2' } delete api("/projects/#{project.id}/labels", user), params: { name: 'label2' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Label Not Found') expect(json_response['message']).to eq('404 Label Not Found')
end end
it 'returns 400 for wrong parameters' do it 'returns 400 for wrong parameters' do
delete api("/projects/#{project.id}/labels", user) delete api("/projects/#{project.id}/labels", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'fails if label_id and name are given in params' do it 'fails if label_id and name are given in params' do
...@@ -449,7 +449,7 @@ describe API::Labels do ...@@ -449,7 +449,7 @@ describe API::Labels do
name: priority_label.name name: priority_label.name
} }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -480,7 +480,7 @@ describe API::Labels do ...@@ -480,7 +480,7 @@ describe API::Labels do
new_name: 'label3' new_name: 'label3'
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 if label by id does not exist' do it 'returns 404 if label by id does not exist' do
...@@ -490,13 +490,13 @@ describe API::Labels do ...@@ -490,13 +490,13 @@ describe API::Labels do
new_name: 'label3' new_name: 'label3'
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 400 if no label name and id is given' do it 'returns 400 if no label name and id is given' do
put api("/projects/#{project.id}/labels", user), params: { new_name: 'label2' } put api("/projects/#{project.id}/labels", user), params: { new_name: 'label2' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('label_id, name are missing, exactly one parameter must be provided') expect(json_response['error']).to eq('label_id, name are missing, exactly one parameter must be provided')
end end
...@@ -508,7 +508,7 @@ describe API::Labels do ...@@ -508,7 +508,7 @@ describe API::Labels do
new_name: 'New Label' new_name: 'New Label'
} }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -523,7 +523,7 @@ describe API::Labels do ...@@ -523,7 +523,7 @@ describe API::Labels do
it 'returns 200 if label is promoted' do it 'returns 200 if label is promoted' do
put api("/projects/#{project.id}/labels/promote", user), params: { name: label1.name } put api("/projects/#{project.id}/labels/promote", user), params: { name: label1.name }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(label1.name) expect(json_response['name']).to eq(label1.name)
expect(json_response['color']).to eq(label1.color) expect(json_response['color']).to eq(label1.color)
end end
...@@ -535,7 +535,7 @@ describe API::Labels do ...@@ -535,7 +535,7 @@ describe API::Labels do
.to change(project.labels, :count).by(-1) .to change(project.labels, :count).by(-1)
.and change(group.labels, :count).by(0) .and change(group.labels, :count).by(0)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'returns 403 if guest promotes label' do it 'returns 403 if guest promotes label' do
...@@ -544,19 +544,19 @@ describe API::Labels do ...@@ -544,19 +544,19 @@ describe API::Labels do
put api("/projects/#{project.id}/labels/promote", guest), params: { name: label1.name } put api("/projects/#{project.id}/labels/promote", guest), params: { name: label1.name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'returns 404 if label does not exist' do it 'returns 404 if label does not exist' do
put api("/projects/#{project.id}/labels/promote", user), params: { name: 'unknown' } put api("/projects/#{project.id}/labels/promote", user), params: { name: 'unknown' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 400 if no label name given' do it 'returns 400 if no label name given' do
put api("/projects/#{project.id}/labels/promote", user) put api("/projects/#{project.id}/labels/promote", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('name is missing') expect(json_response['error']).to eq('name is missing')
end end
end end
...@@ -566,7 +566,7 @@ describe API::Labels do ...@@ -566,7 +566,7 @@ describe API::Labels do
it "subscribes to the label" do it "subscribes to the label" do
post api("/projects/#{project.id}/labels/#{label1.title}/subscribe", user) post api("/projects/#{project.id}/labels/#{label1.title}/subscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["name"]).to eq(label1.title) expect(json_response["name"]).to eq(label1.title)
expect(json_response["subscribed"]).to be_truthy expect(json_response["subscribed"]).to be_truthy
end end
...@@ -576,7 +576,7 @@ describe API::Labels do ...@@ -576,7 +576,7 @@ describe API::Labels do
it "subscribes to the label" do it "subscribes to the label" do
post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user) post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["name"]).to eq(label1.title) expect(json_response["name"]).to eq(label1.title)
expect(json_response["subscribed"]).to be_truthy expect(json_response["subscribed"]).to be_truthy
end end
...@@ -590,7 +590,7 @@ describe API::Labels do ...@@ -590,7 +590,7 @@ describe API::Labels do
it "returns 304" do it "returns 304" do
post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user) post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user)
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
end end
end end
...@@ -598,7 +598,7 @@ describe API::Labels do ...@@ -598,7 +598,7 @@ describe API::Labels do
it "returns 404 error" do it "returns 404 error" do
post api("/projects/#{project.id}/labels/1234/subscribe", user) post api("/projects/#{project.id}/labels/1234/subscribe", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -612,7 +612,7 @@ describe API::Labels do ...@@ -612,7 +612,7 @@ describe API::Labels do
it "unsubscribes from the label" do it "unsubscribes from the label" do
post api("/projects/#{project.id}/labels/#{label1.title}/unsubscribe", user) post api("/projects/#{project.id}/labels/#{label1.title}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["name"]).to eq(label1.title) expect(json_response["name"]).to eq(label1.title)
expect(json_response["subscribed"]).to be_falsey expect(json_response["subscribed"]).to be_falsey
end end
...@@ -622,7 +622,7 @@ describe API::Labels do ...@@ -622,7 +622,7 @@ describe API::Labels do
it "unsubscribes from the label" do it "unsubscribes from the label" do
post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user) post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["name"]).to eq(label1.title) expect(json_response["name"]).to eq(label1.title)
expect(json_response["subscribed"]).to be_falsey expect(json_response["subscribed"]).to be_falsey
end end
...@@ -636,7 +636,7 @@ describe API::Labels do ...@@ -636,7 +636,7 @@ describe API::Labels do
it "returns 304" do it "returns 304" do
post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user) post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
end end
end end
...@@ -644,7 +644,7 @@ describe API::Labels do ...@@ -644,7 +644,7 @@ describe API::Labels do
it "returns 404 error" do it "returns 404 error" do
post api("/projects/#{project.id}/labels/1234/unsubscribe", user) post api("/projects/#{project.id}/labels/1234/unsubscribe", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -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