Commit 69621aab authored by Nick Thomas's avatar Nick Thomas

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

Add http status cop to api specs a-s

See merge request gitlab-org/gitlab!25177
parents 4c9ab1ac f4e1b246
......@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-p]*.rb'
- 'ee/spec/requests/api/[a-p]*.rb'
- 'spec/requests/api/[a-s]*.rb'
- 'ee/spec/requests/api/[a-s]*.rb'
Style/MultilineWhenThen:
Enabled: false
......
......@@ -43,7 +43,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
expect(build).to be_running
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(
"id" => build.id,
"variables" => include("key" => 'KEY', "value" => 'value', "public" => true, "masked" => false),
......@@ -60,7 +60,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
build.reload
expect(build).to be_pending
expect(response).to have_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
end
......
......@@ -19,14 +19,14 @@ describe API::Scim do
it 'responds with 401' do
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
it 'responds with paginated users when there is no filter' do
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['totalResults']).to eq(Identity.count)
end
......@@ -34,14 +34,14 @@ describe API::Scim 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}\"")
expect(response).to have_gitlab_http_status(412)
expect(response).to have_gitlab_http_status(:precondition_failed)
end
context 'existing user matches filter' do
it 'responds with 200' do
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['totalResults']).to eq(1)
end
......@@ -59,7 +59,7 @@ describe API::Scim do
it 'responds with 200' do
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['totalResults']).to eq(0)
end
......@@ -70,14 +70,14 @@ describe API::Scim do
it 'responds with 404 if there is no user' do
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
context 'existing user' do
it 'responds with 200' do
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)
end
end
......@@ -105,7 +105,7 @@ describe API::Scim do
end
it 'responds with 201' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'has the user external ID' do
......@@ -167,7 +167,7 @@ describe API::Scim do
end
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")
end
end
......@@ -200,7 +200,7 @@ describe API::Scim do
end
it 'responds with 201' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'has the user external ID' do
......@@ -213,7 +213,7 @@ describe API::Scim do
it 'responds with 404 if there is no user' do
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
context 'existing user' do
......@@ -225,7 +225,7 @@ describe API::Scim do
end
it 'responds with 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'updates the extern_uid' do
......@@ -241,7 +241,7 @@ describe API::Scim do
end
it 'responds with 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'updates the name' do
......@@ -266,7 +266,7 @@ describe API::Scim do
end
it 'responds with 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
......@@ -284,7 +284,7 @@ describe API::Scim do
end
it 'responds with 209' do
expect(response).to have_gitlab_http_status(409)
expect(response).to have_gitlab_http_status(:conflict)
end
end
end
......@@ -297,7 +297,7 @@ describe API::Scim do
end
it 'responds with 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'removes the identity link' do
......@@ -314,7 +314,7 @@ describe API::Scim do
end
it 'responds with 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'removes the identity link' do
......@@ -329,7 +329,7 @@ describe API::Scim do
it 'responds with 404 if there is no user' do
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
......
......@@ -21,7 +21,7 @@ describe API::Services do
it 'returns status 200' do
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")
end
end
......
......@@ -23,7 +23,7 @@ describe API::Settings, 'EE Settings' do
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['file_template_project_id']).to eq(project.id)
end
......@@ -40,7 +40,7 @@ describe API::Settings, 'EE Settings' do
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_project_ids']).to eq(project_ids)
expect(json_response['elasticsearch_namespace_ids']).to eq(namespace_ids)
......@@ -61,7 +61,7 @@ describe API::Settings, 'EE Settings' do
'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(ElasticsearchIndexedNamespace.count).to eq(0)
expect(ElasticsearchIndexedProject.count).to eq(1)
......@@ -85,7 +85,7 @@ describe API::Settings, 'EE Settings' do
it 'hides the attributes in the API' do
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|
expect(json_response.keys).not_to include(attribute)
end
......@@ -105,7 +105,7 @@ describe API::Settings, 'EE Settings' do
it 'includes the attributes in the API' do
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|
expect(json_response.keys).to include(attribute)
end
......@@ -113,7 +113,7 @@ describe API::Settings, 'EE Settings' do
it 'allows updating the settings' do
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|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
......
......@@ -19,7 +19,7 @@ describe API::Repositories do
it 'returns the repository tree' do
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(json_response).to be_an Array
......@@ -108,7 +108,7 @@ describe API::Repositories do
it 'returns blob attributes as json' do
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['encoding']).to eq("base64")
expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n")
......@@ -167,7 +167,7 @@ describe API::Repositories do
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"
end
......@@ -231,7 +231,7 @@ describe API::Repositories do
it 'returns the repository archive' do
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
......@@ -242,7 +242,7 @@ describe API::Repositories do
it 'returns the repository archive archive.zip' do
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
......@@ -253,7 +253,7 @@ describe API::Repositories do
it 'returns the repository archive archive.tar.bz2' do
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
......@@ -314,7 +314,7 @@ describe API::Repositories do
}).and_call_original
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['diffs']).to be_present
end
......@@ -325,7 +325,7 @@ describe API::Repositories do
}).and_call_original
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['diffs']).to be_present
end
......@@ -336,7 +336,7 @@ describe API::Repositories do
}).and_call_original
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['diffs']).to be_present
end
......@@ -344,7 +344,7 @@ describe API::Repositories do
it "compares tags" do
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['diffs']).to be_present
end
......@@ -352,7 +352,7 @@ describe API::Repositories do
it "compares commits" do
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['diffs']).to be_empty
expect(json_response['compare_same_ref']).to be_falsey
......@@ -361,7 +361,7 @@ describe API::Repositories do
it "compares commits in reverse order" do
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['diffs']).to be_present
end
......@@ -369,7 +369,7 @@ describe API::Repositories do
it "compares same refs" do
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['diffs']).to be_empty
expect(json_response['compare_same_ref']).to be_truthy
......@@ -380,7 +380,7 @@ describe API::Repositories do
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['diffs']).to be_present
expect(json_response['diffs'].first['diff']).to be_empty
......@@ -389,13 +389,13 @@ describe API::Repositories do
it "returns a 404 when from ref is unknown" do
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
it "returns a 404 when to ref is unknown" do
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
......@@ -433,7 +433,7 @@ describe API::Repositories do
it 'returns valid data' do
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(json_response).to be_an Array
......@@ -450,7 +450,7 @@ describe API::Repositories do
it 'returns the repository contribuors sorted by commits desc' do
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(json_response.first['commits']).to be > json_response.last['commits']
end
......@@ -460,7 +460,7 @@ describe API::Repositories do
it 'returns the repository contribuors sorted by name asc case insensitive' do
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(json_response.first['name'].downcase).to be < json_response.last['name'].downcase
end
......
This diff is collapsed.
This diff is collapsed.
......@@ -9,7 +9,7 @@ describe API::Search do
let_it_be(:repo_project) { create(:project, :public, :repository, group: group) }
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 include_limited_pagination_headers }
it { expect(json_response.size).to eq(size) }
......@@ -20,7 +20,7 @@ describe API::Search do
it 'returns 401 error' do
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
......@@ -28,7 +28,7 @@ describe API::Search do
it 'returns 400 error' do
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
......@@ -36,7 +36,7 @@ describe API::Search do
it 'returns 400 error' do
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
......@@ -115,7 +115,7 @@ describe API::Search do
end
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
......@@ -147,7 +147,7 @@ describe API::Search do
it 'returns 401 error' do
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
......@@ -155,7 +155,7 @@ describe API::Search do
it 'returns 400 error' do
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
......@@ -163,7 +163,7 @@ describe API::Search do
it 'returns 400 error' do
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
......@@ -171,7 +171,7 @@ describe API::Search do
it 'returns 404 error' do
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
......@@ -181,7 +181,7 @@ describe API::Search do
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
......@@ -254,7 +254,7 @@ describe API::Search do
end
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
......@@ -277,7 +277,7 @@ describe API::Search do
it 'returns 401 error' do
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
......@@ -285,7 +285,7 @@ describe API::Search do
it 'returns 400 error' do
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
......@@ -293,7 +293,7 @@ describe API::Search do
it 'returns 400 error' do
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
......@@ -301,7 +301,7 @@ describe API::Search do
it 'returns 404 error' do
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
......@@ -311,7 +311,7 @@ describe API::Search do
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
......@@ -383,7 +383,7 @@ describe API::Search do
end
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
......@@ -436,7 +436,7 @@ describe API::Search do
it 'by filename' do
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.first['path']).to eq('PROCESS.md')
expect(json_response.first['filename']).to eq('PROCESS.md')
......@@ -445,21 +445,21 @@ describe API::Search do
it 'by path' do
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)
end
it 'by extension' do
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)
end
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' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
end
end
......
......@@ -14,14 +14,14 @@ describe API::Services do
it 'returns authentication error when unauthenticated' do
get api("/projects/#{project.id}/services")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it "returns error when authenticated but user is not a project owner" do
project.add_developer(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
context 'project with services' do
......@@ -32,7 +32,7 @@ describe API::Services do
get api("/projects/#{project.id}/services", user)
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.count).to eq(1)
expect(json_response.first['slug']).to eq('emails-on-push')
......@@ -49,7 +49,7 @@ describe API::Services do
it "updates #{service} settings" do
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
events = current_service.event_names.empty? ? ["foo"].freeze : current_service.event_names
......@@ -61,7 +61,7 @@ describe API::Services do
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)
events.each do |event|
next if event == "foo"
......@@ -103,7 +103,7 @@ describe API::Services do
it "deletes #{service}" do
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
expect(project.send(service_method).activated?).to be_falsey
end
......@@ -117,13 +117,13 @@ describe API::Services do
it 'returns authentication error when unauthenticated' do
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
it "returns all properties of service #{service}" do
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)
end
......@@ -131,7 +131,7 @@ describe API::Services do
project.add_developer(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
......@@ -144,7 +144,7 @@ describe API::Services do
it 'returns a not found message' do
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")
end
end
......@@ -163,7 +163,7 @@ describe API::Services do
it 'when the service is inactive' do
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
......@@ -178,7 +178,7 @@ describe API::Services do
it 'returns status 200' do
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
......@@ -186,7 +186,7 @@ describe API::Services do
it 'returns a generic 404' do
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")
end
end
......@@ -206,7 +206,7 @@ describe API::Services do
it 'returns status 200' do
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")
end
end
......@@ -228,7 +228,7 @@ describe API::Services do
it 'accepts a username for update' do
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')
end
end
......@@ -253,14 +253,14 @@ describe API::Services 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')
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')
end
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)
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)
end
end
......
......@@ -11,7 +11,7 @@ describe API::Settings, 'Settings' do
it "returns application settings" do
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['default_projects_limit']).to eq(42)
expect(json_response['password_authentication_enabled_for_web']).to be_truthy
......@@ -91,7 +91,7 @@ describe API::Settings, 'Settings' do
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_projects_limit']).to eq(3)
expect(json_response['default_project_creation']).to eq(::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS)
......@@ -132,7 +132,7 @@ describe API::Settings, 'Settings' do
put api("/application/settings", admin),
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)
end
......@@ -143,7 +143,7 @@ describe API::Settings, 'Settings' do
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
end
......@@ -151,7 +151,7 @@ describe API::Settings, 'Settings' do
put api("/application/settings", admin),
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)
end
......@@ -173,7 +173,7 @@ describe API::Settings, 'Settings' do
it 'includes the attributes in the API' do
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|
expect(json_response.keys).to include(attribute)
end
......@@ -182,7 +182,7 @@ describe API::Settings, 'Settings' do
it 'allows updating the settings' do
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|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
end
......@@ -205,7 +205,7 @@ describe API::Settings, 'Settings' do
it "includes the attributes in the API" do
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|
expect(json_response.keys).to include(attribute)
end
......@@ -214,7 +214,7 @@ describe API::Settings, 'Settings' do
it "allows updating the settings" do
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|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
end
......@@ -224,7 +224,7 @@ describe API::Settings, 'Settings' do
it "returns a blank parameter error message" do
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")
end
......@@ -233,7 +233,7 @@ describe API::Settings, 'Settings' do
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"]
expect(message["snowplow_collector_hostname"]).to include("can't be blank")
end
......@@ -257,7 +257,7 @@ describe API::Settings, 'Settings' do
it 'includes attributes in the API' do
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|
expect(json_response.keys).to include(attribute)
end
......@@ -266,7 +266,7 @@ describe API::Settings, 'Settings' do
it 'does not include sensitive attributes in the API' do
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|
expect(json_response.keys).not_to include(attribute)
end
......@@ -275,7 +275,7 @@ describe API::Settings, 'Settings' do
it 'allows updating the settings' do
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|
expect(ApplicationSetting.current.public_send(attribute)).to eq(value)
end
......@@ -287,7 +287,7 @@ describe API::Settings, 'Settings' do
it 'does not update the settings' do
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_access_key_id is missing')
expect(json_response['error']).to include('eks_secret_access_key is missing')
......@@ -299,7 +299,7 @@ describe API::Settings, 'Settings' do
it "returns a blank parameter error message" do
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')
end
end
......@@ -314,7 +314,7 @@ describe API::Settings, 'Settings' do
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_url']).to eq('http://assets.example.com')
expect(json_response['asset_proxy_secret_key']).to be_nil
......@@ -327,7 +327,7 @@ describe API::Settings, 'Settings' do
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'])
end
end
......@@ -340,7 +340,7 @@ describe API::Settings, 'Settings' do
domain_blacklist: []
}
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
message = json_response["message"]
expect(message["domain_blacklist"]).to eq(["Domain blacklist cannot be empty if Blacklist is enabled."])
end
......@@ -352,7 +352,7 @@ describe API::Settings, 'Settings' do
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']).to eq(['domain1.com', 'domain2.com'])
end
......@@ -364,7 +364,7 @@ describe API::Settings, 'Settings' do
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']).to eq(['domain3.com', '*.domain4.com'])
end
......@@ -374,7 +374,7 @@ describe API::Settings, 'Settings' do
it "returns a blank parameter error message" do
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')
end
end
......
......@@ -9,21 +9,21 @@ describe API::SidekiqMetrics do
it 'defines the `queue_metrics` endpoint' do
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
end
it 'defines the `process_metrics` endpoint' do
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
end
it 'defines the `job_stats` endpoint' do
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['jobs']).to be_a Hash
expect(json_response['jobs'].keys)
......@@ -34,7 +34,7 @@ describe API::SidekiqMetrics do
it 'defines the `compound_metrics` endpoint' do
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['queues']).to be_a Hash
expect(json_response['processes']).to be_an Array
......
......@@ -13,7 +13,7 @@ describe API::Snippets do
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(json_response).to be_an Array
expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
......@@ -30,7 +30,7 @@ describe API::Snippets do
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(json_response).to be_an Array
expect(json_response.size).to eq(0)
......@@ -41,7 +41,7 @@ describe API::Snippets do
get api("/snippets/")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'does not return snippets related to a project with disable feature visibility' do
......@@ -73,7 +73,7 @@ describe API::Snippets do
it 'returns all snippets with public visibility from all users' do
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(json_response).to be_an Array
expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
......@@ -95,13 +95,13 @@ describe API::Snippets do
it 'requires authentication' do
get api("/snippets/#{snippet.id}", nil)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns raw text' do
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.body).to eq(snippet.content)
end
......@@ -117,14 +117,14 @@ describe API::Snippets do
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')
end
it 'hides private snippets from ordinary users' do
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
it 'shows internal snippets to ordinary users' do
......@@ -132,7 +132,7 @@ describe API::Snippets do
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
......@@ -145,13 +145,13 @@ describe API::Snippets do
it 'requires authentication' do
get api("/snippets/#{private_snippet.id}", nil)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns snippet json' do
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['description']).to eq(private_snippet.description)
......@@ -162,19 +162,19 @@ describe API::Snippets do
it 'shows private snippets to an admin' do
get api("/snippets/#{private_snippet.id}", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'hides private snippets from an ordinary user' do
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
it 'shows internal snippets to an ordinary user' do
get api("/snippets/#{internal_snippet.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns 404 for invalid snippet id' do
......@@ -182,7 +182,7 @@ describe API::Snippets do
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')
end
end
......@@ -208,7 +208,7 @@ describe API::Snippets do
subject
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['description']).to eq(params[:description])
expect(json_response['file_name']).to eq(params[:file_name])
......@@ -259,7 +259,7 @@ describe API::Snippets do
post api("/snippets/", user), params: params
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
context 'when the snippet is spam' do
......@@ -285,7 +285,7 @@ describe API::Snippets do
expect { create_snippet(visibility: 'public') }
.not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" })
end
......@@ -311,7 +311,7 @@ describe API::Snippets do
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
expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description)
......@@ -334,21 +334,21 @@ describe API::Snippets do
it 'returns 404 for invalid snippet id' do
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')
end
it "returns 404 for another user's snippet" do
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')
end
it 'returns 400 for missing parameters' do
put api("/snippets/1234", user)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
context 'when the snippet is spam' do
......@@ -378,7 +378,7 @@ describe API::Snippets do
expect { update_snippet(title: 'Foo') }
.not_to change { snippet.reload.title }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" })
end
......@@ -410,14 +410,14 @@ describe API::Snippets do
expect do
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
it 'returns 404 for invalid snippet id' do
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')
end
......@@ -434,7 +434,7 @@ describe API::Snippets do
it 'exposes known attributes' do
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['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
......@@ -443,7 +443,7 @@ describe API::Snippets do
it "returns unauthorized for non-admin users" do
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
......@@ -25,7 +25,7 @@ describe API::Statistics, 'Statistics' do
it "returns authentication error" do
get api(path, nil)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -35,7 +35,7 @@ describe API::Statistics, 'Statistics' do
it "returns forbidden error" do
get api(path, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -45,7 +45,7 @@ describe API::Statistics, 'Statistics' do
it 'matches the response schema' do
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')
end
......
......@@ -33,7 +33,7 @@ describe API::Submodules do
it 'returns 401' do
put api(route(submodule)), params: params
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -41,7 +41,7 @@ describe API::Submodules do
it 'returns 403' do
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
......@@ -49,19 +49,19 @@ describe API::Submodules do
it 'returns 400 if params is missing' do
put api(route(submodule), user)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 if branch is missing' do
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
it 'returns 400 if commit_sha is missing' do
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
it 'returns the commit' do
......@@ -69,7 +69,7 @@ describe API::Submodules do
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['author_name']).to eq user.name
expect(json_response['committer_name']).to eq user.name
......@@ -89,7 +89,7 @@ describe API::Submodules do
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(project.repository.blob_at(branch, submodule).id).to eq commit_sha
end
......
......@@ -40,7 +40,7 @@ describe API::Suggestions do
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)
.to include('id', 'from_line', 'to_line', 'appliable', 'applied',
'from_content', 'to_content')
......@@ -57,7 +57,7 @@ describe API::Suggestions do
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' })
end
end
......@@ -74,7 +74,7 @@ describe API::Suggestions do
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' })
end
end
......
......@@ -18,7 +18,7 @@ describe API::SystemHooks do
it "returns authentication error" do
get api("/hooks")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -26,7 +26,7 @@ describe API::SystemHooks do
it "returns forbidden error" do
get api("/hooks", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -34,7 +34,7 @@ describe API::SystemHooks do
it "returns an array of hooks" do
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(json_response).to be_an Array
expect(json_response.first['url']).to eq(hook.url)
......@@ -56,13 +56,13 @@ describe API::SystemHooks do
it "responds with 400 if url not given" do
post api("/hooks", admin)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it "responds with 400 if url is invalid" do
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
it "does not create new hook without url" do
......@@ -76,7 +76,7 @@ describe API::SystemHooks do
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['push_events']).to be false
expect(json_response['tag_push_events']).to be false
......@@ -95,7 +95,7 @@ describe API::SystemHooks do
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['push_events']).to be true
expect(json_response['tag_push_events']).to be true
......@@ -106,13 +106,13 @@ describe API::SystemHooks do
describe "GET /hooks/:id" do
it "returns hook by id" do
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')
end
it "returns 404 on failure" do
get api("/hooks/404", admin)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -121,14 +121,14 @@ describe API::SystemHooks do
expect do
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
it 'returns 404 if the system hook does not exist' do
delete api('/hooks/12345', admin)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it_behaves_like '412 response' do
......
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