summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/api_guard/admin_mode_middleware_spec.rb2
-rw-r--r--spec/requests/api/avatar_spec.rb10
-rw-r--r--spec/requests/api/commit_statuses_spec.rb2
-rw-r--r--spec/requests/api/container_registry_event_spec.rb4
-rw-r--r--spec/requests/api/deploy_keys_spec.rb6
-rw-r--r--spec/requests/api/group_labels_spec.rb2
-rw-r--r--spec/requests/api/internal/base_spec.rb14
-rw-r--r--spec/requests/api/issues/post_projects_issues_spec.rb4
-rw-r--r--spec/requests/api/labels_spec.rb12
-rw-r--r--spec/requests/api/merge_request_diffs_spec.rb4
-rw-r--r--spec/requests/api/merge_requests_spec.rb14
-rw-r--r--spec/requests/api/notes_spec.rb2
-rw-r--r--spec/requests/api/projects_spec.rb14
-rw-r--r--spec/requests/api/repositories_spec.rb2
-rw-r--r--spec/requests/api/runner_spec.rb32
-rw-r--r--spec/requests/api/services_spec.rb6
-rw-r--r--spec/requests/api/user_counts_spec.rb6
-rw-r--r--spec/requests/api/users_spec.rb2
-rw-r--r--spec/requests/health_controller_spec.rb8
-rw-r--r--spec/requests/projects/merge_requests_discussions_spec.rb2
20 files changed, 74 insertions, 74 deletions
diff --git a/spec/requests/api/api_guard/admin_mode_middleware_spec.rb b/spec/requests/api/api_guard/admin_mode_middleware_spec.rb
index 8973afe6570..7175076e56d 100644
--- a/spec/requests/api/api_guard/admin_mode_middleware_spec.rb
+++ b/spec/requests/api/api_guard/admin_mode_middleware_spec.rb
@@ -26,7 +26,7 @@ describe API::APIGuard::AdminModeMiddleware, :do_not_mock_admin_mode, :request_s
get api('/willfail')
- expect(response.status).to eq(500)
+ expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.body).to include('oh noes!')
expect(Gitlab::Auth::CurrentUserMode.bypass_session_admin_id).to be_nil
diff --git a/spec/requests/api/avatar_spec.rb b/spec/requests/api/avatar_spec.rb
index c8bc7f8a4a2..45e34b7894b 100644
--- a/spec/requests/api/avatar_spec.rb
+++ b/spec/requests/api/avatar_spec.rb
@@ -17,7 +17,7 @@ describe API::Avatar do
it 'returns the avatar url' do
get api('/avatar'), params: { email: 'public@example.com' }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}")
end
end
@@ -34,7 +34,7 @@ describe API::Avatar do
it 'returns the avatar url from Gravatar' do
get api('/avatar'), params: { email: 'private@example.com' }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to eq('https://gravatar')
end
end
@@ -57,7 +57,7 @@ describe API::Avatar do
it 'returns the avatar url from Gravatar' do
get api('/avatar'), params: { email: 'public@example.com' }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to eq('https://gravatar')
end
end
@@ -74,7 +74,7 @@ describe API::Avatar do
it 'returns the avatar url from Gravatar' do
get api('/avatar'), params: { email: 'private@example.com' }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to eq('https://gravatar')
end
end
@@ -92,7 +92,7 @@ describe API::Avatar do
it 'returns the avatar url' do
get api('/avatar', user), params: { email: 'public@example.com' }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}")
end
end
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 6b810cf2d89..0c0bf8b4df0 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -96,7 +96,7 @@ describe API::CommitStatuses do
end
it 'returns empty array' do
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response).to be_empty
end
diff --git a/spec/requests/api/container_registry_event_spec.rb b/spec/requests/api/container_registry_event_spec.rb
index 9c144f80fd4..2cdf2656cb7 100644
--- a/spec/requests/api/container_registry_event_spec.rb
+++ b/spec/requests/api/container_registry_event_spec.rb
@@ -27,7 +27,7 @@ describe API::ContainerRegistryEvent do
expect(event).to have_received(:handle!).once
expect(event).to have_received(:track!).once
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns 401 error status when token is invalid' do
@@ -35,7 +35,7 @@ describe API::ContainerRegistryEvent do
params: { events: events }.to_json,
headers: registry_headers.merge('Authorization' => 'invalid_token')
- expect(response.status).to eq 401
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb
index 9092d132b53..e8cc6bc71ae 100644
--- a/spec/requests/api/deploy_keys_spec.rb
+++ b/spec/requests/api/deploy_keys_spec.rb
@@ -19,7 +19,7 @@ describe API::DeployKeys do
it 'returns authentication error' do
get api('/deploy_keys')
- expect(response.status).to eq(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -27,7 +27,7 @@ describe API::DeployKeys do
it 'returns a 403 error' do
get api('/deploy_keys', user)
- expect(response.status).to eq(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -35,7 +35,7 @@ describe API::DeployKeys do
it 'returns all deploy keys' do
get api('/deploy_keys', admin)
- expect(response.status).to eq(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['id']).to eq(deploy_keys_project.deploy_key.id)
diff --git a/spec/requests/api/group_labels_spec.rb b/spec/requests/api/group_labels_spec.rb
index dea26ec7274..231a055f73c 100644
--- a/spec/requests/api/group_labels_spec.rb
+++ b/spec/requests/api/group_labels_spec.rb
@@ -98,7 +98,7 @@ describe API::GroupLabels do
color: '#FFAABB'
}
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq('Foo & Bar')
expect(json_response['color']).to eq('#FFAABB')
expect(json_response['description']).to be_nil
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb
index 77501c3a136..06ba0bd30ff 100644
--- a/spec/requests/api/internal/base_spec.rb
+++ b/spec/requests/api/internal/base_spec.rb
@@ -217,7 +217,7 @@ describe API::Internal::Base do
it "finds the key" do
get(api('/internal/authorized_keys'), params: { fingerprint: key.fingerprint, secret_token: secret_token })
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response["key"]).to eq(key.key)
end
end
@@ -226,7 +226,7 @@ describe API::Internal::Base do
it "returns 404" do
get(api('/internal/authorized_keys'), params: { fingerprint: "no:t-:va:li:d0", secret_token: secret_token })
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -234,7 +234,7 @@ describe API::Internal::Base do
it "returns 404" do
get(api('/internal/authorized_keys'), params: { fingerprint: "#{key.fingerprint[0..5]}%", secret_token: secret_token })
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -242,20 +242,20 @@ describe API::Internal::Base do
it "finds the key" do
get(api('/internal/authorized_keys'), params: { key: key.key.split[1], secret_token: secret_token })
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response["key"]).to eq(key.key)
end
it "returns 404 with a partial key" do
get(api('/internal/authorized_keys'), params: { key: key.key.split[1][0...-3], secret_token: secret_token })
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it "returns 404 with an not valid base64 string" do
get(api('/internal/authorized_keys'), params: { key: "whatever!", secret_token: secret_token })
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@@ -812,7 +812,7 @@ describe API::Internal::Base do
project.add_developer(user)
push(key, project, 'web')
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to be_truthy
end
end
diff --git a/spec/requests/api/issues/post_projects_issues_spec.rb b/spec/requests/api/issues/post_projects_issues_spec.rb
index 0ec13eb2b31..5b8d45d9465 100644
--- a/spec/requests/api/issues/post_projects_issues_spec.rb
+++ b/spec/requests/api/issues/post_projects_issues_spec.rb
@@ -244,7 +244,7 @@ describe API::Issues do
title: 'new issue',
labels: 'label, label?, label&foo, ?, &'
}
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['labels']).to include 'label'
expect(json_response['labels']).to include 'label?'
expect(json_response['labels']).to include 'label&foo'
@@ -258,7 +258,7 @@ describe API::Issues do
title: 'new issue',
labels: ['label', 'label?', 'label&foo, ?, &']
}
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['labels']).to include 'label'
expect(json_response['labels']).to include 'label?'
expect(json_response['labels']).to include 'label&foo'
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb
index f8216da3419..19d4e8cef20 100644
--- a/spec/requests/api/labels_spec.rb
+++ b/spec/requests/api/labels_spec.rb
@@ -43,7 +43,7 @@ describe API::Labels do
it "returns 200 if a priority is added (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, priority: 3)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(label1.name)
expect(json_response['priority']).to eq(3)
end
@@ -103,7 +103,7 @@ describe API::Labels do
it "returns 200 if priority is changed (#{route_type} route)" do
put_labels_api(route_type, user, spec_params, priority: 10)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(expected_response_label_id)
expect(json_response['priority']).to eq(10)
end
@@ -124,7 +124,7 @@ describe API::Labels do
put api("/projects/#{project.id}/labels", user),
params: request_params
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(expected_response_label_id)
expect(json_response['priority']).to be_nil
end
@@ -144,7 +144,7 @@ describe API::Labels do
put api("/projects/#{project.id}/labels/#{label_id}", user),
params: request_params
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(expected_response_label_id)
expect(json_response['priority']).to be_nil
end
@@ -321,7 +321,7 @@ describe API::Labels do
color: '#FFAABB'
}
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq('Foo & Bar')
expect(json_response['color']).to eq('#FFAABB')
expect(json_response['description']).to be_nil
@@ -336,7 +336,7 @@ describe API::Labels do
priority: 3
}
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq('Foo & Bar')
expect(json_response['color']).to eq('#FFAABB')
expect(json_response['description']).to be_nil
diff --git a/spec/requests/api/merge_request_diffs_spec.rb b/spec/requests/api/merge_request_diffs_spec.rb
index 2e74022ae07..90b6f39cc90 100644
--- a/spec/requests/api/merge_request_diffs_spec.rb
+++ b/spec/requests/api/merge_request_diffs_spec.rb
@@ -18,7 +18,7 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions", user)
merge_request_diff = merge_request.merge_request_diffs.last
- expect(response.status).to eq 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(merge_request.merge_request_diffs.size)
@@ -43,7 +43,7 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
it 'returns a 200 for a valid merge request' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions/#{merge_request_diff.id}", user)
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(merge_request_diff.id)
expect(json_response['head_commit_sha']).to eq(merge_request_diff.head_commit_sha)
expect(json_response['diffs'].size).to eq(merge_request_diff.diffs.size)
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index ab7149a6bb3..5440e187ba9 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -2164,7 +2164,7 @@ describe API::MergeRequests do
labels: 'label, label?, label&foo, ?, &'
}
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'label'
expect(json_response['labels']).to include 'label?'
expect(json_response['labels']).to include 'label&foo'
@@ -2179,7 +2179,7 @@ describe API::MergeRequests do
labels: ['label', 'label?', 'label&foo, ?, &', '1, 2', 3, 4]
}
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'label'
expect(json_response['labels']).to include 'label?'
expect(json_response['labels']).to include 'label&foo'
@@ -2198,7 +2198,7 @@ describe API::MergeRequests do
labels: ''
}
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to eq []
end
@@ -2210,7 +2210,7 @@ describe API::MergeRequests do
}.to_json,
headers: { 'Content-Type' => 'application/json' }
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to eq []
end
@@ -2221,7 +2221,7 @@ describe API::MergeRequests do
labels: []
}
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to eq []
end
@@ -2232,7 +2232,7 @@ describe API::MergeRequests do
labels: ['']
}
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to eq []
end
@@ -2243,7 +2243,7 @@ describe API::MergeRequests do
labels: ['', '', '']
}
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to eq []
end
end
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index 3fb14eb9d5a..797dd3bb4e2 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -41,7 +41,7 @@ describe API::Notes do
end
it 'responds with resource not found error' do
- expect(response.status).to eq 404
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not create new note' do
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index c4f4801e372..a50b2b7aca8 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -190,7 +190,7 @@ describe API::Projects do
it 'includes the project labels as the tag_list' do
get api('/projects', user)
- expect(response.status).to eq 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.keys).to include('tag_list')
@@ -199,7 +199,7 @@ describe API::Projects do
it 'includes open_issues_count' do
get api('/projects', user)
- expect(response.status).to eq 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.keys).to include('open_issues_count')
@@ -220,7 +220,7 @@ describe API::Projects do
get api('/projects', user)
- expect(response.status).to eq 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.find { |hash| hash['id'] == project.id }.keys).not_to include('open_issues_count')
@@ -232,7 +232,7 @@ describe API::Projects do
get api('/projects?with_issues_enabled=true', user)
- expect(response.status).to eq 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 { |p| p['id'] }).not_to include(project.id)
@@ -281,7 +281,7 @@ describe API::Projects do
it 'includes open_issues_count' do
get api('/projects', user)
- expect(response.status).to eq 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.keys).to include('open_issues_count')
@@ -293,7 +293,7 @@ describe API::Projects do
get api('/projects', user)
- expect(response.status).to eq 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.find { |hash| hash['id'] == project.id }.keys).not_to include('open_issues_count')
@@ -568,7 +568,7 @@ describe API::Projects do
get api('/projects?with_issues_enabled=true', user2)
- expect(response.status).to eq 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 { |p| p['id'] }).not_to include(project.id)
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index b503c923037..a96bc68ace9 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -48,7 +48,7 @@ describe API::Repositories do
it 'returns recursive project paths tree' do
get api("#{route}?recursive=1", current_user)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(response).to include_pagination_headers
expect(json_response[4]['name']).to eq('html')
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index 03560cae775..d05d886bf85 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -1102,7 +1102,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'returns that operation conflicts' do
- expect(response.status).to eq(409)
+ expect(response).to have_gitlab_http_status(:conflict)
end
end
end
@@ -1185,7 +1185,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
context 'when request is valid' do
it 'gets correct response' do
- expect(response.status).to eq 202
+ expect(response).to have_gitlab_http_status(:accepted)
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended'
expect(response.header).to have_key 'Range'
expect(response.header).to have_key 'Job-Status'
@@ -1242,7 +1242,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'responds with forbidden' do
- expect(response.status).to eq(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -1252,7 +1252,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'has valid trace' do
- expect(response.status).to eq(202)
+ expect(response).to have_gitlab_http_status(:accepted)
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended'
end
@@ -1267,7 +1267,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'returns Forbidden ' do
- expect(response.status).to eq(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -1287,7 +1287,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'returns an error' do
- expect(response.status).to eq(416)
+ expect(response).to have_gitlab_http_status(:range_not_satisfiable)
expect(response.header['Range']).to eq('0-0')
end
end
@@ -1298,7 +1298,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'succeeds with updating trace' do
- expect(response.status).to eq(202)
+ expect(response).to have_gitlab_http_status(:accepted)
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended hello'
end
end
@@ -1313,7 +1313,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'returns that operation conflicts' do
- expect(response.status).to eq(409)
+ expect(response).to have_gitlab_http_status(:conflict)
end
end
@@ -1336,7 +1336,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns X-GitLab-Trace-Update-Interval as 3' do
patch_the_trace
- expect(response.status).to eq 202
+ expect(response).to have_gitlab_http_status(:accepted)
expect(response.header['X-GitLab-Trace-Update-Interval']).to eq('3')
end
end
@@ -1345,7 +1345,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'returns X-GitLab-Trace-Update-Interval as 30' do
patch_the_trace
- expect(response.status).to eq 202
+ expect(response).to have_gitlab_http_status(:accepted)
expect(response.header['X-GitLab-Trace-Update-Interval']).to eq('30')
end
end
@@ -1358,7 +1358,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it 'does not return X-GitLab-Trace-Update-Interval header' do
patch_the_trace
- expect(response.status).to eq 202
+ expect(response).to have_gitlab_http_status(:accepted)
expect(response.header).not_to have_key 'X-GitLab-Trace-Update-Interval'
end
end
@@ -1370,7 +1370,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it 'gets correct response' do
- expect(response.status).to eq 202
+ expect(response).to have_gitlab_http_status(:accepted)
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended'
expect(response.header).to have_key 'Range'
expect(response.header).to have_key 'Job-Status'
@@ -1381,7 +1381,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:headers_with_range) { headers.merge({ 'Content-Range' => '15-20/6' }) }
it 'gets 416 error response with range headers' do
- expect(response.status).to eq 416
+ expect(response).to have_gitlab_http_status(:range_not_satisfiable)
expect(response.header).to have_key 'Range'
expect(response.header['Range']).to eq '0-11'
end
@@ -1391,7 +1391,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:headers_with_range) { headers.merge({ 'Content-Range' => '8-20/13' }) }
it 'gets 416 error response with range headers' do
- expect(response.status).to eq 416
+ expect(response).to have_gitlab_http_status(:range_not_satisfiable)
expect(response.header).to have_key 'Range'
expect(response.header['Range']).to eq '0-11'
end
@@ -1400,13 +1400,13 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
context 'when Content-Range header is missing' do
let(:headers_with_range) { headers }
- it { expect(response.status).to eq 400 }
+ it { expect(response).to have_gitlab_http_status(:bad_request) }
end
context 'when job has been errased' do
let(:job) { create(:ci_build, runner_id: runner.id, erased_at: Time.now) }
- it { expect(response.status).to eq 403 }
+ it { expect(response).to have_gitlab_http_status(:forbidden) }
end
def patch_the_trace(content = ' appended', request_headers = nil)
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index 906ffce25bf..53265574e6a 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -81,15 +81,15 @@ describe API::Services do
end
if required_attributes.empty?
- expected_code = 200
+ expected_code = :ok
else
attrs.delete(required_attributes.sample)
- expected_code = 400
+ expected_code = :bad_request
end
put api("/projects/#{project.id}/services/#{dashed_service}", user), params: attrs
- expect(response.status).to eq(expected_code)
+ expect(response).to have_gitlab_http_status(expected_code)
end
end
diff --git a/spec/requests/api/user_counts_spec.rb b/spec/requests/api/user_counts_spec.rb
index c833bd047e2..688dfe11115 100644
--- a/spec/requests/api/user_counts_spec.rb
+++ b/spec/requests/api/user_counts_spec.rb
@@ -13,7 +13,7 @@ describe API::UserCounts do
it 'returns authentication error' do
get api('/user_counts')
- expect(response.status).to eq(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -21,7 +21,7 @@ describe API::UserCounts do
it 'returns open counts for current user' do
get api('/user_counts', user)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash
expect(json_response['merge_requests']).to eq(1)
end
@@ -31,7 +31,7 @@ describe API::UserCounts do
get api('/user_counts', user)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash
expect(json_response['merge_requests']).to eq(2)
end
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 92cc6dc887e..ee0f7545adc 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -832,7 +832,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "updates external status" do
put api("/users/#{user.id}", admin), params: { external: true }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['external']).to eq(true)
expect(user.reload.external?).to be_truthy
end
diff --git a/spec/requests/health_controller_spec.rb b/spec/requests/health_controller_spec.rb
index 61412815039..6ee716e0e89 100644
--- a/spec/requests/health_controller_spec.rb
+++ b/spec/requests/health_controller_spec.rb
@@ -37,7 +37,7 @@ describe HealthController do
it 'responds with resource not found' do
subject
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -48,7 +48,7 @@ describe HealthController do
it 'responds with health checks data' do
subject
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq('GitLab OK')
end
end
@@ -95,7 +95,7 @@ describe HealthController do
expect(json_response['master_check']).to contain_exactly(
{ 'status' => 'failed', 'message' => 'unexpected Master check result: false' })
- expect(response.status).to eq(503)
+ expect(response).to have_gitlab_http_status(:service_unavailable)
expect(response.headers['X-GitLab-Custom-Error']).to eq(1)
end
end
@@ -126,7 +126,7 @@ describe HealthController do
expect(json_response['redis_check']).to contain_exactly(
{ 'status' => 'failed', 'message' => 'check error' })
- expect(response.status).to eq(503)
+ expect(response).to have_gitlab_http_status(:service_unavailable)
expect(response.headers['X-GitLab-Custom-Error']).to eq(1)
end
end
diff --git a/spec/requests/projects/merge_requests_discussions_spec.rb b/spec/requests/projects/merge_requests_discussions_spec.rb
index ffc98d09e5c..94e9c81bc3b 100644
--- a/spec/requests/projects/merge_requests_discussions_spec.rb
+++ b/spec/requests/projects/merge_requests_discussions_spec.rb
@@ -21,7 +21,7 @@ describe 'merge requests discussions' do
it 'returns 200' do
send_request
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
# https://docs.gitlab.com/ee/development/query_recorder.html#use-request-specs-instead-of-controller-specs