Commit f4e1b246 authored by Peter Leitzen's avatar Peter Leitzen

Add http status cop to api specs a-s

243 files inspected, 343 offenses detected, 343 offenses corrected
parent e8fb1e9f
...@@ -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-p]*.rb' - 'spec/requests/api/[a-s]*.rb'
- 'ee/spec/requests/api/[a-p]*.rb' - 'ee/spec/requests/api/[a-s]*.rb'
Style/MultilineWhenThen: Style/MultilineWhenThen:
Enabled: false Enabled: false
......
...@@ -43,7 +43,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -43,7 +43,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
expect(build).to be_running expect(build).to be_running
expect(build.runner).to eq(runner) expect(build.runner).to eq(runner)
expect(response).to have_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(json_response).to include( expect(json_response).to include(
"id" => build.id, "id" => build.id,
"variables" => include("key" => 'KEY', "value" => 'value', "public" => true, "masked" => false), "variables" => include("key" => 'KEY', "value" => 'value', "public" => true, "masked" => false),
...@@ -60,7 +60,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -60,7 +60,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
build.reload build.reload
expect(build).to be_pending expect(build).to be_pending
expect(response).to have_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
end end
......
...@@ -19,14 +19,14 @@ describe API::Scim do ...@@ -19,14 +19,14 @@ describe API::Scim do
it 'responds with 401' do it 'responds with 401' do
get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id eq \"#{identity.extern_uid}\"", token: false) get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id eq \"#{identity.extern_uid}\"", token: false)
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
it 'responds with paginated users when there is no filter' do it 'responds with paginated users when there is no filter' do
get scim_api("scim/v2/groups/#{group.full_path}/Users") get scim_api("scim/v2/groups/#{group.full_path}/Users")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['Resources']).not_to be_empty expect(json_response['Resources']).not_to be_empty
expect(json_response['totalResults']).to eq(Identity.count) expect(json_response['totalResults']).to eq(Identity.count)
end end
...@@ -34,14 +34,14 @@ describe API::Scim do ...@@ -34,14 +34,14 @@ describe API::Scim do
it 'responds with an error for unsupported filters' do it 'responds with an error for unsupported filters' do
get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id ne \"#{identity.extern_uid}\"") get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id ne \"#{identity.extern_uid}\"")
expect(response).to have_gitlab_http_status(412) expect(response).to have_gitlab_http_status(:precondition_failed)
end end
context 'existing user matches filter' do context 'existing user matches filter' do
it 'responds with 200' do it 'responds with 200' do
get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id eq \"#{identity.extern_uid}\"") get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id eq \"#{identity.extern_uid}\"")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['Resources']).not_to be_empty expect(json_response['Resources']).not_to be_empty
expect(json_response['totalResults']).to eq(1) expect(json_response['totalResults']).to eq(1)
end end
...@@ -59,7 +59,7 @@ describe API::Scim do ...@@ -59,7 +59,7 @@ describe API::Scim do
it 'responds with 200' do it 'responds with 200' do
get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id eq \"nonexistent\"") get scim_api("scim/v2/groups/#{group.full_path}/Users?filter=id eq \"nonexistent\"")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['Resources']).to be_empty expect(json_response['Resources']).to be_empty
expect(json_response['totalResults']).to eq(0) expect(json_response['totalResults']).to eq(0)
end end
...@@ -70,14 +70,14 @@ describe API::Scim do ...@@ -70,14 +70,14 @@ describe API::Scim do
it 'responds with 404 if there is no user' do it 'responds with 404 if there is no user' do
get scim_api("scim/v2/groups/#{group.full_path}/Users/123") get scim_api("scim/v2/groups/#{group.full_path}/Users/123")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'existing user' do context 'existing user' do
it 'responds with 200' do it 'responds with 200' do
get scim_api("scim/v2/groups/#{group.full_path}/Users/#{identity.extern_uid}") get scim_api("scim/v2/groups/#{group.full_path}/Users/#{identity.extern_uid}")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(identity.extern_uid) expect(json_response['id']).to eq(identity.extern_uid)
end end
end end
...@@ -105,7 +105,7 @@ describe API::Scim do ...@@ -105,7 +105,7 @@ describe API::Scim 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 'has the user external ID' do it 'has the user external ID' do
...@@ -167,7 +167,7 @@ describe API::Scim do ...@@ -167,7 +167,7 @@ describe API::Scim do
end end
it 'returns user error' do it 'returns user error' do
expect(response).to have_gitlab_http_status(412) expect(response).to have_gitlab_http_status(:precondition_failed)
expect(json_response.fetch('detail')).to include("Email can't be blank") expect(json_response.fetch('detail')).to include("Email can't be blank")
end end
end end
...@@ -200,7 +200,7 @@ describe API::Scim do ...@@ -200,7 +200,7 @@ describe API::Scim 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 'has the user external ID' do it 'has the user external ID' do
...@@ -213,7 +213,7 @@ describe API::Scim do ...@@ -213,7 +213,7 @@ describe API::Scim do
it 'responds with 404 if there is no user' do it 'responds with 404 if there is no user' do
patch scim_api("scim/v2/groups/#{group.full_path}/Users/123") patch scim_api("scim/v2/groups/#{group.full_path}/Users/123")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'existing user' do context 'existing user' do
...@@ -225,7 +225,7 @@ describe API::Scim do ...@@ -225,7 +225,7 @@ describe API::Scim 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 'updates the extern_uid' do it 'updates the extern_uid' do
...@@ -241,7 +241,7 @@ describe API::Scim do ...@@ -241,7 +241,7 @@ describe API::Scim 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 'updates the name' do it 'updates the name' do
...@@ -266,7 +266,7 @@ describe API::Scim do ...@@ -266,7 +266,7 @@ describe API::Scim 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
end end
...@@ -284,7 +284,7 @@ describe API::Scim do ...@@ -284,7 +284,7 @@ describe API::Scim do
end end
it 'responds with 209' do it 'responds with 209' do
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
end end
end end
end end
...@@ -297,7 +297,7 @@ describe API::Scim do ...@@ -297,7 +297,7 @@ describe API::Scim 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 'removes the identity link' do it 'removes the identity link' do
...@@ -314,7 +314,7 @@ describe API::Scim do ...@@ -314,7 +314,7 @@ describe API::Scim 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 'removes the identity link' do it 'removes the identity link' do
...@@ -329,7 +329,7 @@ describe API::Scim do ...@@ -329,7 +329,7 @@ describe API::Scim do
it 'responds with 404 if there is no user' do it 'responds with 404 if there is no user' do
delete scim_api("scim/v2/groups/#{group.full_path}/Users/123") delete scim_api("scim/v2/groups/#{group.full_path}/Users/123")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -21,7 +21,7 @@ describe API::Services do ...@@ -21,7 +21,7 @@ describe API::Services do
it 'returns status 200' do it 'returns status 200' do
post api('/slack/trigger'), params: { token: 'token', text: 'help' } post api('/slack/trigger'), params: { token: 'token', text: 'help' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['response_type']).to eq("ephemeral") expect(json_response['response_type']).to eq("ephemeral")
end end
end end
......
...@@ -23,7 +23,7 @@ describe API::Settings, 'EE Settings' do ...@@ -23,7 +23,7 @@ describe API::Settings, 'EE Settings' do
file_template_project_id: project.id file_template_project_id: project.id
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['help_text']).to eq('Help text') expect(json_response['help_text']).to eq('Help text')
expect(json_response['file_template_project_id']).to eq(project.id) expect(json_response['file_template_project_id']).to eq(project.id)
end end
...@@ -40,7 +40,7 @@ describe API::Settings, 'EE Settings' do ...@@ -40,7 +40,7 @@ describe API::Settings, 'EE Settings' do
elasticsearch_namespace_ids: namespace_ids.join(',') elasticsearch_namespace_ids: namespace_ids.join(',')
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['elasticsearch_limit_indexing']).to eq(true) expect(json_response['elasticsearch_limit_indexing']).to eq(true)
expect(json_response['elasticsearch_project_ids']).to eq(project_ids) expect(json_response['elasticsearch_project_ids']).to eq(project_ids)
expect(json_response['elasticsearch_namespace_ids']).to eq(namespace_ids) expect(json_response['elasticsearch_namespace_ids']).to eq(namespace_ids)
...@@ -61,7 +61,7 @@ describe API::Settings, 'EE Settings' do ...@@ -61,7 +61,7 @@ describe API::Settings, 'EE Settings' do
'CONTENT_TYPE' => 'application/json' 'CONTENT_TYPE' => 'application/json'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['elasticsearch_namespace_ids']).to eq([]) expect(json_response['elasticsearch_namespace_ids']).to eq([])
expect(ElasticsearchIndexedNamespace.count).to eq(0) expect(ElasticsearchIndexedNamespace.count).to eq(0)
expect(ElasticsearchIndexedProject.count).to eq(1) expect(ElasticsearchIndexedProject.count).to eq(1)
...@@ -85,7 +85,7 @@ describe API::Settings, 'EE Settings' do ...@@ -85,7 +85,7 @@ describe API::Settings, 'EE Settings' do
it 'hides the attributes in the API' do it 'hides the attributes in the API' do
get api("/application/settings", admin) get api("/application/settings", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
attribute_names.each do |attribute| attribute_names.each do |attribute|
expect(json_response.keys).not_to include(attribute) expect(json_response.keys).not_to include(attribute)
end end
...@@ -105,7 +105,7 @@ describe API::Settings, 'EE Settings' do ...@@ -105,7 +105,7 @@ describe API::Settings, 'EE Settings' do
it 'includes the attributes in the API' do it 'includes the attributes in the API' do
get api("/application/settings", admin) get api("/application/settings", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
attribute_names.each do |attribute| attribute_names.each do |attribute|
expect(json_response.keys).to include(attribute) expect(json_response.keys).to include(attribute)
end end
...@@ -113,7 +113,7 @@ describe API::Settings, 'EE Settings' do ...@@ -113,7 +113,7 @@ describe API::Settings, 'EE Settings' do
it 'allows updating the settings' do it 'allows updating the settings' do
put api("/application/settings", admin), params: settings put api("/application/settings", admin), params: settings
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
settings.each do |attribute, value| settings.each do |attribute, value|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value) expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
......
...@@ -19,7 +19,7 @@ describe API::Repositories do ...@@ -19,7 +19,7 @@ describe API::Repositories do
it 'returns the repository tree' do it 'returns the repository tree' do
get api(route, current_user) get api(route, current_user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -108,7 +108,7 @@ describe API::Repositories do ...@@ -108,7 +108,7 @@ describe API::Repositories do
it 'returns blob attributes as json' do it 'returns blob attributes as json' do
get api(route, current_user) get api(route, current_user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['size']).to eq(111) expect(json_response['size']).to eq(111)
expect(json_response['encoding']).to eq("base64") expect(json_response['encoding']).to eq("base64")
expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n") expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n")
...@@ -167,7 +167,7 @@ describe API::Repositories do ...@@ -167,7 +167,7 @@ describe API::Repositories do
get api(route, current_user) get api(route, current_user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" expect(headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end end
...@@ -231,7 +231,7 @@ describe API::Repositories do ...@@ -231,7 +231,7 @@ describe API::Repositories do
it 'returns the repository archive' do it 'returns the repository archive' do
get api(route, current_user) get api(route, current_user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
type, params = workhorse_send_data type, params = workhorse_send_data
...@@ -242,7 +242,7 @@ describe API::Repositories do ...@@ -242,7 +242,7 @@ describe API::Repositories do
it 'returns the repository archive archive.zip' do it 'returns the repository archive archive.zip' do
get api("/projects/#{project.id}/repository/archive.zip", user) get api("/projects/#{project.id}/repository/archive.zip", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
type, params = workhorse_send_data type, params = workhorse_send_data
...@@ -253,7 +253,7 @@ describe API::Repositories do ...@@ -253,7 +253,7 @@ describe API::Repositories do
it 'returns the repository archive archive.tar.bz2' do it 'returns the repository archive archive.tar.bz2' do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user) get api("/projects/#{project.id}/repository/archive.tar.bz2", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
type, params = workhorse_send_data type, params = workhorse_send_data
...@@ -314,7 +314,7 @@ describe API::Repositories do ...@@ -314,7 +314,7 @@ describe API::Repositories do
}).and_call_original }).and_call_original
get api(route, current_user), params: { from: 'master', to: 'feature' } get api(route, current_user), params: { from: 'master', to: 'feature' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
...@@ -325,7 +325,7 @@ describe API::Repositories do ...@@ -325,7 +325,7 @@ describe API::Repositories do
}).and_call_original }).and_call_original
get api(route, current_user), params: { from: 'master', to: 'feature', straight: false } get api(route, current_user), params: { from: 'master', to: 'feature', straight: false }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
...@@ -336,7 +336,7 @@ describe API::Repositories do ...@@ -336,7 +336,7 @@ describe API::Repositories do
}).and_call_original }).and_call_original
get api(route, current_user), params: { from: 'master', to: 'feature', straight: true } get api(route, current_user), params: { from: 'master', to: 'feature', straight: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
...@@ -344,7 +344,7 @@ describe API::Repositories do ...@@ -344,7 +344,7 @@ describe API::Repositories do
it "compares tags" do it "compares tags" do
get api(route, current_user), params: { from: 'v1.0.0', to: 'v1.1.0' } get api(route, current_user), params: { from: 'v1.0.0', to: 'v1.1.0' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
...@@ -352,7 +352,7 @@ describe API::Repositories do ...@@ -352,7 +352,7 @@ describe API::Repositories do
it "compares commits" do it "compares commits" do
get api(route, current_user), params: { from: sample_commit.id, to: sample_commit.parent_id } get api(route, current_user), params: { from: sample_commit.id, to: sample_commit.parent_id }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_empty expect(json_response['commits']).to be_empty
expect(json_response['diffs']).to be_empty expect(json_response['diffs']).to be_empty
expect(json_response['compare_same_ref']).to be_falsey expect(json_response['compare_same_ref']).to be_falsey
...@@ -361,7 +361,7 @@ describe API::Repositories do ...@@ -361,7 +361,7 @@ describe API::Repositories do
it "compares commits in reverse order" do it "compares commits in reverse order" do
get api(route, current_user), params: { from: sample_commit.parent_id, to: sample_commit.id } get api(route, current_user), params: { from: sample_commit.parent_id, to: sample_commit.id }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
...@@ -369,7 +369,7 @@ describe API::Repositories do ...@@ -369,7 +369,7 @@ describe API::Repositories do
it "compares same refs" do it "compares same refs" do
get api(route, current_user), params: { from: 'master', to: 'master' } get api(route, current_user), params: { from: 'master', to: 'master' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_empty expect(json_response['commits']).to be_empty
expect(json_response['diffs']).to be_empty expect(json_response['diffs']).to be_empty
expect(json_response['compare_same_ref']).to be_truthy expect(json_response['compare_same_ref']).to be_truthy
...@@ -380,7 +380,7 @@ describe API::Repositories do ...@@ -380,7 +380,7 @@ describe API::Repositories do
get api(route, current_user), params: { from: 'master', to: 'feature' } get api(route, current_user), params: { from: 'master', to: 'feature' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
expect(json_response['diffs'].first['diff']).to be_empty expect(json_response['diffs'].first['diff']).to be_empty
...@@ -389,13 +389,13 @@ describe API::Repositories do ...@@ -389,13 +389,13 @@ describe API::Repositories do
it "returns a 404 when from ref is unknown" do it "returns a 404 when from ref is unknown" do
get api(route, current_user), params: { from: 'unknown_ref', to: 'master' } get api(route, current_user), params: { from: 'unknown_ref', to: 'master' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns a 404 when to ref is unknown" do it "returns a 404 when to ref is unknown" do
get api(route, current_user), params: { from: 'master', to: 'unknown_ref' } get api(route, current_user), params: { from: 'master', to: 'unknown_ref' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -433,7 +433,7 @@ describe API::Repositories do ...@@ -433,7 +433,7 @@ describe API::Repositories do
it 'returns valid data' do it 'returns valid data' do
get api(route, current_user) get api(route, current_user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -450,7 +450,7 @@ describe API::Repositories do ...@@ -450,7 +450,7 @@ describe API::Repositories do
it 'returns the repository contribuors sorted by commits desc' do it 'returns the repository contribuors sorted by commits desc' do
get api(route, current_user), params: { order_by: 'commits', sort: 'desc' } get api(route, current_user), params: { order_by: 'commits', sort: 'desc' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('contributors') expect(response).to match_response_schema('contributors')
expect(json_response.first['commits']).to be > json_response.last['commits'] expect(json_response.first['commits']).to be > json_response.last['commits']
end end
...@@ -460,7 +460,7 @@ describe API::Repositories do ...@@ -460,7 +460,7 @@ describe API::Repositories do
it 'returns the repository contribuors sorted by name asc case insensitive' do it 'returns the repository contribuors sorted by name asc case insensitive' do
get api(route, current_user), params: { order_by: 'name', sort: 'asc' } get api(route, current_user), params: { order_by: 'name', sort: 'asc' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('contributors') expect(response).to match_response_schema('contributors')
expect(json_response.first['name'].downcase).to be < json_response.last['name'].downcase expect(json_response.first['name'].downcase).to be < json_response.last['name'].downcase
end end
......
...@@ -22,7 +22,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -22,7 +22,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 400 error' do it 'returns 400 error' do
post api('/runners') post api('/runners')
expect(response).to have_gitlab_http_status 400 expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -30,7 +30,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -30,7 +30,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 403 error' do it 'returns 403 error' do
post api('/runners'), params: { token: 'invalid' } post api('/runners'), params: { token: 'invalid' }
expect(response).to have_gitlab_http_status 403 expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -40,7 +40,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -40,7 +40,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
runner = Ci::Runner.first runner = Ci::Runner.first
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(runner.id) expect(json_response['id']).to eq(runner.id)
expect(json_response['token']).to eq(runner.token) expect(json_response['token']).to eq(runner.token)
expect(runner.run_untagged).to be true expect(runner.run_untagged).to be true
...@@ -55,7 +55,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -55,7 +55,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'creates project runner' do it 'creates project runner' do
post api('/runners'), params: { token: project.runners_token } post api('/runners'), params: { token: project.runners_token }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(project.runners.size).to eq(1) expect(project.runners.size).to eq(1)
runner = Ci::Runner.first runner = Ci::Runner.first
expect(runner.token).not_to eq(registration_token) expect(runner.token).not_to eq(registration_token)
...@@ -70,7 +70,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -70,7 +70,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'creates a group runner' do it 'creates a group runner' do
post api('/runners'), params: { token: group.runners_token } post api('/runners'), params: { token: group.runners_token }
expect(response).to have_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(group.runners.reload.size).to eq(1) expect(group.runners.reload.size).to eq(1)
runner = Ci::Runner.first runner = Ci::Runner.first
expect(runner.token).not_to eq(registration_token) expect(runner.token).not_to eq(registration_token)
...@@ -87,7 +87,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -87,7 +87,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
description: 'server.hostname' description: 'server.hostname'
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.description).to eq('server.hostname') expect(Ci::Runner.first.description).to eq('server.hostname')
end end
end end
...@@ -99,7 +99,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -99,7 +99,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
tag_list: 'tag1, tag2' tag_list: 'tag1, tag2'
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2)) expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2))
end end
end end
...@@ -113,7 +113,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -113,7 +113,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
tag_list: ['tag'] tag_list: ['tag']
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.run_untagged).to be false expect(Ci::Runner.first.run_untagged).to be false
expect(Ci::Runner.first.tag_list.sort).to eq(['tag']) expect(Ci::Runner.first.tag_list.sort).to eq(['tag'])
end end
...@@ -126,7 +126,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -126,7 +126,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
run_untagged: false run_untagged: false
} }
expect(response).to have_gitlab_http_status 400 expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to include( expect(json_response['message']).to include(
'tags_list' => ['can not be empty when runner is not allowed to pick untagged jobs']) 'tags_list' => ['can not be empty when runner is not allowed to pick untagged jobs'])
end end
...@@ -140,7 +140,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -140,7 +140,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
locked: true locked: true
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.locked).to be true expect(Ci::Runner.first.locked).to be true
end end
end end
...@@ -153,7 +153,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -153,7 +153,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
active: true active: true
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.active).to be true expect(Ci::Runner.first.active).to be true
end end
end end
...@@ -165,7 +165,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -165,7 +165,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
active: false active: false
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.active).to be false expect(Ci::Runner.first.active).to be false
end end
end end
...@@ -179,7 +179,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -179,7 +179,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
access_level: 'ref_protected' access_level: 'ref_protected'
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.ref_protected?).to be true expect(Ci::Runner.first.ref_protected?).to be true
end end
end end
...@@ -191,7 +191,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -191,7 +191,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
access_level: 'not_protected' access_level: 'not_protected'
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.ref_protected?).to be false expect(Ci::Runner.first.ref_protected?).to be false
end end
end end
...@@ -204,7 +204,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -204,7 +204,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
maximum_timeout: 9000 maximum_timeout: 9000
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.maximum_timeout).to eq(9000) expect(Ci::Runner.first.maximum_timeout).to eq(9000)
end end
...@@ -215,7 +215,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -215,7 +215,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
maximum_timeout: '' maximum_timeout: ''
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.maximum_timeout).to be_nil expect(Ci::Runner.first.maximum_timeout).to be_nil
end end
end end
...@@ -231,7 +231,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -231,7 +231,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
info: { param => value } info: { param => value }
} }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.read_attribute(param.to_sym)).to eq(value) expect(Ci::Runner.first.read_attribute(param.to_sym)).to eq(value)
end end
end end
...@@ -242,7 +242,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -242,7 +242,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
params: { token: registration_token }, params: { token: registration_token },
headers: { 'X-Forwarded-For' => '123.111.123.111' } headers: { 'X-Forwarded-For' => '123.111.123.111' }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(Ci::Runner.first.ip_address).to eq('123.111.123.111') expect(Ci::Runner.first.ip_address).to eq('123.111.123.111')
end end
end end
...@@ -252,7 +252,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -252,7 +252,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 400 error' do it 'returns 400 error' do
delete api('/runners') delete api('/runners')
expect(response).to have_gitlab_http_status 400 expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -260,7 +260,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -260,7 +260,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 403 error' do it 'returns 403 error' do
delete api('/runners'), params: { token: 'invalid' } delete api('/runners'), params: { token: 'invalid' }
expect(response).to have_gitlab_http_status 403 expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -270,7 +270,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -270,7 +270,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'deletes Runner' do it 'deletes Runner' do
delete api('/runners'), params: { token: runner.token } delete api('/runners'), params: { token: runner.token }
expect(response).to have_gitlab_http_status 204 expect(response).to have_gitlab_http_status(:no_content)
expect(Ci::Runner.count).to eq(0) expect(Ci::Runner.count).to eq(0)
end end
...@@ -296,7 +296,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -296,7 +296,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 403 error' do it 'returns 403 error' do
post api('/runners/verify'), params: { token: 'invalid-token' } post api('/runners/verify'), params: { token: 'invalid-token' }
expect(response).to have_gitlab_http_status 403 expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -304,7 +304,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -304,7 +304,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'verifies Runner credentials' do it 'verifies Runner credentials' do
post api('/runners/verify'), params: { token: runner.token } post api('/runners/verify'), params: { token: runner.token }
expect(response).to have_gitlab_http_status 200 expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -361,7 +361,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -361,7 +361,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
context 'when runner sends version in User-Agent' do context 'when runner sends version in User-Agent' do
context 'for stable version' do context 'for stable version' do
it 'gives 204 and set X-GitLab-Last-Update' do it 'gives 204 and set X-GitLab-Last-Update' do
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(response.header).to have_key('X-GitLab-Last-Update') expect(response.header).to have_key('X-GitLab-Last-Update')
end end
end end
...@@ -370,7 +370,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -370,7 +370,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:last_update) { runner.ensure_runner_queue_value } let(:last_update) { runner.ensure_runner_queue_value }
it 'gives 204 and set the same X-GitLab-Last-Update' do it 'gives 204 and set the same X-GitLab-Last-Update' do
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(response.header['X-GitLab-Last-Update']).to eq(last_update) expect(response.header['X-GitLab-Last-Update']).to eq(last_update)
end end
end end
...@@ -380,7 +380,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -380,7 +380,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:new_update) { runner.tick_runner_queue } let(:new_update) { runner.tick_runner_queue }
it 'gives 204 and set a new X-GitLab-Last-Update' do it 'gives 204 and set a new X-GitLab-Last-Update' do
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(response.header['X-GitLab-Last-Update']).to eq(new_update) expect(response.header['X-GitLab-Last-Update']).to eq(new_update)
end end
end end
...@@ -388,19 +388,19 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -388,19 +388,19 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
context 'when beta version is sent' do context 'when beta version is sent' do
let(:user_agent) { 'gitlab-runner 9.0.0~beta.167.g2b2bacc (master; go1.7.4; linux/amd64)' } let(:user_agent) { 'gitlab-runner 9.0.0~beta.167.g2b2bacc (master; go1.7.4; linux/amd64)' }
it { expect(response).to have_gitlab_http_status(204) } it { expect(response).to have_gitlab_http_status(:no_content) }
end end
context 'when pre-9-0 version is sent' do context 'when pre-9-0 version is sent' do
let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0 (1-6-stable; go1.6.3; linux/amd64)' } let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0 (1-6-stable; go1.6.3; linux/amd64)' }
it { expect(response).to have_gitlab_http_status(204) } it { expect(response).to have_gitlab_http_status(:no_content) }
end end
context 'when pre-9-0 beta version is sent' do context 'when pre-9-0 beta version is sent' do
let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0~beta.167.g2b2bacc (master; go1.6.3; linux/amd64)' } let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0~beta.167.g2b2bacc (master; go1.6.3; linux/amd64)' }
it { expect(response).to have_gitlab_http_status(204) } it { expect(response).to have_gitlab_http_status(:no_content) }
end end
end end
end end
...@@ -409,7 +409,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -409,7 +409,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 400 error' do it 'returns 400 error' do
post api('/jobs/request') post api('/jobs/request')
expect(response).to have_gitlab_http_status 400 expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -417,7 +417,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -417,7 +417,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 403 error' do it 'returns 403 error' do
post api('/jobs/request'), params: { token: 'invalid' } post api('/jobs/request'), params: { token: 'invalid' }
expect(response).to have_gitlab_http_status 403 expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -429,7 +429,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -429,7 +429,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns 204 error' do it 'returns 204 error' do
request_job request_job
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(response.header['X-GitLab-Last-Update']).to eq(update_value) expect(response.header['X-GitLab-Last-Update']).to eq(update_value)
end end
end end
...@@ -516,7 +516,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -516,7 +516,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'picks a job' do it 'picks a job' do
request_job info: { platform: :darwin } request_job info: { platform: :darwin }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(response.headers).not_to have_key('X-GitLab-Last-Update') expect(response.headers).not_to have_key('X-GitLab-Last-Update')
expect(runner.reload.platform).to eq('darwin') expect(runner.reload.platform).to eq('darwin')
expect(json_response['id']).to eq(job.id) expect(json_response['id']).to eq(job.id)
...@@ -541,7 +541,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -541,7 +541,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
request_job info: { platform: :darwin } request_job info: { platform: :darwin }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(job.id) expect(json_response['id']).to eq(job.id)
end end
...@@ -551,7 +551,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -551,7 +551,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'sets branch as ref_type' do it 'sets branch as ref_type' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['ref_type']).to eq('tag') expect(json_response['git_info']['ref_type']).to eq('tag')
end end
...@@ -563,7 +563,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -563,7 +563,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'specifies refspecs' do it 'specifies refspecs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['refspecs']).to include("+refs/tags/#{job.ref}:refs/tags/#{job.ref}") expect(json_response['git_info']['refspecs']).to include("+refs/tags/#{job.ref}:refs/tags/#{job.ref}")
end end
end end
...@@ -576,7 +576,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -576,7 +576,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'specifies refspecs' do it 'specifies refspecs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['refspecs']) expect(json_response['git_info']['refspecs'])
.to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*') .to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*')
end end
...@@ -592,7 +592,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -592,7 +592,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'gives 204' do it 'gives 204' do
request_job(job_age: job_age) request_job(job_age: job_age)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
...@@ -602,7 +602,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -602,7 +602,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'picks a job' do it 'picks a job' do
request_job(job_age: job_age) request_job(job_age: job_age)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
end end
...@@ -611,7 +611,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -611,7 +611,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'sets tag as ref_type' do it 'sets tag as ref_type' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['ref_type']).to eq('branch') expect(json_response['git_info']['ref_type']).to eq('branch')
end end
...@@ -623,7 +623,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -623,7 +623,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'specifies refspecs' do it 'specifies refspecs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['refspecs']).to include("+refs/heads/#{job.ref}:refs/remotes/origin/#{job.ref}") expect(json_response['git_info']['refspecs']).to include("+refs/heads/#{job.ref}:refs/remotes/origin/#{job.ref}")
end end
end end
...@@ -636,7 +636,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -636,7 +636,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'specifies refspecs' do it 'specifies refspecs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['refspecs']) expect(json_response['git_info']['refspecs'])
.to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*') .to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*')
end end
...@@ -651,7 +651,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -651,7 +651,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'sets branch as ref_type' do it 'sets branch as ref_type' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['ref_type']).to eq('branch') expect(json_response['git_info']['ref_type']).to eq('branch')
end end
...@@ -663,7 +663,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -663,7 +663,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns the overwritten git depth for merge request refspecs' do it 'returns the overwritten git depth for merge request refspecs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['depth']).to eq(1) expect(json_response['git_info']['depth']).to eq(1)
end end
end end
...@@ -680,7 +680,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -680,7 +680,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it "updates provided Runner's parameter" do it "updates provided Runner's parameter" do
request_job info: { param => value } request_job info: { param => value }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(runner.reload.read_attribute(param.to_sym)).to eq(value) expect(runner.reload.read_attribute(param.to_sym)).to eq(value)
end end
end end
...@@ -691,7 +691,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -691,7 +691,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
params: { token: runner.token }, params: { token: runner.token },
headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222' } headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222' }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(runner.reload.ip_address).to eq('123.222.123.222') expect(runner.reload.ip_address).to eq('123.222.123.222')
end end
...@@ -700,7 +700,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -700,7 +700,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
params: { token: runner.token }, params: { token: runner.token },
headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222, 127.0.0.1' } headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222, 127.0.0.1' }
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
expect(runner.reload.ip_address).to eq('123.222.123.222') expect(runner.reload.ip_address).to eq('123.222.123.222')
end end
...@@ -713,7 +713,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -713,7 +713,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns a conflict' do it 'returns a conflict' do
request_job request_job
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
expect(response.headers).not_to have_key('X-GitLab-Last-Update') expect(response.headers).not_to have_key('X-GitLab-Last-Update')
end end
end end
...@@ -731,7 +731,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -731,7 +731,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns dependent jobs' do it 'returns dependent jobs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(test_job.id) expect(json_response['id']).to eq(test_job.id)
expect(json_response['dependencies'].count).to eq(2) expect(json_response['dependencies'].count).to eq(2)
expect(json_response['dependencies']).to include( expect(json_response['dependencies']).to include(
...@@ -751,7 +751,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -751,7 +751,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns dependent jobs' do it 'returns dependent jobs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(test_job.id) expect(json_response['id']).to eq(test_job.id)
expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'].count).to eq(1)
expect(json_response['dependencies']).to include( expect(json_response['dependencies']).to include(
...@@ -777,7 +777,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -777,7 +777,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns dependent jobs' do it 'returns dependent jobs' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(test_job.id) expect(json_response['id']).to eq(test_job.id)
expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'].count).to eq(1)
expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token) expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token)
...@@ -801,7 +801,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -801,7 +801,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns an empty array' do it 'returns an empty array' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(empty_dependencies_job.id) expect(json_response['id']).to eq(empty_dependencies_job.id)
expect(json_response['dependencies'].count).to eq(0) expect(json_response['dependencies'].count).to eq(0)
end end
...@@ -820,7 +820,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -820,7 +820,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'picks job' do it 'picks job' do
request_job request_job
expect(response).to have_gitlab_http_status 201 expect(response).to have_gitlab_http_status(:created)
end end
end end
...@@ -854,7 +854,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -854,7 +854,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns variables for triggers' do it 'returns variables for triggers' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['variables']).to include(*expected_variables) expect(json_response['variables']).to include(*expected_variables)
end end
end end
...@@ -919,7 +919,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -919,7 +919,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'contains info about timeout taken from project' do it 'contains info about timeout taken from project' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['runner_info']).to include({ 'timeout' => 1234 }) expect(json_response['runner_info']).to include({ 'timeout' => 1234 })
end end
...@@ -929,7 +929,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -929,7 +929,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'contains info about timeout overridden by runner' do it 'contains info about timeout overridden by runner' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['runner_info']).to include({ 'timeout' => 1000 }) expect(json_response['runner_info']).to include({ 'timeout' => 1000 })
end end
end end
...@@ -940,7 +940,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -940,7 +940,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'contains info about timeout not overridden by runner' do it 'contains info about timeout not overridden by runner' do
request_job request_job
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['runner_info']).to include({ 'timeout' => 1234 }) expect(json_response['runner_info']).to include({ 'timeout' => 1234 })
end end
end end
...@@ -965,7 +965,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -965,7 +965,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns the image ports' do it 'returns the image ports' do
request_job request_job
expect(response).to have_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(json_response).to include( expect(json_response).to include(
'id' => job.id, 'id' => job.id,
'image' => a_hash_including('name' => 'ruby', 'ports' => [{ 'number' => 80, 'protocol' => 'http', 'name' => 'default_port' }]), 'image' => a_hash_including('name' => 'ruby', 'ports' => [{ 'number' => 80, 'protocol' => 'http', 'name' => 'default_port' }]),
...@@ -989,7 +989,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -989,7 +989,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns the service ports' do it 'returns the service ports' do
request_job request_job
expect(response).to have_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(json_response).to include( expect(json_response).to include(
'id' => job.id, 'id' => job.id,
'image' => a_hash_including('name' => 'ruby'), 'image' => a_hash_including('name' => 'ruby'),
...@@ -1089,7 +1089,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1089,7 +1089,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
update_job(state: 'success', trace: 'BUILD TRACE UPDATED') update_job(state: 'success', trace: 'BUILD TRACE UPDATED')
job.reload job.reload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(job.trace.raw).to eq 'BUILD TRACE UPDATED' expect(job.trace.raw).to eq 'BUILD TRACE UPDATED'
expect(job.job_artifacts_trace.open.read).to eq 'BUILD TRACE UPDATED' expect(job.job_artifacts_trace.open.read).to eq 'BUILD TRACE UPDATED'
end end
...@@ -1133,7 +1133,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1133,7 +1133,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'responds with forbidden' do it 'responds with forbidden' do
update_job update_job
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -1147,7 +1147,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1147,7 +1147,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
update_job(state: 'success', trace: 'BUILD TRACE UPDATED') update_job(state: 'success', trace: 'BUILD TRACE UPDATED')
job.reload job.reload
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(response.header['Job-Status']).to eq 'failed' expect(response.header['Job-Status']).to eq 'failed'
expect(job.trace.raw).to eq 'Job failed' expect(job.trace.raw).to eq 'Job failed'
expect(job).to be_failed expect(job).to be_failed
...@@ -1461,7 +1461,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1461,7 +1461,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'succeeds' do it 'succeeds' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path) expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path)
expect(json_response['RemoteObject']).to be_nil expect(json_response['RemoteObject']).to be_nil
...@@ -1481,7 +1481,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1481,7 +1481,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'succeeds' do it 'succeeds' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response).not_to have_key('TempPath') expect(json_response).not_to have_key('TempPath')
expect(json_response['RemoteObject']).to have_key('ID') expect(json_response['RemoteObject']).to have_key('ID')
...@@ -1509,7 +1509,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1509,7 +1509,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'fails to post' do it 'fails to post' do
authorize_artifacts_with_token_in_params(filesize: sample_max_size.megabytes.to_i) authorize_artifacts_with_token_in_params(filesize: sample_max_size.megabytes.to_i)
expect(response).to have_gitlab_http_status(413) expect(response).to have_gitlab_http_status(:payload_too_large)
end end
end end
...@@ -1557,7 +1557,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1557,7 +1557,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'authorizes posting artifacts to running job' do it 'authorizes posting artifacts to running job' do
authorize_artifacts_with_token_in_headers authorize_artifacts_with_token_in_headers
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response['TempPath']).not_to be_nil expect(json_response['TempPath']).not_to be_nil
end end
...@@ -1567,7 +1567,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1567,7 +1567,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
authorize_artifacts_with_token_in_headers(filesize: 100) authorize_artifacts_with_token_in_headers(filesize: 100)
expect(response).to have_gitlab_http_status(413) expect(response).to have_gitlab_http_status(:payload_too_large)
end end
end end
...@@ -1575,7 +1575,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1575,7 +1575,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'fails to authorize artifacts posting' do it 'fails to authorize artifacts posting' do
authorize_artifacts(token: job.project.runners_token) authorize_artifacts(token: job.project.runners_token)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -1591,7 +1591,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1591,7 +1591,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'responds with forbidden' do it 'responds with forbidden' do
authorize_artifacts(token: 'invalid', filesize: 100 ) authorize_artifacts(token: 'invalid', filesize: 100 )
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -1632,14 +1632,14 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1632,14 +1632,14 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'responds with forbidden' do it 'responds with forbidden' do
upload_artifacts(file_upload, headers_with_token) upload_artifacts(file_upload, headers_with_token)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
context 'when job is running' do context 'when job is running' do
shared_examples 'successful artifacts upload' do shared_examples 'successful artifacts upload' do
it 'updates successfully' do it 'updates successfully' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
...@@ -1678,7 +1678,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1678,7 +1678,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:remote_id) { 'invalid id' } let(:remote_id) { 'invalid id' }
it 'responds with bad request' do it 'responds with bad request' do
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response['message']).to eq("Missing file") expect(json_response['message']).to eq("Missing file")
end end
end end
...@@ -1689,7 +1689,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1689,7 +1689,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'responds with forbidden' do it 'responds with forbidden' do
upload_artifacts(file_upload, headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.project.runners_token)) upload_artifacts(file_upload, headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.project.runners_token))
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -1700,7 +1700,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1700,7 +1700,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
upload_artifacts(file_upload, headers_with_token) upload_artifacts(file_upload, headers_with_token)
expect(response).to have_gitlab_http_status(413) expect(response).to have_gitlab_http_status(:payload_too_large)
end end
end end
...@@ -1708,7 +1708,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1708,7 +1708,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'fails to post artifacts without file' do it 'fails to post artifacts without file' do
post api("/jobs/#{job.id}/artifacts"), params: {}, headers: headers_with_token post api("/jobs/#{job.id}/artifacts"), params: {}, headers: headers_with_token
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -1716,7 +1716,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1716,7 +1716,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'fails to post artifacts without GitLab-Workhorse' do it 'fails to post artifacts without GitLab-Workhorse' do
post api("/jobs/#{job.id}/artifacts"), params: { token: job.token }, headers: {} post api("/jobs/#{job.id}/artifacts"), params: { token: job.token }, headers: {}
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -1750,7 +1750,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1750,7 +1750,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:expire_in) { '7 days' } let(:expire_in) { '7 days' }
it 'updates when specified' do it 'updates when specified' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(7.days.from_now) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(7.days.from_now)
end end
end end
...@@ -1759,7 +1759,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1759,7 +1759,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:expire_in) { nil } let(:expire_in) { nil }
it 'ignores if not specified' do it 'ignores if not specified' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.artifacts_expire_at).to be_nil expect(job.reload.artifacts_expire_at).to be_nil
end end
...@@ -1768,7 +1768,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1768,7 +1768,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:default_artifacts_expire_in) { '5 days' } let(:default_artifacts_expire_in) { '5 days' }
it 'sets to application default' do it 'sets to application default' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(5.days.from_now) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(5.days.from_now)
end end
end end
...@@ -1777,7 +1777,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1777,7 +1777,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:default_artifacts_expire_in) { '0' } let(:default_artifacts_expire_in) { '0' }
it 'does not set expire_in' do it 'does not set expire_in' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.artifacts_expire_at).to be_nil expect(job.reload.artifacts_expire_at).to be_nil
end end
end end
...@@ -1812,7 +1812,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1812,7 +1812,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end end
it 'stores artifacts and artifacts metadata' do it 'stores artifacts and artifacts metadata' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(stored_artifacts_file.filename).to eq(artifacts.original_filename) expect(stored_artifacts_file.filename).to eq(artifacts.original_filename)
expect(stored_metadata_file.filename).to eq(metadata.original_filename) expect(stored_metadata_file.filename).to eq(metadata.original_filename)
expect(stored_artifacts_size).to eq(artifacts.size) expect(stored_artifacts_size).to eq(artifacts.size)
...@@ -1827,7 +1827,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1827,7 +1827,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end end
it 'is expected to respond with bad request' do it 'is expected to respond with bad request' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not store metadata' do it 'does not store metadata' do
...@@ -1843,7 +1843,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1843,7 +1843,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'stores junit test report' do it 'stores junit test report' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.job_artifacts_archive).not_to be_nil expect(job.reload.job_artifacts_archive).not_to be_nil
end end
end end
...@@ -1854,7 +1854,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1854,7 +1854,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns an error' do it 'returns an error' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(job.reload.job_artifacts_archive).to be_nil expect(job.reload.job_artifacts_archive).to be_nil
end end
end end
...@@ -1868,7 +1868,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1868,7 +1868,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'stores junit test report' do it 'stores junit test report' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.job_artifacts_junit).not_to be_nil expect(job.reload.job_artifacts_junit).not_to be_nil
end end
end end
...@@ -1880,7 +1880,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1880,7 +1880,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns an error' do it 'returns an error' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(job.reload.job_artifacts_junit).to be_nil expect(job.reload.job_artifacts_junit).to be_nil
end end
end end
...@@ -1894,7 +1894,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1894,7 +1894,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'stores metrics_referee data' do it 'stores metrics_referee data' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.job_artifacts_metrics_referee).not_to be_nil expect(job.reload.job_artifacts_metrics_referee).not_to be_nil
end end
end end
...@@ -1906,7 +1906,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1906,7 +1906,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns an error' do it 'returns an error' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(job.reload.job_artifacts_metrics_referee).to be_nil expect(job.reload.job_artifacts_metrics_referee).to be_nil
end end
end end
...@@ -1920,7 +1920,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1920,7 +1920,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'stores network_referee data' do it 'stores network_referee data' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(job.reload.job_artifacts_network_referee).not_to be_nil expect(job.reload.job_artifacts_network_referee).not_to be_nil
end end
end end
...@@ -1932,7 +1932,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1932,7 +1932,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns an error' do it 'returns an error' do
upload_artifacts(file_upload, headers_with_token, params) upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(job.reload.job_artifacts_network_referee).to be_nil expect(job.reload.job_artifacts_network_referee).to be_nil
end end
end end
...@@ -2013,7 +2013,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -2013,7 +2013,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it' "fails to post artifacts for outside of tmp path"' do it' "fails to post artifacts for outside of tmp path"' do
upload_artifacts(file_upload, headers_with_token) upload_artifacts(file_upload, headers_with_token)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -2055,7 +2055,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -2055,7 +2055,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end end
it 'download artifacts' do it 'download 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
end end
end end
...@@ -2070,7 +2070,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -2070,7 +2070,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end end
it 'uses workhorse send-url' do it 'uses workhorse send-url' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h).to include( expect(response.headers.to_h).to include(
'Gitlab-Workhorse-Send-Data' => /send-url:/) 'Gitlab-Workhorse-Send-Data' => /send-url:/)
end end
...@@ -2082,7 +2082,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -2082,7 +2082,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end end
it 'receive redirect for downloading artifacts' do it 'receive redirect for downloading artifacts' do
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response.headers).to include('Location') expect(response.headers).to include('Location')
end end
end end
...@@ -2097,7 +2097,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -2097,7 +2097,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end end
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
end end
...@@ -2106,7 +2106,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -2106,7 +2106,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'responds with not found' do it 'responds with not found' do
download_artifact download_artifact
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -32,7 +32,7 @@ describe API::Runners do ...@@ -32,7 +32,7 @@ describe API::Runners do
it 'returns response status and headers' do it 'returns response status and headers' do
get api('/runners', user) get api('/runners', 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
end end
...@@ -51,7 +51,7 @@ describe API::Runners do ...@@ -51,7 +51,7 @@ describe API::Runners do
get api('/runners?scope=paused', user) get api('/runners?scope=paused', 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 match_array [ expect(json_response).to match_array [
...@@ -61,7 +61,7 @@ describe API::Runners do ...@@ -61,7 +61,7 @@ describe API::Runners do
it 'avoids filtering if scope is invalid' do it 'avoids filtering if scope is invalid' do
get api('/runners?scope=unknown', user) get api('/runners?scope=unknown', user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by type' do it 'filters runners by type' do
...@@ -76,7 +76,7 @@ describe API::Runners do ...@@ -76,7 +76,7 @@ describe API::Runners do
it 'does not filter by invalid type' do it 'does not filter by invalid type' do
get api('/runners?type=bogus', user) get api('/runners?type=bogus', user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by status' do it 'filters runners by status' do
...@@ -92,7 +92,7 @@ describe API::Runners do ...@@ -92,7 +92,7 @@ describe API::Runners do
it 'does not filter by invalid status' do it 'does not filter by invalid status' do
get api('/runners?status=bogus', user) get api('/runners?status=bogus', user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by tag_list' do it 'filters runners by tag_list' do
...@@ -111,7 +111,7 @@ describe API::Runners do ...@@ -111,7 +111,7 @@ describe API::Runners do
it 'does not return runners' do it 'does not return runners' do
get api('/runners') get api('/runners')
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -122,7 +122,7 @@ describe API::Runners do ...@@ -122,7 +122,7 @@ describe API::Runners do
it 'returns response status and headers' do it 'returns response status and headers' do
get api('/runners/all', admin) get api('/runners/all', 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
end end
...@@ -141,7 +141,7 @@ describe API::Runners do ...@@ -141,7 +141,7 @@ describe API::Runners do
get api('/runners/all?scope=shared', admin) get api('/runners/all?scope=shared', admin)
shared = json_response.all? { |r| r['is_shared'] } shared = json_response.all? { |r| r['is_shared'] }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response[0]).to have_key('ip_address') expect(json_response[0]).to have_key('ip_address')
...@@ -151,7 +151,7 @@ describe API::Runners do ...@@ -151,7 +151,7 @@ describe API::Runners do
it 'filters runners by scope' do it 'filters runners by scope' do
get api('/runners/all?scope=specific', admin) get api('/runners/all?scope=specific', 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 match_array [ expect(json_response).to match_array [
...@@ -163,7 +163,7 @@ describe API::Runners do ...@@ -163,7 +163,7 @@ describe API::Runners do
it 'avoids filtering if scope is invalid' do it 'avoids filtering if scope is invalid' do
get api('/runners/all?scope=unknown', admin) get api('/runners/all?scope=unknown', admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by type' do it 'filters runners by type' do
...@@ -178,7 +178,7 @@ describe API::Runners do ...@@ -178,7 +178,7 @@ describe API::Runners do
it 'does not filter by invalid type' do it 'does not filter by invalid type' do
get api('/runners/all?type=bogus', admin) get api('/runners/all?type=bogus', admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by status' do it 'filters runners by status' do
...@@ -194,7 +194,7 @@ describe API::Runners do ...@@ -194,7 +194,7 @@ describe API::Runners do
it 'does not filter by invalid status' do it 'does not filter by invalid status' do
get api('/runners/all?status=bogus', admin) get api('/runners/all?status=bogus', admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by tag_list' do it 'filters runners by tag_list' do
...@@ -213,7 +213,7 @@ describe API::Runners do ...@@ -213,7 +213,7 @@ describe API::Runners do
it 'does not return runners list' do it 'does not return runners list' do
get api('/runners/all', user) get api('/runners/all', user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -222,7 +222,7 @@ describe API::Runners do ...@@ -222,7 +222,7 @@ describe API::Runners do
it 'does not return runners' do it 'does not return runners' do
get api('/runners') get api('/runners')
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -233,7 +233,7 @@ describe API::Runners do ...@@ -233,7 +233,7 @@ describe API::Runners do
it "returns runner's details" do it "returns runner's details" do
get api("/runners/#{shared_runner.id}", admin) get api("/runners/#{shared_runner.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['description']).to eq(shared_runner.description) expect(json_response['description']).to eq(shared_runner.description)
expect(json_response['maximum_timeout']).to be_nil expect(json_response['maximum_timeout']).to be_nil
end end
...@@ -247,7 +247,7 @@ describe API::Runners do ...@@ -247,7 +247,7 @@ describe API::Runners do
expect do expect do
delete api("/runners/#{unused_project_runner.id}", admin) delete api("/runners/#{unused_project_runner.id}", admin)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { Ci::Runner.project_type.count }.by(-1) end.to change { Ci::Runner.project_type.count }.by(-1)
end end
end end
...@@ -255,7 +255,7 @@ describe API::Runners do ...@@ -255,7 +255,7 @@ describe API::Runners do
it "returns runner's details" do it "returns runner's details" do
get api("/runners/#{project_runner.id}", admin) get api("/runners/#{project_runner.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['description']).to eq(project_runner.description) expect(json_response['description']).to eq(project_runner.description)
end end
...@@ -269,7 +269,7 @@ describe API::Runners do ...@@ -269,7 +269,7 @@ describe API::Runners do
it 'returns 404 if runner does not exists' do it 'returns 404 if runner does not exists' do
get api('/runners/0', admin) get api('/runners/0', admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -278,7 +278,7 @@ describe API::Runners do ...@@ -278,7 +278,7 @@ describe API::Runners do
it "returns runner's details" do it "returns runner's details" do
get api("/runners/#{project_runner.id}", user) get api("/runners/#{project_runner.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['description']).to eq(project_runner.description) expect(json_response['description']).to eq(project_runner.description)
end end
end end
...@@ -287,7 +287,7 @@ describe API::Runners do ...@@ -287,7 +287,7 @@ describe API::Runners do
it "returns runner's details" do it "returns runner's details" do
get api("/runners/#{shared_runner.id}", user) get api("/runners/#{shared_runner.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['description']).to eq(shared_runner.description) expect(json_response['description']).to eq(shared_runner.description)
end end
end end
...@@ -297,7 +297,7 @@ describe API::Runners do ...@@ -297,7 +297,7 @@ describe API::Runners do
it "does not return project runner's details" do it "does not return project runner's details" do
get api("/runners/#{project_runner.id}", user2) get api("/runners/#{project_runner.id}", user2)
expect(response).to have_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -305,7 +305,7 @@ describe API::Runners do ...@@ -305,7 +305,7 @@ describe API::Runners do
it "does not return project runner's details" do it "does not return project runner's details" do
get api("/runners/#{project_runner.id}") get api("/runners/#{project_runner.id}")
expect(response).to have_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -318,7 +318,7 @@ describe API::Runners do ...@@ -318,7 +318,7 @@ describe API::Runners do
description = shared_runner.description description = shared_runner.description
update_runner(shared_runner.id, admin, description: "#{description}_updated") update_runner(shared_runner.id, admin, description: "#{description}_updated")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.reload.description).to eq("#{description}_updated") expect(shared_runner.reload.description).to eq("#{description}_updated")
end end
...@@ -326,14 +326,14 @@ describe API::Runners do ...@@ -326,14 +326,14 @@ describe API::Runners do
active = shared_runner.active active = shared_runner.active
update_runner(shared_runner.id, admin, active: !active) update_runner(shared_runner.id, admin, active: !active)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.reload.active).to eq(!active) expect(shared_runner.reload.active).to eq(!active)
end end
it 'runner tag list' do it 'runner tag list' do
update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql']) update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql'])
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.reload.tag_list).to include('ruby2.1', 'pgsql', 'mysql') expect(shared_runner.reload.tag_list).to include('ruby2.1', 'pgsql', 'mysql')
end end
...@@ -342,28 +342,28 @@ describe API::Runners do ...@@ -342,28 +342,28 @@ describe API::Runners do
update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql']) update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql'])
update_runner(shared_runner.id, admin, run_untagged: 'false') update_runner(shared_runner.id, admin, run_untagged: 'false')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.reload.run_untagged?).to be(false) expect(shared_runner.reload.run_untagged?).to be(false)
end end
it 'runner unlocked flag' do it 'runner unlocked flag' do
update_runner(shared_runner.id, admin, locked: 'true') update_runner(shared_runner.id, admin, locked: 'true')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.reload.locked?).to be(true) expect(shared_runner.reload.locked?).to be(true)
end end
it 'runner access level' do it 'runner access level' do
update_runner(shared_runner.id, admin, access_level: 'ref_protected') update_runner(shared_runner.id, admin, access_level: 'ref_protected')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.reload.ref_protected?).to be_truthy expect(shared_runner.reload.ref_protected?).to be_truthy
end end
it 'runner maximum timeout' do it 'runner maximum timeout' do
update_runner(shared_runner.id, admin, maximum_timeout: 1234) update_runner(shared_runner.id, admin, maximum_timeout: 1234)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.reload.maximum_timeout).to eq(1234) expect(shared_runner.reload.maximum_timeout).to eq(1234)
end end
...@@ -371,7 +371,7 @@ describe API::Runners do ...@@ -371,7 +371,7 @@ describe API::Runners do
put api("/runners/#{shared_runner.id}", admin) put api("/runners/#{shared_runner.id}", admin)
shared_runner.reload shared_runner.reload
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -390,7 +390,7 @@ describe API::Runners do ...@@ -390,7 +390,7 @@ describe API::Runners do
maximum_timeout: 1234) maximum_timeout: 1234)
shared_runner.reload shared_runner.reload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(shared_runner.description).to eq("#{description}_updated") expect(shared_runner.description).to eq("#{description}_updated")
expect(shared_runner.active).to eq(!active) expect(shared_runner.active).to eq(!active)
expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql') expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql')
...@@ -411,7 +411,7 @@ describe API::Runners do ...@@ -411,7 +411,7 @@ describe API::Runners do
update_runner(project_runner.id, admin, description: 'test') update_runner(project_runner.id, admin, description: 'test')
project_runner.reload project_runner.reload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project_runner.description).to eq('test') expect(project_runner.description).to eq('test')
expect(project_runner.description).not_to eq(description) expect(project_runner.description).not_to eq(description)
expect(project_runner.ensure_runner_queue_value) expect(project_runner.ensure_runner_queue_value)
...@@ -422,7 +422,7 @@ describe API::Runners do ...@@ -422,7 +422,7 @@ describe API::Runners do
it 'returns 404 if runner does not exists' do it 'returns 404 if runner does not exists' do
update_runner(0, admin, description: 'test') update_runner(0, admin, description: 'test')
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
def update_runner(id, user, args) def update_runner(id, user, args)
...@@ -435,7 +435,7 @@ describe API::Runners do ...@@ -435,7 +435,7 @@ describe API::Runners do
it 'does not update runner' do it 'does not update runner' do
put api("/runners/#{shared_runner.id}", user), params: { description: 'test' } put api("/runners/#{shared_runner.id}", user), params: { description: 'test' }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -443,7 +443,7 @@ describe API::Runners do ...@@ -443,7 +443,7 @@ describe API::Runners do
it 'does not update project runner without access to it' do it 'does not update project runner without access to it' do
put api("/runners/#{project_runner.id}", user2), params: { description: 'test' } put api("/runners/#{project_runner.id}", user2), params: { description: 'test' }
expect(response).to have_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'updates project runner with access to it' do it 'updates project runner with access to it' do
...@@ -451,7 +451,7 @@ describe API::Runners do ...@@ -451,7 +451,7 @@ describe API::Runners do
put api("/runners/#{project_runner.id}", admin), params: { description: 'test' } put api("/runners/#{project_runner.id}", admin), params: { description: 'test' }
project_runner.reload project_runner.reload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(project_runner.description).to eq('test') expect(project_runner.description).to eq('test')
expect(project_runner.description).not_to eq(description) expect(project_runner.description).not_to eq(description)
end end
...@@ -462,7 +462,7 @@ describe API::Runners do ...@@ -462,7 +462,7 @@ describe API::Runners do
it 'does not delete project runner' do it 'does not delete project runner' do
put api("/runners/#{project_runner.id}") put api("/runners/#{project_runner.id}")
expect(response).to have_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -474,7 +474,7 @@ describe API::Runners do ...@@ -474,7 +474,7 @@ describe API::Runners do
expect do expect do
delete api("/runners/#{shared_runner.id}", admin) delete api("/runners/#{shared_runner.id}", admin)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { Ci::Runner.instance_type.count }.by(-1) end.to change { Ci::Runner.instance_type.count }.by(-1)
end end
...@@ -488,7 +488,7 @@ describe API::Runners do ...@@ -488,7 +488,7 @@ describe API::Runners do
expect do expect do
delete api("/runners/#{project_runner.id}", admin) delete api("/runners/#{project_runner.id}", admin)
expect(response).to have_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { Ci::Runner.project_type.count }.by(-1) end.to change { Ci::Runner.project_type.count }.by(-1)
end end
end end
...@@ -496,7 +496,7 @@ describe API::Runners do ...@@ -496,7 +496,7 @@ describe API::Runners do
it 'returns 404 if runner does not exists' do it 'returns 404 if runner does not exists' do
delete api('/runners/0', admin) delete api('/runners/0', admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -504,40 +504,40 @@ describe API::Runners do ...@@ -504,40 +504,40 @@ describe API::Runners do
context 'when runner is shared' do context 'when runner is shared' do
it 'does not delete runner' do it 'does not delete runner' do
delete api("/runners/#{shared_runner.id}", user) delete api("/runners/#{shared_runner.id}", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
context 'when runner is not shared' do context 'when runner is not shared' do
it 'does not delete runner without access to it' do it 'does not delete runner without access to it' do
delete api("/runners/#{project_runner.id}", user2) delete api("/runners/#{project_runner.id}", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'does not delete project runner with more than one associated project' do it 'does not delete project runner with more than one associated project' do
delete api("/runners/#{two_projects_runner.id}", user) delete api("/runners/#{two_projects_runner.id}", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'deletes project runner for one owned project' do it 'deletes project runner for one owned project' do
expect do expect do
delete api("/runners/#{project_runner.id}", user) delete api("/runners/#{project_runner.id}", user)
expect(response).to have_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { Ci::Runner.project_type.count }.by(-1) end.to change { Ci::Runner.project_type.count }.by(-1)
end end
it 'does not delete group runner with maintainer access' do it 'does not delete group runner with maintainer access' do
delete api("/runners/#{group_runner.id}", group_maintainer) delete api("/runners/#{group_runner.id}", group_maintainer)
expect(response).to have_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'deletes group runner with owner access' do it 'deletes group runner with owner access' do
expect do expect do
delete api("/runners/#{group_runner.id}", user) delete api("/runners/#{group_runner.id}", user)
expect(response).to have_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { Ci::Runner.group_type.count }.by(-1) end.to change { Ci::Runner.group_type.count }.by(-1)
end end
...@@ -551,7 +551,7 @@ describe API::Runners do ...@@ -551,7 +551,7 @@ describe API::Runners do
it 'does not delete project runner' do it 'does not delete project runner' do
delete api("/runners/#{project_runner.id}") delete api("/runners/#{project_runner.id}")
expect(response).to have_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -569,7 +569,7 @@ describe API::Runners do ...@@ -569,7 +569,7 @@ describe API::Runners do
it 'return jobs' do it 'return jobs' do
get api("/runners/#{shared_runner.id}/jobs", admin) get api("/runners/#{shared_runner.id}/jobs", 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)
...@@ -581,7 +581,7 @@ describe API::Runners do ...@@ -581,7 +581,7 @@ describe API::Runners do
it 'return jobs' do it 'return jobs' do
get api("/runners/#{project_runner.id}/jobs", admin) get api("/runners/#{project_runner.id}/jobs", 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)
...@@ -593,7 +593,7 @@ describe API::Runners do ...@@ -593,7 +593,7 @@ describe API::Runners do
it 'return filtered jobs' do it 'return filtered jobs' do
get api("/runners/#{project_runner.id}/jobs?status=failed", admin) get api("/runners/#{project_runner.id}/jobs?status=failed", 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)
...@@ -607,7 +607,7 @@ describe API::Runners do ...@@ -607,7 +607,7 @@ describe API::Runners do
it 'return jobs in descending order' do it 'return jobs in descending order' do
get api("/runners/#{project_runner.id}/jobs?order_by=id", admin) get api("/runners/#{project_runner.id}/jobs?order_by=id", 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)
...@@ -620,7 +620,7 @@ describe API::Runners do ...@@ -620,7 +620,7 @@ describe API::Runners do
it 'return jobs sorted in ascending order' do it 'return jobs sorted in ascending order' do
get api("/runners/#{project_runner.id}/jobs?order_by=id&sort=asc", admin) get api("/runners/#{project_runner.id}/jobs?order_by=id&sort=asc", 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)
...@@ -634,7 +634,7 @@ describe API::Runners do ...@@ -634,7 +634,7 @@ describe API::Runners do
it 'return 400' do it 'return 400' do
get api("/runners/#{project_runner.id}/jobs?status=non-existing", admin) get api("/runners/#{project_runner.id}/jobs?status=non-existing", admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -642,7 +642,7 @@ describe API::Runners do ...@@ -642,7 +642,7 @@ describe API::Runners do
it 'return 400' do it 'return 400' do
get api("/runners/#{project_runner.id}/jobs?order_by=non-existing", admin) get api("/runners/#{project_runner.id}/jobs?order_by=non-existing", admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -650,7 +650,7 @@ describe API::Runners do ...@@ -650,7 +650,7 @@ describe API::Runners do
it 'return 400' do it 'return 400' do
get api("/runners/#{project_runner.id}/jobs?sort=non-existing", admin) get api("/runners/#{project_runner.id}/jobs?sort=non-existing", admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -659,7 +659,7 @@ describe API::Runners do ...@@ -659,7 +659,7 @@ describe API::Runners do
it 'returns 404' do it 'returns 404' do
get api('/runners/0/jobs', admin) get api('/runners/0/jobs', admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -670,7 +670,7 @@ describe API::Runners do ...@@ -670,7 +670,7 @@ describe API::Runners do
it 'returns 403' do it 'returns 403' do
get api("/runners/#{shared_runner.id}/jobs", user) get api("/runners/#{shared_runner.id}/jobs", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -678,7 +678,7 @@ describe API::Runners do ...@@ -678,7 +678,7 @@ describe API::Runners do
it 'return jobs' do it 'return jobs' do
get api("/runners/#{project_runner.id}/jobs", user) get api("/runners/#{project_runner.id}/jobs", 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)
...@@ -690,7 +690,7 @@ describe API::Runners do ...@@ -690,7 +690,7 @@ describe API::Runners do
it 'return filtered jobs' do it 'return filtered jobs' do
get api("/runners/#{project_runner.id}/jobs?status=failed", user) get api("/runners/#{project_runner.id}/jobs?status=failed", 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)
...@@ -703,7 +703,7 @@ describe API::Runners do ...@@ -703,7 +703,7 @@ describe API::Runners do
it 'return 400' do it 'return 400' do
get api("/runners/#{project_runner.id}/jobs?status=non-existing", user) get api("/runners/#{project_runner.id}/jobs?status=non-existing", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -712,7 +712,7 @@ describe API::Runners do ...@@ -712,7 +712,7 @@ describe API::Runners do
it 'returns 404' do it 'returns 404' do
get api('/runners/0/jobs', user) get api('/runners/0/jobs', user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -721,7 +721,7 @@ describe API::Runners do ...@@ -721,7 +721,7 @@ describe API::Runners do
it 'does not return jobs' do it 'does not return jobs' do
get api("/runners/#{project_runner.id}/jobs", user2) get api("/runners/#{project_runner.id}/jobs", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -729,7 +729,7 @@ describe API::Runners do ...@@ -729,7 +729,7 @@ describe API::Runners do
it 'does not return jobs' do it 'does not return jobs' do
get api("/runners/#{project_runner.id}/jobs") get api("/runners/#{project_runner.id}/jobs")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -739,7 +739,7 @@ describe API::Runners do ...@@ -739,7 +739,7 @@ describe API::Runners do
it 'returns response status and headers' do it 'returns response status and headers' do
get api('/runners/all', admin) get api('/runners/all', 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
end end
...@@ -756,7 +756,7 @@ describe API::Runners do ...@@ -756,7 +756,7 @@ describe API::Runners do
it 'filters runners by scope' do it 'filters runners by scope' do
get api("/projects/#{project.id}/runners?scope=specific", user) get api("/projects/#{project.id}/runners?scope=specific", 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 match_array [ expect(json_response).to match_array [
...@@ -767,7 +767,7 @@ describe API::Runners do ...@@ -767,7 +767,7 @@ describe API::Runners do
it 'avoids filtering if scope is invalid' do it 'avoids filtering if scope is invalid' do
get api("/projects/#{project.id}/runners?scope=unknown", user) get api("/projects/#{project.id}/runners?scope=unknown", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by type' do it 'filters runners by type' do
...@@ -782,7 +782,7 @@ describe API::Runners do ...@@ -782,7 +782,7 @@ describe API::Runners do
it 'does not filter by invalid type' do it 'does not filter by invalid type' do
get api("/projects/#{project.id}/runners?type=bogus", user) get api("/projects/#{project.id}/runners?type=bogus", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by status' do it 'filters runners by status' do
...@@ -798,7 +798,7 @@ describe API::Runners do ...@@ -798,7 +798,7 @@ describe API::Runners do
it 'does not filter by invalid status' do it 'does not filter by invalid status' do
get api("/projects/#{project.id}/runners?status=bogus", user) get api("/projects/#{project.id}/runners?status=bogus", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'filters runners by tag_list' do it 'filters runners by tag_list' do
...@@ -817,7 +817,7 @@ describe API::Runners do ...@@ -817,7 +817,7 @@ describe API::Runners do
it "does not return project's runners" do it "does not return project's runners" do
get api("/projects/#{project.id}/runners", user2) get api("/projects/#{project.id}/runners", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -825,7 +825,7 @@ describe API::Runners do ...@@ -825,7 +825,7 @@ describe API::Runners do
it "does not return project's runners" do it "does not return project's runners" do
get api("/projects/#{project.id}/runners") get api("/projects/#{project.id}/runners")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -838,14 +838,14 @@ describe API::Runners do ...@@ -838,14 +838,14 @@ describe API::Runners do
expect do expect do
post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id }
end.to change { project.runners.count }.by(+1) end.to change { project.runners.count }.by(+1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'avoids changes when enabling already enabled runner' do it 'avoids changes when enabling already enabled runner' do
expect do expect do
post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner.id } post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner.id }
end.to change { project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not enable locked runner' do it 'does not enable locked runner' do
...@@ -855,19 +855,19 @@ describe API::Runners do ...@@ -855,19 +855,19 @@ describe API::Runners do
post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id }
end.to change { project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'does not enable shared runner' do it 'does not enable shared runner' do
post api("/projects/#{project.id}/runners", user), params: { runner_id: shared_runner.id } post api("/projects/#{project.id}/runners", user), params: { runner_id: shared_runner.id }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'does not enable group runner' do it 'does not enable group runner' do
post api("/projects/#{project.id}/runners", user), params: { runner_id: group_runner.id } post api("/projects/#{project.id}/runners", user), params: { runner_id: group_runner.id }
expect(response).to have_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
context 'user is admin' do context 'user is admin' do
...@@ -878,7 +878,7 @@ describe API::Runners do ...@@ -878,7 +878,7 @@ describe API::Runners do
expect do expect do
post api("/projects/#{project.id}/runners", admin), params: { runner_id: new_project_runner.id } post api("/projects/#{project.id}/runners", admin), params: { runner_id: new_project_runner.id }
end.to change { project.runners.count }.by(+1) end.to change { project.runners.count }.by(+1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
...@@ -888,14 +888,14 @@ describe API::Runners do ...@@ -888,14 +888,14 @@ describe API::Runners do
end.to change { project.runners.count }.by(1) end.to change { project.runners.count }.by(1)
expect(shared_runner.reload).not_to be_instance_type expect(shared_runner.reload).not_to be_instance_type
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
it 'raises an error when no runner_id param is provided' do it 'raises an error when no runner_id param is provided' do
post api("/projects/#{project.id}/runners", admin) post api("/projects/#{project.id}/runners", admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -905,7 +905,7 @@ describe API::Runners do ...@@ -905,7 +905,7 @@ describe API::Runners do
it 'does not enable runner without access to' do it 'does not enable runner without access to' do
post api("/projects/#{project.id}/runners", user), params: { runner_id: new_project_runner.id } post api("/projects/#{project.id}/runners", user), params: { runner_id: new_project_runner.id }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -913,7 +913,7 @@ describe API::Runners do ...@@ -913,7 +913,7 @@ describe API::Runners do
it 'does not enable runner' do it 'does not enable runner' do
post api("/projects/#{project.id}/runners", user2) post api("/projects/#{project.id}/runners", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -921,7 +921,7 @@ describe API::Runners do ...@@ -921,7 +921,7 @@ describe API::Runners do
it 'does not enable runner' do it 'does not enable runner' do
post api("/projects/#{project.id}/runners") post api("/projects/#{project.id}/runners")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -933,7 +933,7 @@ describe API::Runners do ...@@ -933,7 +933,7 @@ describe API::Runners do
expect do expect do
delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { project.runners.count }.by(-1) end.to change { project.runners.count }.by(-1)
end end
...@@ -947,14 +947,14 @@ describe API::Runners do ...@@ -947,14 +947,14 @@ describe API::Runners do
expect do expect do
delete api("/projects/#{project.id}/runners/#{project_runner.id}", user) delete api("/projects/#{project.id}/runners/#{project_runner.id}", user)
end.to change { project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
it 'returns 404 is runner is not found' do it 'returns 404 is runner is not found' do
delete api("/projects/#{project.id}/runners/0", user) delete api("/projects/#{project.id}/runners/0", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -962,7 +962,7 @@ describe API::Runners do ...@@ -962,7 +962,7 @@ describe API::Runners do
it "does not disable project's runner" do it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{project_runner.id}", user2) delete api("/projects/#{project.id}/runners/#{project_runner.id}", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -970,7 +970,7 @@ describe API::Runners do ...@@ -970,7 +970,7 @@ describe API::Runners do
it "does not disable project's runner" do it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{project_runner.id}") delete api("/projects/#{project.id}/runners/#{project_runner.id}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
......
...@@ -9,7 +9,7 @@ describe API::Search do ...@@ -9,7 +9,7 @@ describe API::Search do
let_it_be(:repo_project) { create(:project, :public, :repository, group: group) } let_it_be(:repo_project) { create(:project, :public, :repository, group: group) }
shared_examples 'response is correct' do |schema:, size: 1| shared_examples 'response is correct' do |schema:, size: 1|
it { expect(response).to have_gitlab_http_status(200) } it { expect(response).to have_gitlab_http_status(:ok) }
it { expect(response).to match_response_schema(schema) } it { expect(response).to match_response_schema(schema) }
it { expect(response).to include_limited_pagination_headers } it { expect(response).to include_limited_pagination_headers }
it { expect(json_response.size).to eq(size) } it { expect(json_response.size).to eq(size) }
...@@ -20,7 +20,7 @@ describe API::Search do ...@@ -20,7 +20,7 @@ describe API::Search do
it 'returns 401 error' do it 'returns 401 error' do
get api('/search'), params: { scope: 'projects', search: 'awesome' } get api('/search'), params: { scope: 'projects', search: 'awesome' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -28,7 +28,7 @@ describe API::Search do ...@@ -28,7 +28,7 @@ describe API::Search do
it 'returns 400 error' do it 'returns 400 error' do
get api('/search', user), params: { scope: 'unsupported', search: 'awesome' } get api('/search', user), params: { scope: 'unsupported', search: 'awesome' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -36,7 +36,7 @@ describe API::Search do ...@@ -36,7 +36,7 @@ describe API::Search do
it 'returns 400 error' do it 'returns 400 error' do
get api('/search', user), params: { search: 'awesome' } get api('/search', user), params: { search: 'awesome' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -115,7 +115,7 @@ describe API::Search do ...@@ -115,7 +115,7 @@ describe API::Search do
end end
it 'returns 400 error' do it 'returns 400 error' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -147,7 +147,7 @@ describe API::Search do ...@@ -147,7 +147,7 @@ describe API::Search do
it 'returns 401 error' do it 'returns 401 error' do
get api("/groups/#{group.id}/search"), params: { scope: 'projects', search: 'awesome' } get api("/groups/#{group.id}/search"), params: { scope: 'projects', search: 'awesome' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -155,7 +155,7 @@ describe API::Search do ...@@ -155,7 +155,7 @@ describe API::Search do
it 'returns 400 error' do it 'returns 400 error' do
get api("/groups/#{group.id}/search", user), params: { scope: 'unsupported', search: 'awesome' } get api("/groups/#{group.id}/search", user), params: { scope: 'unsupported', search: 'awesome' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -163,7 +163,7 @@ describe API::Search do ...@@ -163,7 +163,7 @@ describe API::Search do
it 'returns 400 error' do it 'returns 400 error' do
get api("/groups/#{group.id}/search", user), params: { search: 'awesome' } get api("/groups/#{group.id}/search", user), params: { search: 'awesome' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -171,7 +171,7 @@ describe API::Search do ...@@ -171,7 +171,7 @@ describe API::Search do
it 'returns 404 error' do it 'returns 404 error' do
get api('/groups/0/search', user), params: { scope: 'issues', search: 'awesome' } get api('/groups/0/search', user), params: { scope: 'issues', search: 'awesome' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -181,7 +181,7 @@ describe API::Search do ...@@ -181,7 +181,7 @@ describe API::Search do
get api("/groups/#{private_group.id}/search", user), params: { scope: 'issues', search: 'awesome' } get api("/groups/#{private_group.id}/search", user), params: { scope: 'issues', search: 'awesome' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -254,7 +254,7 @@ describe API::Search do ...@@ -254,7 +254,7 @@ describe API::Search do
end end
it 'returns 400 error' do it 'returns 400 error' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -277,7 +277,7 @@ describe API::Search do ...@@ -277,7 +277,7 @@ describe API::Search do
it 'returns 401 error' do it 'returns 401 error' do
get api("/projects/#{project.id}/search"), params: { scope: 'issues', search: 'awesome' } get api("/projects/#{project.id}/search"), params: { scope: 'issues', search: 'awesome' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -285,7 +285,7 @@ describe API::Search do ...@@ -285,7 +285,7 @@ describe API::Search do
it 'returns 400 error' do it 'returns 400 error' do
get api("/projects/#{project.id}/search", user), params: { scope: 'unsupported', search: 'awesome' } get api("/projects/#{project.id}/search", user), params: { scope: 'unsupported', search: 'awesome' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -293,7 +293,7 @@ describe API::Search do ...@@ -293,7 +293,7 @@ describe API::Search do
it 'returns 400 error' do it 'returns 400 error' do
get api("/projects/#{project.id}/search", user), params: { search: 'awesome' } get api("/projects/#{project.id}/search", user), params: { search: 'awesome' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -301,7 +301,7 @@ describe API::Search do ...@@ -301,7 +301,7 @@ describe API::Search do
it 'returns 404 error' do it 'returns 404 error' do
get api('/projects/0/search', user), params: { scope: 'issues', search: 'awesome' } get api('/projects/0/search', user), params: { scope: 'issues', search: 'awesome' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -311,7 +311,7 @@ describe API::Search do ...@@ -311,7 +311,7 @@ describe API::Search do
get api("/projects/#{project.id}/search", user), params: { scope: 'issues', search: 'awesome' } get api("/projects/#{project.id}/search", user), params: { scope: 'issues', search: 'awesome' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -383,7 +383,7 @@ describe API::Search do ...@@ -383,7 +383,7 @@ describe API::Search do
end end
it 'returns 400 error' do it 'returns 400 error' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -436,7 +436,7 @@ describe API::Search do ...@@ -436,7 +436,7 @@ describe API::Search do
it 'by filename' do it 'by filename' do
get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon filename:PROCESS.md' } get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon filename:PROCESS.md' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2) expect(json_response.size).to eq(2)
expect(json_response.first['path']).to eq('PROCESS.md') expect(json_response.first['path']).to eq('PROCESS.md')
expect(json_response.first['filename']).to eq('PROCESS.md') expect(json_response.first['filename']).to eq('PROCESS.md')
...@@ -445,21 +445,21 @@ describe API::Search do ...@@ -445,21 +445,21 @@ describe API::Search do
it 'by path' do it 'by path' do
get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon path:markdown' } get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon path:markdown' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(8) expect(json_response.size).to eq(8)
end end
it 'by extension' do it 'by extension' do
get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon extension:md' } get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon extension:md' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(11) expect(json_response.size).to eq(11)
end end
it 'by ref' do it 'by ref' do
get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'This file is used in tests for ci_environments_status', ref: 'pages-deploy' } get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'This file is used in tests for ci_environments_status', ref: 'pages-deploy' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
end end
end end
......
...@@ -14,14 +14,14 @@ describe API::Services do ...@@ -14,14 +14,14 @@ describe API::Services do
it 'returns authentication error when unauthenticated' do it 'returns authentication error when unauthenticated' do
get api("/projects/#{project.id}/services") get api("/projects/#{project.id}/services")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it "returns error when authenticated but user is not a project owner" do it "returns error when authenticated but user is not a project owner" do
project.add_developer(user2) project.add_developer(user2)
get api("/projects/#{project.id}/services", user2) get api("/projects/#{project.id}/services", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
context 'project with services' do context 'project with services' do
...@@ -32,7 +32,7 @@ describe API::Services do ...@@ -32,7 +32,7 @@ describe API::Services do
get api("/projects/#{project.id}/services", user) get api("/projects/#{project.id}/services", user)
aggregate_failures 'expect successful response with all active services' do aggregate_failures 'expect successful response with all active services' 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
expect(json_response.count).to eq(1) expect(json_response.count).to eq(1)
expect(json_response.first['slug']).to eq('emails-on-push') expect(json_response.first['slug']).to eq('emails-on-push')
...@@ -49,7 +49,7 @@ describe API::Services do ...@@ -49,7 +49,7 @@ describe API::Services do
it "updates #{service} settings" do it "updates #{service} settings" do
put api("/projects/#{project.id}/services/#{dashed_service}", user), params: service_attrs put api("/projects/#{project.id}/services/#{dashed_service}", user), params: service_attrs
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
current_service = project.services.first current_service = project.services.first
events = current_service.event_names.empty? ? ["foo"].freeze : current_service.event_names events = current_service.event_names.empty? ? ["foo"].freeze : current_service.event_names
...@@ -61,7 +61,7 @@ describe API::Services do ...@@ -61,7 +61,7 @@ describe API::Services do
put api("/projects/#{project.id}/services/#{dashed_service}?#{query_strings}", user), params: service_attrs put api("/projects/#{project.id}/services/#{dashed_service}?#{query_strings}", user), params: service_attrs
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['slug']).to eq(dashed_service) expect(json_response['slug']).to eq(dashed_service)
events.each do |event| events.each do |event|
next if event == "foo" next if event == "foo"
...@@ -103,7 +103,7 @@ describe API::Services do ...@@ -103,7 +103,7 @@ describe API::Services do
it "deletes #{service}" do it "deletes #{service}" do
delete api("/projects/#{project.id}/services/#{dashed_service}", user) delete api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
project.send(service_method).reload project.send(service_method).reload
expect(project.send(service_method).activated?).to be_falsey expect(project.send(service_method).activated?).to be_falsey
end end
...@@ -117,13 +117,13 @@ describe API::Services do ...@@ -117,13 +117,13 @@ describe API::Services do
it 'returns authentication error when unauthenticated' do it 'returns authentication error when unauthenticated' do
get api("/projects/#{project.id}/services/#{dashed_service}") get api("/projects/#{project.id}/services/#{dashed_service}")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it "returns all properties of service #{service}" do it "returns all properties of service #{service}" do
get api("/projects/#{project.id}/services/#{dashed_service}", user) get api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['properties'].keys).to match_array(service_instance.api_field_names) expect(json_response['properties'].keys).to match_array(service_instance.api_field_names)
end end
...@@ -131,7 +131,7 @@ describe API::Services do ...@@ -131,7 +131,7 @@ describe API::Services do
project.add_developer(user2) project.add_developer(user2)
get api("/projects/#{project.id}/services/#{dashed_service}", user2) get api("/projects/#{project.id}/services/#{dashed_service}", user2)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -144,7 +144,7 @@ describe API::Services do ...@@ -144,7 +144,7 @@ describe API::Services do
it 'returns a not found message' do it 'returns a not found message' do
post api("/projects/#{project.id}/services/idonotexist/trigger") post api("/projects/#{project.id}/services/idonotexist/trigger")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response["error"]).to eq("404 Not Found") expect(json_response["error"]).to eq("404 Not Found")
end end
end end
...@@ -163,7 +163,7 @@ describe API::Services do ...@@ -163,7 +163,7 @@ describe API::Services do
it 'when the service is inactive' do it 'when the service is inactive' do
post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -178,7 +178,7 @@ describe API::Services do ...@@ -178,7 +178,7 @@ describe API::Services do
it 'returns status 200' do it 'returns status 200' do
post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -186,7 +186,7 @@ describe API::Services do ...@@ -186,7 +186,7 @@ describe API::Services do
it 'returns a generic 404' do it 'returns a generic 404' do
post api("/projects/404/services/#{service_name}/trigger"), params: params post api("/projects/404/services/#{service_name}/trigger"), params: params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response["message"]).to eq("404 Service Not Found") expect(json_response["message"]).to eq("404 Service Not Found")
end end
end end
...@@ -206,7 +206,7 @@ describe API::Services do ...@@ -206,7 +206,7 @@ describe API::Services do
it 'returns status 200' do it 'returns status 200' do
post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: { token: 'token', text: 'help' } post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: { token: 'token', text: 'help' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['response_type']).to eq("ephemeral") expect(json_response['response_type']).to eq("ephemeral")
end end
end end
...@@ -228,7 +228,7 @@ describe API::Services do ...@@ -228,7 +228,7 @@ describe API::Services do
it 'accepts a username for update' do it 'accepts a username for update' do
put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(username: 'new_username') put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(username: 'new_username')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['properties']['username']).to eq('new_username') expect(json_response['properties']['username']).to eq('new_username')
end end
end end
...@@ -253,14 +253,14 @@ describe API::Services do ...@@ -253,14 +253,14 @@ describe API::Services do
it 'accepts branches_to_be_notified for update' do it 'accepts branches_to_be_notified for update' do
put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(branches_to_be_notified: 'all') put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(branches_to_be_notified: 'all')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['properties']['branches_to_be_notified']).to eq('all') expect(json_response['properties']['branches_to_be_notified']).to eq('all')
end end
it 'accepts notify_only_broken_pipelines for update' do it 'accepts notify_only_broken_pipelines for update' do
put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(notify_only_broken_pipelines: true) put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(notify_only_broken_pipelines: true)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['properties']['notify_only_broken_pipelines']).to eq(true) expect(json_response['properties']['notify_only_broken_pipelines']).to eq(true)
end end
end end
......
...@@ -11,7 +11,7 @@ describe API::Settings, 'Settings' do ...@@ -11,7 +11,7 @@ describe API::Settings, 'Settings' do
it "returns application settings" do it "returns application settings" do
get api("/application/settings", admin) get api("/application/settings", admin)
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['default_projects_limit']).to eq(42) expect(json_response['default_projects_limit']).to eq(42)
expect(json_response['password_authentication_enabled_for_web']).to be_truthy expect(json_response['password_authentication_enabled_for_web']).to be_truthy
...@@ -91,7 +91,7 @@ describe API::Settings, 'Settings' do ...@@ -91,7 +91,7 @@ describe API::Settings, 'Settings' do
snippet_size_limit: 5 snippet_size_limit: 5
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['default_ci_config_path']).to eq('debian/salsa-ci.yml') expect(json_response['default_ci_config_path']).to eq('debian/salsa-ci.yml')
expect(json_response['default_projects_limit']).to eq(3) expect(json_response['default_projects_limit']).to eq(3)
expect(json_response['default_project_creation']).to eq(::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) expect(json_response['default_project_creation']).to eq(::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS)
...@@ -132,7 +132,7 @@ describe API::Settings, 'Settings' do ...@@ -132,7 +132,7 @@ describe API::Settings, 'Settings' do
put api("/application/settings", admin), put api("/application/settings", admin),
params: { performance_bar_allowed_group_id: group.full_path } params: { performance_bar_allowed_group_id: group.full_path }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['performance_bar_allowed_group_id']).to eq(group.id) expect(json_response['performance_bar_allowed_group_id']).to eq(group.id)
end end
...@@ -143,7 +143,7 @@ describe API::Settings, 'Settings' do ...@@ -143,7 +143,7 @@ describe API::Settings, 'Settings' do
performance_bar_allowed_group_id: group.full_path performance_bar_allowed_group_id: group.full_path
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['performance_bar_allowed_group_id']).to be_nil expect(json_response['performance_bar_allowed_group_id']).to be_nil
end end
...@@ -151,7 +151,7 @@ describe API::Settings, 'Settings' do ...@@ -151,7 +151,7 @@ describe API::Settings, 'Settings' do
put api("/application/settings", admin), put api("/application/settings", admin),
params: { allow_local_requests_from_hooks_and_services: true } params: { allow_local_requests_from_hooks_and_services: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['allow_local_requests_from_hooks_and_services']).to eq(true) expect(json_response['allow_local_requests_from_hooks_and_services']).to eq(true)
end end
...@@ -173,7 +173,7 @@ describe API::Settings, 'Settings' do ...@@ -173,7 +173,7 @@ describe API::Settings, 'Settings' do
it 'includes the attributes in the API' do it 'includes the attributes in the API' do
get api("/application/settings", admin) get api("/application/settings", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
attribute_names.each do |attribute| attribute_names.each do |attribute|
expect(json_response.keys).to include(attribute) expect(json_response.keys).to include(attribute)
end end
...@@ -182,7 +182,7 @@ describe API::Settings, 'Settings' do ...@@ -182,7 +182,7 @@ describe API::Settings, 'Settings' do
it 'allows updating the settings' do it 'allows updating the settings' do
put api("/application/settings", admin), params: settings put api("/application/settings", admin), params: settings
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
settings.each do |attribute, value| settings.each do |attribute, value|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value) expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
end end
...@@ -205,7 +205,7 @@ describe API::Settings, 'Settings' do ...@@ -205,7 +205,7 @@ describe API::Settings, 'Settings' do
it "includes the attributes in the API" do it "includes the attributes in the API" do
get api("/application/settings", admin) get api("/application/settings", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
attribute_names.each do |attribute| attribute_names.each do |attribute|
expect(json_response.keys).to include(attribute) expect(json_response.keys).to include(attribute)
end end
...@@ -214,7 +214,7 @@ describe API::Settings, 'Settings' do ...@@ -214,7 +214,7 @@ describe API::Settings, 'Settings' do
it "allows updating the settings" do it "allows updating the settings" do
put api("/application/settings", admin), params: settings put api("/application/settings", admin), params: settings
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
settings.each do |attribute, value| settings.each do |attribute, value|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value) expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
end end
...@@ -224,7 +224,7 @@ describe API::Settings, 'Settings' do ...@@ -224,7 +224,7 @@ describe API::Settings, 'Settings' do
it "returns a blank parameter error message" do it "returns a blank parameter error message" do
put api("/application/settings", admin), params: { snowplow_enabled: true } put api("/application/settings", admin), params: { snowplow_enabled: true }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to eq("snowplow_collector_hostname is missing") expect(json_response["error"]).to eq("snowplow_collector_hostname is missing")
end end
...@@ -233,7 +233,7 @@ describe API::Settings, 'Settings' do ...@@ -233,7 +233,7 @@ describe API::Settings, 'Settings' do
snowplow_collector_hostname: nil snowplow_collector_hostname: nil
}) })
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
message = json_response["message"] message = json_response["message"]
expect(message["snowplow_collector_hostname"]).to include("can't be blank") expect(message["snowplow_collector_hostname"]).to include("can't be blank")
end end
...@@ -257,7 +257,7 @@ describe API::Settings, 'Settings' do ...@@ -257,7 +257,7 @@ describe API::Settings, 'Settings' do
it 'includes attributes in the API' do it 'includes attributes in the API' do
get api("/application/settings", admin) get api("/application/settings", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
exposed_attributes.each do |attribute| exposed_attributes.each do |attribute|
expect(json_response.keys).to include(attribute) expect(json_response.keys).to include(attribute)
end end
...@@ -266,7 +266,7 @@ describe API::Settings, 'Settings' do ...@@ -266,7 +266,7 @@ describe API::Settings, 'Settings' do
it 'does not include sensitive attributes in the API' do it 'does not include sensitive attributes in the API' do
get api("/application/settings", admin) get api("/application/settings", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
sensitive_attributes.each do |attribute| sensitive_attributes.each do |attribute|
expect(json_response.keys).not_to include(attribute) expect(json_response.keys).not_to include(attribute)
end end
...@@ -275,7 +275,7 @@ describe API::Settings, 'Settings' do ...@@ -275,7 +275,7 @@ describe API::Settings, 'Settings' do
it 'allows updating the settings' do it 'allows updating the settings' do
put api("/application/settings", admin), params: settings put api("/application/settings", admin), params: settings
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
settings.each do |attribute, value| settings.each do |attribute, value|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value) expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
end end
...@@ -287,7 +287,7 @@ describe API::Settings, 'Settings' do ...@@ -287,7 +287,7 @@ describe API::Settings, 'Settings' do
it 'does not update the settings' do it 'does not update the settings' do
put api("/application/settings", admin), params: settings put api("/application/settings", admin), params: settings
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to include('eks_account_id is missing') expect(json_response['error']).to include('eks_account_id is missing')
expect(json_response['error']).to include('eks_access_key_id is missing') expect(json_response['error']).to include('eks_access_key_id is missing')
expect(json_response['error']).to include('eks_secret_access_key is missing') expect(json_response['error']).to include('eks_secret_access_key is missing')
...@@ -299,7 +299,7 @@ describe API::Settings, 'Settings' do ...@@ -299,7 +299,7 @@ describe API::Settings, 'Settings' do
it "returns a blank parameter error message" do it "returns a blank parameter error message" do
put api("/application/settings", admin), params: { plantuml_enabled: true } put api("/application/settings", admin), params: { plantuml_enabled: true }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('plantuml_url is missing') expect(json_response['error']).to eq('plantuml_url is missing')
end end
end end
...@@ -314,7 +314,7 @@ describe API::Settings, 'Settings' do ...@@ -314,7 +314,7 @@ describe API::Settings, 'Settings' do
asset_proxy_whitelist: ['example.com', '*.example.com'] asset_proxy_whitelist: ['example.com', '*.example.com']
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['asset_proxy_enabled']).to be(true) expect(json_response['asset_proxy_enabled']).to be(true)
expect(json_response['asset_proxy_url']).to eq('http://assets.example.com') expect(json_response['asset_proxy_url']).to eq('http://assets.example.com')
expect(json_response['asset_proxy_secret_key']).to be_nil expect(json_response['asset_proxy_secret_key']).to be_nil
...@@ -327,7 +327,7 @@ describe API::Settings, 'Settings' do ...@@ -327,7 +327,7 @@ describe API::Settings, 'Settings' do
asset_proxy_whitelist: 'example.com, *.example.com' asset_proxy_whitelist: 'example.com, *.example.com'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['asset_proxy_whitelist']).to eq(['example.com', '*.example.com', 'localhost']) expect(json_response['asset_proxy_whitelist']).to eq(['example.com', '*.example.com', 'localhost'])
end end
end end
...@@ -340,7 +340,7 @@ describe API::Settings, 'Settings' do ...@@ -340,7 +340,7 @@ describe API::Settings, 'Settings' do
domain_blacklist: [] domain_blacklist: []
} }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
message = json_response["message"] message = json_response["message"]
expect(message["domain_blacklist"]).to eq(["Domain blacklist cannot be empty if Blacklist is enabled."]) expect(message["domain_blacklist"]).to eq(["Domain blacklist cannot be empty if Blacklist is enabled."])
end end
...@@ -352,7 +352,7 @@ describe API::Settings, 'Settings' do ...@@ -352,7 +352,7 @@ describe API::Settings, 'Settings' do
domain_blacklist: ['domain1.com', 'domain2.com'] domain_blacklist: ['domain1.com', 'domain2.com']
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['domain_blacklist_enabled']).to be(true) expect(json_response['domain_blacklist_enabled']).to be(true)
expect(json_response['domain_blacklist']).to eq(['domain1.com', 'domain2.com']) expect(json_response['domain_blacklist']).to eq(['domain1.com', 'domain2.com'])
end end
...@@ -364,7 +364,7 @@ describe API::Settings, 'Settings' do ...@@ -364,7 +364,7 @@ describe API::Settings, 'Settings' do
domain_blacklist: 'domain3.com, *.domain4.com' domain_blacklist: 'domain3.com, *.domain4.com'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['domain_blacklist_enabled']).to be(true) expect(json_response['domain_blacklist_enabled']).to be(true)
expect(json_response['domain_blacklist']).to eq(['domain3.com', '*.domain4.com']) expect(json_response['domain_blacklist']).to eq(['domain3.com', '*.domain4.com'])
end end
...@@ -374,7 +374,7 @@ describe API::Settings, 'Settings' do ...@@ -374,7 +374,7 @@ describe API::Settings, 'Settings' do
it "returns a blank parameter error message" do it "returns a blank parameter error message" do
put api("/application/settings", admin), params: { sourcegraph_enabled: true } put api("/application/settings", admin), params: { sourcegraph_enabled: true }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('sourcegraph_url is missing') expect(json_response['error']).to eq('sourcegraph_url is missing')
end end
end end
......
...@@ -9,21 +9,21 @@ describe API::SidekiqMetrics do ...@@ -9,21 +9,21 @@ describe API::SidekiqMetrics do
it 'defines the `queue_metrics` endpoint' do it 'defines the `queue_metrics` endpoint' do
get api('/sidekiq/queue_metrics', admin) get api('/sidekiq/queue_metrics', admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash expect(json_response).to be_a Hash
end end
it 'defines the `process_metrics` endpoint' do it 'defines the `process_metrics` endpoint' do
get api('/sidekiq/process_metrics', admin) get api('/sidekiq/process_metrics', admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['processes']).to be_an Array expect(json_response['processes']).to be_an Array
end end
it 'defines the `job_stats` endpoint' do it 'defines the `job_stats` endpoint' do
get api('/sidekiq/job_stats', admin) get api('/sidekiq/job_stats', admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash expect(json_response).to be_a Hash
expect(json_response['jobs']).to be_a Hash expect(json_response['jobs']).to be_a Hash
expect(json_response['jobs'].keys) expect(json_response['jobs'].keys)
...@@ -34,7 +34,7 @@ describe API::SidekiqMetrics do ...@@ -34,7 +34,7 @@ describe API::SidekiqMetrics do
it 'defines the `compound_metrics` endpoint' do it 'defines the `compound_metrics` endpoint' do
get api('/sidekiq/compound_metrics', admin) get api('/sidekiq/compound_metrics', admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash expect(json_response).to be_a Hash
expect(json_response['queues']).to be_a Hash expect(json_response['queues']).to be_a Hash
expect(json_response['processes']).to be_an Array expect(json_response['processes']).to be_an Array
......
...@@ -13,7 +13,7 @@ describe API::Snippets do ...@@ -13,7 +13,7 @@ describe API::Snippets do
get api("/snippets/", user) get api("/snippets/", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
...@@ -30,7 +30,7 @@ describe API::Snippets do ...@@ -30,7 +30,7 @@ describe API::Snippets do
get api("/snippets/", user) get api("/snippets/", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(0) expect(json_response.size).to eq(0)
...@@ -41,7 +41,7 @@ describe API::Snippets do ...@@ -41,7 +41,7 @@ describe API::Snippets do
get api("/snippets/") get api("/snippets/")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'does not return snippets related to a project with disable feature visibility' do it 'does not return snippets related to a project with disable feature visibility' do
...@@ -73,7 +73,7 @@ describe API::Snippets do ...@@ -73,7 +73,7 @@ describe API::Snippets do
it 'returns all snippets with public visibility from all users' do it 'returns all snippets with public visibility from all users' do
get api("/snippets/public", user) get api("/snippets/public", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
...@@ -95,13 +95,13 @@ describe API::Snippets do ...@@ -95,13 +95,13 @@ describe API::Snippets do
it 'requires authentication' do it 'requires authentication' do
get api("/snippets/#{snippet.id}", nil) get api("/snippets/#{snippet.id}", nil)
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'returns raw text' do it 'returns raw text' do
get api("/snippets/#{snippet.id}/raw", author) get api("/snippets/#{snippet.id}/raw", author)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
expect(response.body).to eq(snippet.content) expect(response.body).to eq(snippet.content)
end end
...@@ -117,14 +117,14 @@ describe API::Snippets do ...@@ -117,14 +117,14 @@ describe API::Snippets do
get api("/snippets/#{snippet.id}/raw", author) get api("/snippets/#{snippet.id}/raw", author)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
it 'hides private snippets from ordinary users' do it 'hides private snippets from ordinary users' do
get api("/snippets/#{snippet.id}/raw", user) get api("/snippets/#{snippet.id}/raw", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'shows internal snippets to ordinary users' do it 'shows internal snippets to ordinary users' do
...@@ -132,7 +132,7 @@ describe API::Snippets do ...@@ -132,7 +132,7 @@ describe API::Snippets do
get api("/snippets/#{internal_snippet.id}/raw", user) get api("/snippets/#{internal_snippet.id}/raw", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -145,13 +145,13 @@ describe API::Snippets do ...@@ -145,13 +145,13 @@ describe API::Snippets do
it 'requires authentication' do it 'requires authentication' do
get api("/snippets/#{private_snippet.id}", nil) get api("/snippets/#{private_snippet.id}", nil)
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'returns snippet json' do it 'returns snippet json' do
get api("/snippets/#{private_snippet.id}", author) get api("/snippets/#{private_snippet.id}", author)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(private_snippet.title) expect(json_response['title']).to eq(private_snippet.title)
expect(json_response['description']).to eq(private_snippet.description) expect(json_response['description']).to eq(private_snippet.description)
...@@ -162,19 +162,19 @@ describe API::Snippets do ...@@ -162,19 +162,19 @@ describe API::Snippets do
it 'shows private snippets to an admin' do it 'shows private snippets to an admin' do
get api("/snippets/#{private_snippet.id}", admin) get api("/snippets/#{private_snippet.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'hides private snippets from an ordinary user' do it 'hides private snippets from an ordinary user' do
get api("/snippets/#{private_snippet.id}", user) get api("/snippets/#{private_snippet.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'shows internal snippets to an ordinary user' do it 'shows internal snippets to an ordinary user' do
get api("/snippets/#{internal_snippet.id}", user) get api("/snippets/#{internal_snippet.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
...@@ -182,7 +182,7 @@ describe API::Snippets do ...@@ -182,7 +182,7 @@ describe API::Snippets do
get api("/snippets/#{private_snippet.id}", admin) get api("/snippets/#{private_snippet.id}", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
end end
...@@ -204,7 +204,7 @@ describe API::Snippets do ...@@ -204,7 +204,7 @@ describe API::Snippets do
post api("/snippets/", user), params: params post api("/snippets/", user), params: params
end.to change { PersonalSnippet.count }.by(1) end.to change { PersonalSnippet.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq(params[:title]) expect(json_response['title']).to eq(params[:title])
expect(json_response['description']).to eq(params[:description]) expect(json_response['description']).to eq(params[:description])
expect(json_response['file_name']).to eq(params[:file_name]) expect(json_response['file_name']).to eq(params[:file_name])
...@@ -229,7 +229,7 @@ describe API::Snippets do ...@@ -229,7 +229,7 @@ describe API::Snippets do
post api("/snippets/", user), params: params post api("/snippets/", user), params: params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context 'when the snippet is spam' do context 'when the snippet is spam' do
...@@ -255,7 +255,7 @@ describe API::Snippets do ...@@ -255,7 +255,7 @@ describe API::Snippets do
expect { create_snippet(visibility: 'public') } expect { create_snippet(visibility: 'public') }
.not_to change { Snippet.count } .not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" }) expect(json_response['message']).to eq({ "error" => "Spam detected" })
end end
...@@ -281,7 +281,7 @@ describe API::Snippets do ...@@ -281,7 +281,7 @@ describe API::Snippets do
put api("/snippets/#{snippet.id}", user), params: { content: new_content, description: new_description, visibility: 'internal' } put api("/snippets/#{snippet.id}", user), params: { content: new_content, description: new_description, visibility: 'internal' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
snippet.reload snippet.reload
expect(snippet.content).to eq(new_content) expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description) expect(snippet.description).to eq(new_description)
...@@ -304,21 +304,21 @@ describe API::Snippets do ...@@ -304,21 +304,21 @@ describe API::Snippets do
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
put api("/snippets/1234", user), params: { title: 'foo' } put api("/snippets/1234", user), params: { title: 'foo' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
it "returns 404 for another user's snippet" do it "returns 404 for another user's snippet" do
put api("/snippets/#{snippet.id}", other_user), params: { title: 'fubar' } put api("/snippets/#{snippet.id}", other_user), params: { title: 'fubar' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
it 'returns 400 for missing parameters' do it 'returns 400 for missing parameters' do
put api("/snippets/1234", user) put api("/snippets/1234", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context 'when the snippet is spam' do context 'when the snippet is spam' do
...@@ -348,7 +348,7 @@ describe API::Snippets do ...@@ -348,7 +348,7 @@ describe API::Snippets do
expect { update_snippet(title: 'Foo') } expect { update_snippet(title: 'Foo') }
.not_to change { snippet.reload.title } .not_to change { snippet.reload.title }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" }) expect(json_response['message']).to eq({ "error" => "Spam detected" })
end end
...@@ -380,14 +380,14 @@ describe API::Snippets do ...@@ -380,14 +380,14 @@ describe API::Snippets do
expect do expect do
delete api("/snippets/#{public_snippet.id}", user) delete api("/snippets/#{public_snippet.id}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { PersonalSnippet.count }.by(-1) end.to change { PersonalSnippet.count }.by(-1)
end end
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
delete api("/snippets/1234", user) delete api("/snippets/1234", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
...@@ -404,7 +404,7 @@ describe API::Snippets do ...@@ -404,7 +404,7 @@ describe API::Snippets do
it 'exposes known attributes' do it 'exposes known attributes' do
get api("/snippets/#{snippet.id}/user_agent_detail", admin) get api("/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
...@@ -413,7 +413,7 @@ describe API::Snippets do ...@@ -413,7 +413,7 @@ describe API::Snippets do
it "returns unauthorized for non-admin users" do it "returns unauthorized for non-admin users" do
get api("/snippets/#{snippet.id}/user_agent_detail", user) get api("/snippets/#{snippet.id}/user_agent_detail", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -25,7 +25,7 @@ describe API::Statistics, 'Statistics' do ...@@ -25,7 +25,7 @@ describe API::Statistics, 'Statistics' do
it "returns authentication error" do it "returns authentication error" do
get api(path, nil) get api(path, nil)
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -35,7 +35,7 @@ describe API::Statistics, 'Statistics' do ...@@ -35,7 +35,7 @@ describe API::Statistics, 'Statistics' do
it "returns forbidden error" do it "returns forbidden error" do
get api(path, user) get api(path, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -45,7 +45,7 @@ describe API::Statistics, 'Statistics' do ...@@ -45,7 +45,7 @@ describe API::Statistics, 'Statistics' do
it 'matches the response schema' do it 'matches the response schema' do
get api(path, admin) get api(path, admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('statistics') expect(response).to match_response_schema('statistics')
end end
......
...@@ -33,7 +33,7 @@ describe API::Submodules do ...@@ -33,7 +33,7 @@ describe API::Submodules do
it 'returns 401' do it 'returns 401' do
put api(route(submodule)), params: params put api(route(submodule)), params: params
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -41,7 +41,7 @@ describe API::Submodules do ...@@ -41,7 +41,7 @@ describe API::Submodules do
it 'returns 403' do it 'returns 403' do
put api(route(submodule), guest), params: params put api(route(submodule), guest), params: params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -49,19 +49,19 @@ describe API::Submodules do ...@@ -49,19 +49,19 @@ describe API::Submodules do
it 'returns 400 if params is missing' do it 'returns 400 if params is missing' do
put api(route(submodule), user) put api(route(submodule), user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 400 if branch is missing' do it 'returns 400 if branch is missing' do
put api(route(submodule), user), params: params.except(:branch) put api(route(submodule), user), params: params.except(:branch)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 400 if commit_sha is missing' do it 'returns 400 if commit_sha is missing' do
put api(route(submodule), user), params: params.except(:commit_sha) put api(route(submodule), user), params: params.except(:commit_sha)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns the commit' do it 'returns the commit' do
...@@ -69,7 +69,7 @@ describe API::Submodules do ...@@ -69,7 +69,7 @@ describe API::Submodules do
put api(route(submodule), user), params: params put api(route(submodule), user), params: params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['message']).to eq commit_message expect(json_response['message']).to eq commit_message
expect(json_response['author_name']).to eq user.name expect(json_response['author_name']).to eq user.name
expect(json_response['committer_name']).to eq user.name expect(json_response['committer_name']).to eq user.name
...@@ -89,7 +89,7 @@ describe API::Submodules do ...@@ -89,7 +89,7 @@ describe API::Submodules do
put api(route(encoded_submodule), user), params: params put api(route(encoded_submodule), user), params: params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq project.repository.commit(branch).id expect(json_response['id']).to eq project.repository.commit(branch).id
expect(project.repository.blob_at(branch, submodule).id).to eq commit_sha expect(project.repository.blob_at(branch, submodule).id).to eq commit_sha
end end
......
...@@ -40,7 +40,7 @@ describe API::Suggestions do ...@@ -40,7 +40,7 @@ describe API::Suggestions do
put api(url, user), params: { id: suggestion.id } put api(url, user), params: { id: suggestion.id }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response) expect(json_response)
.to include('id', 'from_line', 'to_line', 'appliable', 'applied', .to include('id', 'from_line', 'to_line', 'appliable', 'applied',
'from_content', 'to_content') 'from_content', 'to_content')
...@@ -57,7 +57,7 @@ describe API::Suggestions do ...@@ -57,7 +57,7 @@ describe API::Suggestions do
put api(url, user), params: { id: suggestion.id } put api(url, user), params: { id: suggestion.id }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq({ 'message' => 'Suggestion is not appliable' }) expect(json_response).to eq({ 'message' => 'Suggestion is not appliable' })
end end
end end
...@@ -74,7 +74,7 @@ describe API::Suggestions do ...@@ -74,7 +74,7 @@ describe API::Suggestions do
put api(url, user), params: { id: suggestion.id } put api(url, user), params: { id: suggestion.id }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response).to eq({ 'message' => '403 Forbidden' }) expect(json_response).to eq({ 'message' => '403 Forbidden' })
end end
end end
......
...@@ -18,7 +18,7 @@ describe API::SystemHooks do ...@@ -18,7 +18,7 @@ describe API::SystemHooks do
it "returns authentication error" do it "returns authentication error" do
get api("/hooks") get api("/hooks")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -26,7 +26,7 @@ describe API::SystemHooks do ...@@ -26,7 +26,7 @@ describe API::SystemHooks do
it "returns forbidden error" do it "returns forbidden error" do
get api("/hooks", user) get api("/hooks", 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::SystemHooks do ...@@ -34,7 +34,7 @@ describe API::SystemHooks do
it "returns an array of hooks" do it "returns an array of hooks" do
get api("/hooks", admin) get api("/hooks", 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['url']).to eq(hook.url) expect(json_response.first['url']).to eq(hook.url)
...@@ -56,13 +56,13 @@ describe API::SystemHooks do ...@@ -56,13 +56,13 @@ describe API::SystemHooks do
it "responds with 400 if url not given" do it "responds with 400 if url not given" do
post api("/hooks", admin) post api("/hooks", admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "responds with 400 if url is invalid" do it "responds with 400 if url is invalid" do
post api("/hooks", admin), params: { url: 'hp://mep.mep' } post api("/hooks", admin), params: { url: 'hp://mep.mep' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "does not create new hook without url" do it "does not create new hook without url" do
...@@ -76,7 +76,7 @@ describe API::SystemHooks do ...@@ -76,7 +76,7 @@ describe API::SystemHooks do
post api('/hooks', admin), params: { url: 'http://mep.mep' } post api('/hooks', admin), params: { url: 'http://mep.mep' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['enable_ssl_verification']).to be true expect(json_response['enable_ssl_verification']).to be true
expect(json_response['push_events']).to be false expect(json_response['push_events']).to be false
expect(json_response['tag_push_events']).to be false expect(json_response['tag_push_events']).to be false
...@@ -95,7 +95,7 @@ describe API::SystemHooks do ...@@ -95,7 +95,7 @@ describe API::SystemHooks do
merge_requests_events: true merge_requests_events: true
} }
expect(response).to have_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['enable_ssl_verification']).to be false expect(json_response['enable_ssl_verification']).to be false
expect(json_response['push_events']).to be true expect(json_response['push_events']).to be true
expect(json_response['tag_push_events']).to be true expect(json_response['tag_push_events']).to be true
...@@ -106,13 +106,13 @@ describe API::SystemHooks do ...@@ -106,13 +106,13 @@ describe API::SystemHooks do
describe "GET /hooks/:id" do describe "GET /hooks/:id" do
it "returns hook by id" do it "returns hook by id" do
get api("/hooks/#{hook.id}", admin) get api("/hooks/#{hook.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['event_name']).to eq('project_create') expect(json_response['event_name']).to eq('project_create')
end end
it "returns 404 on failure" do it "returns 404 on failure" do
get api("/hooks/404", admin) get api("/hooks/404", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -121,14 +121,14 @@ describe API::SystemHooks do ...@@ -121,14 +121,14 @@ describe API::SystemHooks do
expect do expect do
delete api("/hooks/#{hook.id}", admin) delete api("/hooks/#{hook.id}", admin)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change { SystemHook.count }.by(-1) end.to change { SystemHook.count }.by(-1)
end end
it 'returns 404 if the system hook does not exist' do it 'returns 404 if the system hook does not exist' do
delete api('/hooks/12345', admin) delete api('/hooks/12345', admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
......
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