summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GITLAB_WORKHORSE_VERSION2
-rw-r--r--app/assets/javascripts/monitoring/components/panel_type.vue2
-rw-r--r--app/controllers/projects/pipelines_controller.rb5
-rw-r--r--app/workers/all_queues.yml2
-rw-r--r--app/workers/namespaces/schedule_aggregation_worker.rb3
-rw-r--r--app/workers/project_update_repository_storage_worker.rb10
-rw-r--r--changelogs/unreleased/jc-prevent-storage-update-deletion.yml5
-rw-r--r--changelogs/unreleased/jivanvl-change-copy-text-link-to-chart.yml5
-rw-r--r--changelogs/unreleased/sh-handle-no-latest-pipeline.yml5
-rw-r--r--doc/development/testing_guide/best_practices.md3
-rw-r--r--lib/gitlab/sidekiq_middleware/duplicate_jobs.rb3
-rw-r--r--locale/gitlab.pot6
-rw-r--r--package.json8
-rw-r--r--rubocop/cop/rspec/have_gitlab_http_status.rb86
-rw-r--r--spec/controllers/admin/application_settings_controller_spec.rb6
-rw-r--r--spec/controllers/admin/clusters_controller_spec.rb8
-rw-r--r--spec/controllers/autocomplete_controller_spec.rb2
-rw-r--r--spec/controllers/concerns/lfs_request_spec.rb6
-rw-r--r--spec/controllers/dashboard/todos_controller_spec.rb2
-rw-r--r--spec/controllers/graphql_controller_spec.rb2
-rw-r--r--spec/controllers/groups/clusters_controller_spec.rb8
-rw-r--r--spec/controllers/groups_controller_spec.rb4
-rw-r--r--spec/controllers/metrics_controller_spec.rb6
-rw-r--r--spec/controllers/notification_settings_controller_spec.rb12
-rw-r--r--spec/controllers/oauth/token_info_controller_spec.rb10
-rw-r--r--spec/controllers/omniauth_callbacks_controller_spec.rb4
-rw-r--r--spec/controllers/profiles_controller_spec.rb20
-rw-r--r--spec/controllers/projects/clusters_controller_spec.rb8
-rw-r--r--spec/controllers/projects/group_links_controller_spec.rb4
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb12
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb8
-rw-r--r--spec/controllers/projects/project_members_controller_spec.rb2
-rw-r--r--spec/controllers/projects/protected_branches_controller_spec.rb2
-rw-r--r--spec/controllers/projects/releases_controller_spec.rb6
-rw-r--r--spec/controllers/projects/templates_controller_spec.rb12
-rw-r--r--spec/controllers/projects_controller_spec.rb2
-rw-r--r--spec/controllers/registrations_controller_spec.rb4
-rw-r--r--spec/controllers/repositories/git_http_controller_spec.rb10
-rw-r--r--spec/controllers/sent_notifications_controller_spec.rb2
-rw-r--r--spec/controllers/sessions_controller_spec.rb2
-rw-r--r--spec/controllers/snippets_controller_spec.rb4
-rw-r--r--spec/frontend/monitoring/components/panel_type_spec.js2
-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
-rw-r--r--spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb20
-rw-r--r--spec/support/shared_examples/controllers/sessionless_auth_controller_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/controllers/update_invalid_issuable_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/requests/api/milestones_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/requests/api/notes_shared_examples.rb2
-rw-r--r--spec/workers/namespaces/schedule_aggregation_worker_spec.rb11
-rw-r--r--spec/workers/project_update_repository_storage_worker_spec.rb30
-rw-r--r--yarn.lock8
71 files changed, 337 insertions, 209 deletions
diff --git a/GITLAB_WORKHORSE_VERSION b/GITLAB_WORKHORSE_VERSION
index 3d6a12c1619..0ac74451100 100644
--- a/GITLAB_WORKHORSE_VERSION
+++ b/GITLAB_WORKHORSE_VERSION
@@ -1 +1 @@
-8.28.0
+8.29.0
diff --git a/app/assets/javascripts/monitoring/components/panel_type.vue b/app/assets/javascripts/monitoring/components/panel_type.vue
index d6d60c2d5da..77ba17b6e68 100644
--- a/app/assets/javascripts/monitoring/components/panel_type.vue
+++ b/app/assets/javascripts/monitoring/components/panel_type.vue
@@ -259,7 +259,7 @@ export default {
:data-clipboard-text="clipboardText"
@click="showToast(clipboardText)"
>
- {{ __('Generate link to chart') }}
+ {{ __('Copy link to chart') }}
</gl-dropdown-item>
<gl-dropdown-item
v-if="alertWidgetAvailable"
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index ee102248cb7..ff65f040335 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -13,6 +13,7 @@ class Projects::PipelinesController < Projects::ApplicationController
before_action do
push_frontend_feature_flag(:junit_pipeline_view)
end
+ before_action :ensure_pipeline, only: [:show]
around_action :allow_gitaly_ref_name_caching, only: [:index, :show]
@@ -214,6 +215,10 @@ class Projects::PipelinesController < Projects::ApplicationController
params.require(:pipeline).permit(:ref, variables_attributes: %i[key variable_type secret_value])
end
+ def ensure_pipeline
+ render_404 unless pipeline
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
def pipeline
@pipeline ||= if params[:id].blank? && params[:latest]
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 7dc47c55a04..4c8b703d60e 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -919,7 +919,7 @@
:urgency: :low
:resource_boundary: :unknown
:weight: 1
- :idempotent:
+ :idempotent: true
- :name: authorized_keys
:feature_category: :source_code_management
:has_external_dependencies:
diff --git a/app/workers/namespaces/schedule_aggregation_worker.rb b/app/workers/namespaces/schedule_aggregation_worker.rb
index 94343a9e378..cbf5ed44572 100644
--- a/app/workers/namespaces/schedule_aggregation_worker.rb
+++ b/app/workers/namespaces/schedule_aggregation_worker.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
module Namespaces
- class ScheduleAggregationWorker # rubocop:disable Scalability/IdempotentWorker
+ class ScheduleAggregationWorker
include ApplicationWorker
queue_namespace :update_namespace_statistics
feature_category :source_code_management
+ idempotent!
def perform(namespace_id)
return unless aggregation_schedules_table_exists?
diff --git a/app/workers/project_update_repository_storage_worker.rb b/app/workers/project_update_repository_storage_worker.rb
index ecee33e6421..bb40107494b 100644
--- a/app/workers/project_update_repository_storage_worker.rb
+++ b/app/workers/project_update_repository_storage_worker.rb
@@ -3,11 +3,21 @@
class ProjectUpdateRepositoryStorageWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
+ SameFilesystemError = Class.new(StandardError)
+
feature_category :gitaly
def perform(project_id, new_repository_storage_key)
project = Project.find(project_id)
+ raise SameFilesystemError if same_filesystem?(project.repository.storage, new_repository_storage_key)
+
::Projects::UpdateRepositoryStorageService.new(project).execute(new_repository_storage_key)
end
+
+ private
+
+ def same_filesystem?(old_storage, new_storage)
+ Gitlab::GitalyClient.filesystem_id(old_storage) == Gitlab::GitalyClient.filesystem_id(new_storage)
+ end
end
diff --git a/changelogs/unreleased/jc-prevent-storage-update-deletion.yml b/changelogs/unreleased/jc-prevent-storage-update-deletion.yml
new file mode 100644
index 00000000000..21579d5c66f
--- /dev/null
+++ b/changelogs/unreleased/jc-prevent-storage-update-deletion.yml
@@ -0,0 +1,5 @@
+---
+title: Prevent ProjectUpdateRepositoryStorageWorker from moving to same filesystem
+merge_request: 28469
+author:
+type: fixed
diff --git a/changelogs/unreleased/jivanvl-change-copy-text-link-to-chart.yml b/changelogs/unreleased/jivanvl-change-copy-text-link-to-chart.yml
new file mode 100644
index 00000000000..b040821748d
--- /dev/null
+++ b/changelogs/unreleased/jivanvl-change-copy-text-link-to-chart.yml
@@ -0,0 +1,5 @@
+---
+title: Change the link to chart copy text
+merge_request: 28371
+author:
+type: other
diff --git a/changelogs/unreleased/sh-handle-no-latest-pipeline.yml b/changelogs/unreleased/sh-handle-no-latest-pipeline.yml
new file mode 100644
index 00000000000..e6c92d329d9
--- /dev/null
+++ b/changelogs/unreleased/sh-handle-no-latest-pipeline.yml
@@ -0,0 +1,5 @@
+---
+title: Gracefully handle missing latest CI pipeline
+merge_request: 28263
+author:
+type: fixed
diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md
index 108003b2d76..31a449dbbb2 100644
--- a/doc/development/testing_guide/best_practices.md
+++ b/doc/development/testing_guide/best_practices.md
@@ -543,7 +543,8 @@ expect(metrics.merged_at).to be_like_time(time)
#### `have_gitlab_http_status`
-Prefer `have_gitlab_http_status` over `have_http_status` because the former
+Prefer `have_gitlab_http_status` over `have_http_status` and
+`expect(response.status).to` because the former
could also show the response body whenever the status mismatched. This would
be very useful whenever some tests start breaking and we would love to know
why without editing the source and rerun the tests.
diff --git a/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb b/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb
index f0e26f99c2c..7a77a56d642 100644
--- a/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb
+++ b/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb
@@ -6,7 +6,8 @@ module Gitlab
module SidekiqMiddleware
module DuplicateJobs
DROPPABLE_QUEUES = Set.new([
- Namespaces::RootStatisticsWorker.queue
+ Namespaces::RootStatisticsWorker.queue,
+ Namespaces::ScheduleAggregationWorker.queue
]).freeze
def self.drop_duplicates?(queue_name)
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 2a38073ba92..41baa2946aa 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -5656,6 +5656,9 @@ msgstr ""
msgid "Copy link"
msgstr ""
+msgid "Copy link to chart"
+msgstr ""
+
msgid "Copy personal access token"
msgstr ""
@@ -9141,9 +9144,6 @@ msgstr ""
msgid "Generate key"
msgstr ""
-msgid "Generate link to chart"
-msgstr ""
-
msgid "Generate new export"
msgstr ""
diff --git a/package.json b/package.json
index bc0c719943d..3132009ee2b 100644
--- a/package.json
+++ b/package.json
@@ -38,9 +38,9 @@
"@babel/plugin-proposal-private-methods": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.8.3",
"@babel/preset-env": "^7.8.4",
- "@gitlab/at.js": "^1.5.5",
- "@gitlab/svgs": "^1.116.0",
- "@gitlab/ui": "^10.1.2",
+ "@gitlab/at.js": "1.5.5",
+ "@gitlab/svgs": "1.116.0",
+ "@gitlab/ui": "10.1.2",
"@gitlab/visual-review-tools": "1.5.1",
"@sentry/browser": "^5.10.2",
"@sourcegraph/code-host-integration": "0.0.34",
@@ -145,7 +145,7 @@
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
- "@gitlab/eslint-plugin": "^2.0.0",
+ "@gitlab/eslint-plugin": "2.0.0",
"@vue/test-utils": "^1.0.0-beta.30",
"axios-mock-adapter": "^1.15.0",
"babel-jest": "^24.1.0",
diff --git a/rubocop/cop/rspec/have_gitlab_http_status.rb b/rubocop/cop/rspec/have_gitlab_http_status.rb
index 6b179720060..d61fb9f2368 100644
--- a/rubocop/cop/rspec/have_gitlab_http_status.rb
+++ b/rubocop/cop/rspec/have_gitlab_http_status.rb
@@ -15,39 +15,67 @@ module RuboCop
# expect(response).to have_http_status(200)
# expect(response).to have_http_status(:ok)
# expect(response).to have_gitlab_http_status(200)
+ # expect(response.status).to eq(200)
+ # expect(response.status).not_to eq(200)
#
# # good
# expect(response).to have_gitlab_http_status(:ok)
+ # expect(response).not_to have_gitlab_http_status(:ok)
#
class HaveGitlabHttpStatus < RuboCop::Cop::Cop
CODE_TO_SYMBOL = Rack::Utils::SYMBOL_TO_STATUS_CODE.invert
MSG_MATCHER_NAME =
- 'Use `have_gitlab_http_status` instead of `have_http_status`.'
+ 'Prefer `have_gitlab_http_status` over `have_http_status`.'
- MSG_STATUS =
+ MSG_NUMERIC_STATUS =
'Prefer named HTTP status `%{name}` over ' \
'its numeric representation `%{code}`.'
- MSG_UNKNOWN = 'HTTP status `%{code}` is unknown. ' \
+ MSG_RESPONSE_STATUS =
+ 'Prefer `have_gitlab_http_status` matcher over ' \
+ '`response.status`.'
+
+ MSG_UNKNOWN_STATUS = 'HTTP status `%{code}` is unknown. ' \
'Please provide a valid one or disable this cop.'
MSG_DOCS_LINK = 'https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#have_gitlab_http_status'
REPLACEMENT = 'have_gitlab_http_status(%{arg})'
+ REPLACEMENT_RESPONSE_STATUS =
+ 'expect(response).%{expectation} have_gitlab_http_status(%{arg})'
+
def_node_matcher :have_http_status?, <<~PATTERN
- (
- send nil?
- {
- :have_http_status
- :have_gitlab_http_status
- }
+ (send nil?
+ { :have_http_status :have_gitlab_http_status }
_
)
PATTERN
+ def_node_matcher :response_status_eq?, <<~PATTERN
+ (send
+ (send nil? :expect
+ (send
+ (send nil? :response) :status)) ${ :to :not_to }
+ (send nil? :eq
+ (int $_)))
+ PATTERN
+
def on_send(node)
+ offense_for_matcher(node) || offense_for_response_status(node)
+ end
+
+ def autocorrect(node)
+ lambda do |corrector|
+ replacement = replace_matcher(node) || replace_response_status(node)
+ corrector.replace(node.source_range, replacement)
+ end
+ end
+
+ private
+
+ def offense_for_matcher(node)
return unless have_http_status?(node)
offenses = [
@@ -57,16 +85,31 @@ module RuboCop
return if offenses.empty?
- add_offense(node, message: message_for(offenses))
+ add_offense(node, message: message_for(*offenses))
end
- def autocorrect(node)
- lambda do |corrector|
- corrector.replace(node.source_range, replacement(node))
- end
+ def offense_for_response_status(node)
+ return unless response_status_eq?(node)
+
+ add_offense(node, message: message_for(MSG_RESPONSE_STATUS))
end
- private
+ def replace_matcher(node)
+ return unless have_http_status?(node)
+
+ code = extract_numeric_code(node)
+ arg = code_to_symbol(code) || argument(node).source
+
+ format(REPLACEMENT, arg: arg)
+ end
+
+ def replace_response_status(node)
+ expectation, code = response_status_eq?(node)
+ return unless code
+
+ arg = code_to_symbol(code)
+ format(REPLACEMENT_RESPONSE_STATUS, expectation: expectation, arg: arg)
+ end
def offense_for_name(node)
return if method_name(node) == :have_gitlab_http_status
@@ -79,22 +122,15 @@ module RuboCop
return unless code
symbol = code_to_symbol(code)
- return format(MSG_UNKNOWN, code: code) unless symbol
+ return format(MSG_UNKNOWN_STATUS, code: code) unless symbol
- format(MSG_STATUS, name: symbol, code: code)
+ format(MSG_NUMERIC_STATUS, name: symbol, code: code)
end
- def message_for(offenses)
+ def message_for(*offenses)
(offenses + [MSG_DOCS_LINK]).join(' ')
end
- def replacement(node)
- code = extract_numeric_code(node)
- arg = code_to_symbol(code) || argument(node).source
-
- format(REPLACEMENT, arg: arg)
- end
-
def code_to_symbol(code)
CODE_TO_SYMBOL[code]&.inspect
end
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb
index ea51f3fcdf4..33764818f79 100644
--- a/spec/controllers/admin/application_settings_controller_spec.rb
+++ b/spec/controllers/admin/application_settings_controller_spec.rb
@@ -23,7 +23,7 @@ describe Admin::ApplicationSettingsController do
it 'returns 404' do
get :usage_data, format: :html
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -37,7 +37,7 @@ describe Admin::ApplicationSettingsController do
get :usage_data, format: :html
expect(response.body).to start_with('<span')
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns JSON data' do
@@ -46,7 +46,7 @@ describe Admin::ApplicationSettingsController do
body = json_response
expect(body["version"]).to eq(Gitlab::VERSION)
expect(body).to include('counts')
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
diff --git a/spec/controllers/admin/clusters_controller_spec.rb b/spec/controllers/admin/clusters_controller_spec.rb
index 1f5c33d8022..bd6d5614ccd 100644
--- a/spec/controllers/admin/clusters_controller_spec.rb
+++ b/spec/controllers/admin/clusters_controller_spec.rb
@@ -261,7 +261,7 @@ describe Admin::ClustersController do
cluster = Clusters::Cluster.instance_type.first
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response.location).to eq(admin_cluster_path(cluster))
expect(cluster).to be_aws
expect(cluster).to be_kubernetes
@@ -277,7 +277,7 @@ describe Admin::ClustersController do
it 'does not create a cluster' do
expect { post_create_aws }.not_to change { Clusters::Cluster.count }
- expect(response.status).to eq(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(response.content_type).to eq('application/json')
expect(response.body).to include('is invalid')
end
@@ -389,7 +389,7 @@ describe Admin::ClustersController do
it 'creates an Aws::Role record' do
expect { go }.to change { Aws::Role.count }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
role = Aws::Role.last
expect(role.user).to eq admin
@@ -403,7 +403,7 @@ describe Admin::ClustersController do
it 'does not create a record' do
expect { go }.not_to change { Aws::Role.count }
- expect(response.status).to eq 422
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb
index 1ebbeecc583..f3d4234a558 100644
--- a/spec/controllers/autocomplete_controller_spec.rb
+++ b/spec/controllers/autocomplete_controller_spec.rb
@@ -173,7 +173,7 @@ describe AutocompleteController do
it 'gives an array of users' do
get :users, params: { todo_filter: true }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_kind_of(Array)
end
end
diff --git a/spec/controllers/concerns/lfs_request_spec.rb b/spec/controllers/concerns/lfs_request_spec.rb
index 67c81156ca6..f771a3438cf 100644
--- a/spec/controllers/concerns/lfs_request_spec.rb
+++ b/spec/controllers/concerns/lfs_request_spec.rb
@@ -48,7 +48,7 @@ describe LfsRequest do
it 'returns 403' do
get :show, params: { id: project.id }
- expect(response.status).to eq(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -57,7 +57,7 @@ describe LfsRequest do
it 'returns 404' do
get :show, params: { id: 'does not exist' }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -67,7 +67,7 @@ describe LfsRequest do
it 'returns 404' do
get :show, params: { id: project.id }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb
index 0823afe410d..cea0ea75e5d 100644
--- a/spec/controllers/dashboard/todos_controller_spec.rb
+++ b/spec/controllers/dashboard/todos_controller_spec.rb
@@ -68,7 +68,7 @@ describe Dashboard::TodosController do
create(:todo, project: project, author: author, user: user, target: merge_request_2)
expect { get :index }.not_to exceed_query_limit(control)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb
index 0c1089dc7a8..a8e78524910 100644
--- a/spec/controllers/graphql_controller_spec.rb
+++ b/spec/controllers/graphql_controller_spec.rb
@@ -50,7 +50,7 @@ describe GraphqlController do
post :execute
- expect(response.status).to eq(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(response).to render_template('errors/access_denied')
end
end
diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb
index cdb45e1946e..28a174560dd 100644
--- a/spec/controllers/groups/clusters_controller_spec.rb
+++ b/spec/controllers/groups/clusters_controller_spec.rb
@@ -388,7 +388,7 @@ describe Groups::ClustersController do
cluster = group.clusters.first
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response.location).to eq(group_cluster_path(group, cluster))
expect(cluster).to be_aws
expect(cluster).to be_kubernetes
@@ -404,7 +404,7 @@ describe Groups::ClustersController do
it 'does not create a cluster' do
expect { post_create_aws }.not_to change { Clusters::Cluster.count }
- expect(response.status).to eq(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(response.content_type).to eq('application/json')
expect(response.body).to include('is invalid')
end
@@ -451,7 +451,7 @@ describe Groups::ClustersController do
it 'creates an Aws::Role record' do
expect { go }.to change { Aws::Role.count }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
role = Aws::Role.last
expect(role.user).to eq user
@@ -465,7 +465,7 @@ describe Groups::ClustersController do
it 'does not create a record' do
expect { go }.not_to change { Aws::Role.count }
- expect(response.status).to eq 422
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index 22427f581d4..7bd0f6bd6b8 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -32,7 +32,7 @@ describe GroupsController do
get :new, params: { parent_id: group.id }
expect(response).not_to render_template(:new)
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -373,7 +373,7 @@ describe GroupsController do
delete :destroy, params: { id: group.to_param }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
diff --git a/spec/controllers/metrics_controller_spec.rb b/spec/controllers/metrics_controller_spec.rb
index 331eafba0d3..75509cc509f 100644
--- a/spec/controllers/metrics_controller_spec.rb
+++ b/spec/controllers/metrics_controller_spec.rb
@@ -33,7 +33,7 @@ describe MetricsController, :request_store do
it 'returns prometheus metrics' do
get :index
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to match(/^prometheus_counter 1$/)
end
@@ -45,7 +45,7 @@ describe MetricsController, :request_store do
it 'returns proper response' do
get :index
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq("# Metrics are disabled, see: http://test.host/help/administration/monitoring/prometheus/gitlab_metrics#gitlab-prometheus-metrics\n")
end
end
@@ -75,7 +75,7 @@ describe MetricsController, :request_store do
it 'returns the expected error response' do
get :index
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
diff --git a/spec/controllers/notification_settings_controller_spec.rb b/spec/controllers/notification_settings_controller_spec.rb
index 7b19c67cad3..f3b608aee0c 100644
--- a/spec/controllers/notification_settings_controller_spec.rb
+++ b/spec/controllers/notification_settings_controller_spec.rb
@@ -50,7 +50,7 @@ describe NotificationSettingsController do
notification_setting: { level: :participating }
}
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(notification_setting.level).to eq("participating")
expect(notification_setting.user_id).to eq(user.id)
expect(notification_setting.source_id).to eq(project.id)
@@ -65,7 +65,7 @@ describe NotificationSettingsController do
notification_setting: { level: :custom }.merge(custom_events)
}
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(notification_setting.level).to eq("custom")
custom_events.each do |event, value|
@@ -85,7 +85,7 @@ describe NotificationSettingsController do
notification_setting: { level: :watch }
}
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(notification_setting.level).to eq("watch")
expect(notification_setting.user_id).to eq(user.id)
expect(notification_setting.source_id).to eq(group.id)
@@ -100,7 +100,7 @@ describe NotificationSettingsController do
notification_setting: { level: :custom }.merge(custom_events)
}
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(notification_setting.level).to eq("custom")
custom_events.each do |event, value|
@@ -157,7 +157,7 @@ describe NotificationSettingsController do
notification_setting: { level: :participating }
}
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
end
context 'and setting custom notification setting' do
@@ -176,7 +176,7 @@ describe NotificationSettingsController do
notification_setting: { level: :participating, events: custom_events }
}
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
diff --git a/spec/controllers/oauth/token_info_controller_spec.rb b/spec/controllers/oauth/token_info_controller_spec.rb
index 35ad0dcf98c..4b3539879df 100644
--- a/spec/controllers/oauth/token_info_controller_spec.rb
+++ b/spec/controllers/oauth/token_info_controller_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Oauth::TokenInfoController do
it 'responds with a 401' do
get :show
- expect(response.status).to eq 401
+ expect(response).to have_gitlab_http_status(:unauthorized)
expect(JSON.parse(response.body)).to include('error' => 'invalid_request')
end
end
@@ -22,7 +22,7 @@ RSpec.describe Oauth::TokenInfoController do
it 'responds with the token info' do
get :show, params: { access_token: access_token.token }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(JSON.parse(response.body)).to eq(
'scope' => %w[api],
'scopes' => %w[api],
@@ -39,7 +39,7 @@ RSpec.describe Oauth::TokenInfoController do
it 'responds with a 401' do
get :show, params: { access_token: 'unknown_token' }
- expect(response.status).to eq 401
+ expect(response).to have_gitlab_http_status(:unauthorized)
expect(JSON.parse(response.body)).to include('error' => 'invalid_request')
end
end
@@ -52,7 +52,7 @@ RSpec.describe Oauth::TokenInfoController do
it 'responds with a 401' do
get :show, params: { access_token: access_token.token }
- expect(response.status).to eq 401
+ expect(response).to have_gitlab_http_status(:unauthorized)
expect(JSON.parse(response.body)).to include('error' => 'invalid_request')
end
end
@@ -63,7 +63,7 @@ RSpec.describe Oauth::TokenInfoController do
it 'responds with a 401' do
get :show, params: { access_token: access_token.token }
- expect(response.status).to eq 401
+ expect(response).to have_gitlab_http_status(:unauthorized)
expect(JSON.parse(response.body)).to include('error' => 'invalid_request')
end
end
diff --git a/spec/controllers/omniauth_callbacks_controller_spec.rb b/spec/controllers/omniauth_callbacks_controller_spec.rb
index 71cdba12147..9537ff62f8b 100644
--- a/spec/controllers/omniauth_callbacks_controller_spec.rb
+++ b/spec/controllers/omniauth_callbacks_controller_spec.rb
@@ -234,7 +234,7 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode:
post 'auth0'
expect(request.env['warden']).not_to be_authenticated
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:alert].to('Wrong extern UID provided. Make sure Auth0 is configured correctly.')
end
end
@@ -249,7 +249,7 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode:
post 'salesforce'
expect(request.env['warden']).not_to be_authenticated
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:alert].to('Email not verified. Please verify your email in Salesforce.')
end
end
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index f0d83bb6bbd..d6d2c73d049 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -14,7 +14,7 @@ describe ProfilesController, :request_store do
params: { user: { password: 'hello12345', password_confirmation: 'hello12345' } }
end.not_to change { user.reload.encrypted_password }
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
end
end
@@ -27,7 +27,7 @@ describe ProfilesController, :request_store do
user.reload
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(user.unconfirmed_email).to eq('john@gmail.com')
end
@@ -41,7 +41,7 @@ describe ProfilesController, :request_store do
user.reload
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(user.unconfirmed_email).to eq nil
end
@@ -58,7 +58,7 @@ describe ProfilesController, :request_store do
ldap_user.reload
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com')
end
@@ -75,7 +75,7 @@ describe ProfilesController, :request_store do
ldap_user.reload
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com')
expect(ldap_user.name).not_to eq('John')
expect(ldap_user.location).to eq('City, Country')
@@ -114,7 +114,7 @@ describe ProfilesController, :request_store do
user.reload
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(user.username).to eq(new_username)
end
@@ -127,7 +127,7 @@ describe ProfilesController, :request_store do
},
format: :json
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['message']).to eq(s_('Profiles|Username successfully changed'))
end
@@ -140,7 +140,7 @@ describe ProfilesController, :request_store do
},
format: :json
- expect(response.status).to eq(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['message']).to match(/Username change failed/)
end
@@ -162,7 +162,7 @@ describe ProfilesController, :request_store do
user.reload
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(gitlab_shell.repository_exists?(project.repository_storage, "#{new_username}/#{project.path}.git")).to be_truthy
end
end
@@ -180,7 +180,7 @@ describe ProfilesController, :request_store do
user.reload
- expect(response.status).to eq(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(gitlab_shell.repository_exists?(project.repository_storage, "#{project.disk_path}.git")).to be_truthy
expect(before_disk_path).to eq(project.disk_path)
end
diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb
index a224a2101d3..a5683a27837 100644
--- a/spec/controllers/projects/clusters_controller_spec.rb
+++ b/spec/controllers/projects/clusters_controller_spec.rb
@@ -387,7 +387,7 @@ describe Projects::ClustersController do
cluster = project.clusters.first
- expect(response.status).to eq(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response.location).to eq(project_cluster_path(project, cluster))
expect(cluster).to be_aws
expect(cluster).to be_kubernetes
@@ -403,7 +403,7 @@ describe Projects::ClustersController do
it 'does not create a cluster' do
expect { post_create_aws }.not_to change { Clusters::Cluster.count }
- expect(response.status).to eq(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(response.content_type).to eq('application/json')
expect(response.body).to include('is invalid')
end
@@ -450,7 +450,7 @@ describe Projects::ClustersController do
it 'creates an Aws::Role record' do
expect { go }.to change { Aws::Role.count }
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
role = Aws::Role.last
expect(role.user).to eq user
@@ -464,7 +464,7 @@ describe Projects::ClustersController do
it 'does not create a record' do
expect { go }.not_to change { Aws::Role.count }
- expect(response.status).to eq 422
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
diff --git a/spec/controllers/projects/group_links_controller_spec.rb b/spec/controllers/projects/group_links_controller_spec.rb
index f8271bc8e8a..28999257957 100644
--- a/spec/controllers/projects/group_links_controller_spec.rb
+++ b/spec/controllers/projects/group_links_controller_spec.rb
@@ -59,7 +59,7 @@ describe Projects::GroupLinksController do
include_context 'link project to group'
it 'renders 404' do
- expect(response.status).to eq 404
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not share project with that group' do
@@ -73,7 +73,7 @@ describe Projects::GroupLinksController do
include_context 'link project to group'
it 'renders 404' do
- expect(response.status).to eq 404
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not share project with that group' do
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 2b1890f6cbd..5104c83283d 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -1557,7 +1557,7 @@ describe Projects::MergeRequestsController do
post_rebase
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -1572,7 +1572,7 @@ describe Projects::MergeRequestsController do
post_rebase
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -1583,7 +1583,7 @@ describe Projects::MergeRequestsController do
post_rebase
- expect(response.status).to eq(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['merge_error']).to eq('Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.')
end
end
@@ -1605,7 +1605,7 @@ describe Projects::MergeRequestsController do
post_rebase
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -1621,7 +1621,7 @@ describe Projects::MergeRequestsController do
post_rebase
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -1639,7 +1639,7 @@ describe Projects::MergeRequestsController do
it 'returns 200' do
get :discussions, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
context 'highlight preloading' do
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index 74931fcdeb2..0368130118f 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -923,10 +923,18 @@ describe Projects::PipelinesController do
end
context 'ref provided' do
+ render_views
+
before do
create(:ci_pipeline, ref: 'master', project: project)
end
+ it 'shows a 404 if no pipeline exists' do
+ get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: 'non-existence' }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+
it 'shows the latest pipeline for the provided ref' do
get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name }
diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb
index 09420cc8556..f354bba902a 100644
--- a/spec/controllers/projects/project_members_controller_spec.rb
+++ b/spec/controllers/projects/project_members_controller_spec.rb
@@ -392,7 +392,7 @@ describe Projects::ProjectMembersController do
end
it 'responds with not found' do
- expect(response.status).to eq 404
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
diff --git a/spec/controllers/projects/protected_branches_controller_spec.rb b/spec/controllers/projects/protected_branches_controller_spec.rb
index 0ebbb4b581f..262f77a7328 100644
--- a/spec/controllers/projects/protected_branches_controller_spec.rb
+++ b/spec/controllers/projects/protected_branches_controller_spec.rb
@@ -103,7 +103,7 @@ describe Projects::ProtectedBranchesController do
it "prevents deletion of the protected branch rule" do
delete(:destroy, params: base_params)
- expect(response.status).to eq(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
diff --git a/spec/controllers/projects/releases_controller_spec.rb b/spec/controllers/projects/releases_controller_spec.rb
index 4c957e22d24..45f4433ed0a 100644
--- a/spec/controllers/projects/releases_controller_spec.rb
+++ b/spec/controllers/projects/releases_controller_spec.rb
@@ -36,7 +36,7 @@ describe Projects::ReleasesController do
it 'renders a 200' do
get_index
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
context 'when the project is private' do
@@ -54,7 +54,7 @@ describe Projects::ReleasesController do
get_index
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -66,7 +66,7 @@ describe Projects::ReleasesController do
get_index
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
diff --git a/spec/controllers/projects/templates_controller_spec.rb b/spec/controllers/projects/templates_controller_spec.rb
index b4b04878181..fcd9b4aa8bd 100644
--- a/spec/controllers/projects/templates_controller_spec.rb
+++ b/spec/controllers/projects/templates_controller_spec.rb
@@ -15,7 +15,7 @@ describe Projects::TemplatesController do
it do
get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'issue_template', project_id: project }, format: :json)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('issue_template')
expect(json_response['content']).to eq('issue content')
end
@@ -25,7 +25,7 @@ describe Projects::TemplatesController do
it do
get(:show, params: { namespace_id: project.namespace, template_type: 'merge_request', key: 'merge_request_template', project_id: project }, format: :json)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('merge_request_template')
expect(json_response['content']).to eq('merge request content')
end
@@ -35,7 +35,7 @@ describe Projects::TemplatesController do
it do
get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'issue_template', project_id: project }, format: :json)
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -43,7 +43,7 @@ describe Projects::TemplatesController do
it do
get(:show, params: { namespace_id: project.namespace, template_type: 'merge_request', key: 'merge_request_template', project_id: project }, format: :json)
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -57,13 +57,13 @@ describe Projects::TemplatesController do
it 'renders 404 when the format type is invalid' do
get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'issue_template', project_id: project }, format: :html)
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'renders 404 when the key is unknown' do
get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'unknown_template', project_id: project }, format: :json)
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 53a57937e9b..d0e0dabc9f2 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -294,7 +294,7 @@ describe ProjectsController do
get :show, params: { namespace_id: project.namespace, id: project }
- expect(response.status).to eq 404
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index d7fe3e87056..0b4ecb68cf7 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -334,7 +334,7 @@ describe RegistrationsController do
def expect_failure(message)
expect(flash[:alert]).to eq(message)
- expect(response.status).to eq(303)
+ expect(response).to have_gitlab_http_status(:see_other)
expect(response).to redirect_to profile_account_path
end
@@ -348,7 +348,7 @@ describe RegistrationsController do
def expect_success
expect(flash[:notice]).to eq s_('Profiles|Account scheduled for removal.')
- expect(response.status).to eq(303)
+ expect(response).to have_gitlab_http_status(:see_other)
expect(response).to redirect_to new_user_session_path
end
diff --git a/spec/controllers/repositories/git_http_controller_spec.rb b/spec/controllers/repositories/git_http_controller_spec.rb
index 0bd2305ff85..de14384eb6f 100644
--- a/spec/controllers/repositories/git_http_controller_spec.rb
+++ b/spec/controllers/repositories/git_http_controller_spec.rb
@@ -23,7 +23,7 @@ describe Repositories::GitHttpController do
it 'returns 403' do
head :info_refs, params: params
- expect(response.status).to eq(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -39,7 +39,7 @@ describe Repositories::GitHttpController do
get :info_refs, params: params
- expect(response.status).to eq(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
context 'with authorized user' do
@@ -50,7 +50,7 @@ describe Repositories::GitHttpController do
it 'returns 200' do
get :info_refs, params: params
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'updates the user activity' do
@@ -72,7 +72,7 @@ describe Repositories::GitHttpController do
get :info_refs, params: params
- expect(response.status).to eq(503)
+ expect(response).to have_gitlab_http_status(:service_unavailable)
end
it 'returns 503 with timeout error' do
@@ -80,7 +80,7 @@ describe Repositories::GitHttpController do
get :info_refs, params: params
- expect(response.status).to eq(503)
+ expect(response).to have_gitlab_http_status(:service_unavailable)
expect(response.body).to eq 'Gitlab::GitAccess::TimeoutError'
end
end
diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb
index b4b867f5c66..a0a18f66b0c 100644
--- a/spec/controllers/sent_notifications_controller_spec.rb
+++ b/spec/controllers/sent_notifications_controller_spec.rb
@@ -76,7 +76,7 @@ describe SentNotificationsController do
end
it 'renders unsubscribe page' do
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template :unsubscribe
end
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index f3e2ea50913..af2e452c0ca 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -153,7 +153,7 @@ describe SessionsController do
it 'returns status 403' do
post(:create, params: { user: user_params })
- expect(response.status).to eq 403
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb
index e41deae0e89..05c48fb190c 100644
--- a/spec/controllers/snippets_controller_spec.rb
+++ b/spec/controllers/snippets_controller_spec.rb
@@ -720,7 +720,7 @@ describe SnippetsController do
post(:toggle_award_emoji, params: { id: personal_snippet.to_param, name: "thumbsup" })
end.to change { personal_snippet.award_emoji.count }.from(0).to(1)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it "removes the already awarded emoji" do
@@ -730,7 +730,7 @@ describe SnippetsController do
post(:toggle_award_emoji, params: { id: personal_snippet.to_param, name: "thumbsup" })
end.to change { personal_snippet.award_emoji.count }.from(1).to(0)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
diff --git a/spec/frontend/monitoring/components/panel_type_spec.js b/spec/frontend/monitoring/components/panel_type_spec.js
index 782a276a91b..02511ac46ea 100644
--- a/spec/frontend/monitoring/components/panel_type_spec.js
+++ b/spec/frontend/monitoring/components/panel_type_spec.js
@@ -341,7 +341,7 @@ describe('Panel Type component', () => {
});
it('adds a copy button to the dropdown', () => {
- expect(findCopyLink().text()).toContain('Generate link to chart');
+ expect(findCopyLink().text()).toContain('Copy link to chart');
});
it('opens a toast on click', () => {
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
diff --git a/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb b/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb
index 12bdacdee3c..4aa45e66ca7 100644
--- a/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb
+++ b/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb
@@ -59,6 +59,8 @@ describe RuboCop::Cop::RSpec::HaveGitlabHttpStatus do
'have_http_status(var)' | 'have_gitlab_http_status(var)'
'have_http_status(:success)' | 'have_gitlab_http_status(:success)'
'have_http_status(:invalid)' | 'have_gitlab_http_status(:invalid)'
+ 'expect(response.status).to eq(200)' | 'expect(response).to have_gitlab_http_status(:ok)'
+ 'expect(response.status).not_to eq(200)' | 'expect(response).not_to have_gitlab_http_status(:ok)'
end
with_them do
@@ -90,7 +92,23 @@ describe RuboCop::Cop::RSpec::HaveGitlabHttpStatus do
'have_http_status(200, arg)',
'have_gitlab_http_status',
'have_gitlab_http_status { }',
- 'have_gitlab_http_status(200, arg)'
+ 'have_gitlab_http_status(200, arg)',
+ 'expect(response.status).to eq(arg)',
+ 'expect(response.status).to eq(:ok)',
+ 'expect(response.status).to some_matcher(200)',
+ 'expect(response.status).not_to eq(arg)',
+ 'expect(response.status).not_to eq(:ok)',
+ 'expect(response.status).not_to some_matcher(200)',
+ 'expect(result.status).to eq(200)',
+ 'expect(result.status).not_to eq(200)',
+ <<~CODE,
+ response = some_assignment
+ expect(response.status).to eq(200)
+ CODE
+ <<~CODE
+ response = some_assignment
+ expect(response.status).not_to eq(200)
+ CODE
]
end
diff --git a/spec/support/shared_examples/controllers/sessionless_auth_controller_shared_examples.rb b/spec/support/shared_examples/controllers/sessionless_auth_controller_shared_examples.rb
index e21a3b2f588..f2a97a86df6 100644
--- a/spec/support/shared_examples/controllers/sessionless_auth_controller_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/sessionless_auth_controller_shared_examples.rb
@@ -86,7 +86,7 @@ RSpec.shared_examples 'authenticates sessionless user' do |path, format, params|
get path, params: default_params.merge(feed_token: 'token')
- expect(response.status).not_to eq 200
+ expect(response).not_to have_gitlab_http_status(:ok)
end
end
@@ -103,6 +103,6 @@ RSpec.shared_examples 'authenticates sessionless user' do |path, format, params|
get path, params: default_params.merge(private_token: 'token')
- expect(response.status).not_to eq(200)
+ expect(response).not_to have_gitlab_http_status(:ok)
end
end
diff --git a/spec/support/shared_examples/controllers/update_invalid_issuable_shared_examples.rb b/spec/support/shared_examples/controllers/update_invalid_issuable_shared_examples.rb
index 224cf45ebb3..4a0d5b755db 100644
--- a/spec/support/shared_examples/controllers/update_invalid_issuable_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/update_invalid_issuable_shared_examples.rb
@@ -39,7 +39,7 @@ RSpec.shared_examples 'update invalid issuable' do |klass|
put :update, params: params
- expect(response.status).to eq(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(json_response).to have_key('errors')
end
end
diff --git a/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb b/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
index 662c64647d6..a20c1d78912 100644
--- a/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
@@ -13,7 +13,7 @@ RSpec.shared_examples 'handle uploads' do
context 'when a user is not authorized to upload a file' do
it 'returns 404 status' do
post :create, params: params.merge(file: jpg), format: :json
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -319,7 +319,7 @@ RSpec.shared_examples 'handle uploads authorize' do
it 'returns 404 status' do
post_authorize
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
diff --git a/spec/support/shared_examples/requests/api/milestones_shared_examples.rb b/spec/support/shared_examples/requests/api/milestones_shared_examples.rb
index b7cc5f2ca6b..3afb26bc869 100644
--- a/spec/support/shared_examples/requests/api/milestones_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/milestones_shared_examples.rb
@@ -66,7 +66,7 @@ RSpec.shared_examples 'group and project milestones' do |route_definition|
it 'returns a milestone by iids array' do
get api("#{route}?iids=#{closed_milestone.iid}", user)
- expect(response.status).to eq 200
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response.size).to eq(1)
expect(json_response.size).to eq(1)
diff --git a/spec/support/shared_examples/requests/api/notes_shared_examples.rb b/spec/support/shared_examples/requests/api/notes_shared_examples.rb
index 72e8b920192..61ac9acb154 100644
--- a/spec/support/shared_examples/requests/api/notes_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/notes_shared_examples.rb
@@ -25,7 +25,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
get api("/#{parent_type}/#{parent_id}/#{noteable_type}/#{noteable[id_name]}/notes", user)
- expect(response.status).to eq(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
context '2 notes with equal created_at' do
diff --git a/spec/workers/namespaces/schedule_aggregation_worker_spec.rb b/spec/workers/namespaces/schedule_aggregation_worker_spec.rb
index a2ce9891b5f..e7da346df46 100644
--- a/spec/workers/namespaces/schedule_aggregation_worker_spec.rb
+++ b/spec/workers/namespaces/schedule_aggregation_worker_spec.rb
@@ -54,6 +54,17 @@ describe Namespaces::ScheduleAggregationWorker, '#perform', :clean_gitlab_redis_
end
end
+ it_behaves_like 'an idempotent worker' do
+ let(:job_args) { [group.id] }
+
+ it 'creates a single aggregation schedule' do
+ expect { worker.perform(*job_args) }
+ .to change { Namespace::AggregationSchedule.count }.by(1)
+ expect { worker.perform(*job_args) }
+ .not_to change { Namespace::AggregationSchedule.count }
+ end
+ end
+
def stub_aggregation_schedule_statistics
# Namespace::Aggregations are deleted by
# Namespace::AggregationSchedule::schedule_root_storage_statistics,
diff --git a/spec/workers/project_update_repository_storage_worker_spec.rb b/spec/workers/project_update_repository_storage_worker_spec.rb
index 4cc44281a69..ed99b8135c2 100644
--- a/spec/workers/project_update_repository_storage_worker_spec.rb
+++ b/spec/workers/project_update_repository_storage_worker_spec.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'spec_helper'
+require 'securerandom'
describe ProjectUpdateRepositoryStorageWorker do
let(:project) { create(:project, :repository) }
@@ -8,12 +9,33 @@ describe ProjectUpdateRepositoryStorageWorker do
subject { described_class.new }
describe "#perform" do
- it "calls the update repository storage service" do
- expect_next_instance_of(Projects::UpdateRepositoryStorageService) do |instance|
- expect(instance).to receive(:execute).with('new_storage')
+ context 'when source and target repositories are on different filesystems' do
+ before do
+ allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
+ allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('new_storage').and_return(SecureRandom.uuid)
end
- subject.perform(project.id, 'new_storage')
+ it "calls the update repository storage service" do
+ expect_next_instance_of(Projects::UpdateRepositoryStorageService) do |instance|
+ expect(instance).to receive(:execute).with('new_storage')
+ end
+
+ subject.perform(project.id, 'new_storage')
+ end
+ end
+
+ context 'when source and target repositories are on the same filesystems' do
+ let(:filesystem_id) { SecureRandom.uuid }
+
+ before do
+ allow(Gitlab::GitalyClient).to receive(:filesystem_id).and_return(filesystem_id)
+ end
+
+ it 'raises an error' do
+ expect_any_instance_of(::Projects::UpdateRepositoryStorageService).not_to receive(:new)
+
+ expect { subject.perform(project.id, 'new_storage') }.to raise_error(ProjectUpdateRepositoryStorageWorker::SameFilesystemError)
+ end
end
end
end
diff --git a/yarn.lock b/yarn.lock
index 9610f68fd97..31e2ddb32d8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -761,12 +761,12 @@
exec-sh "^0.3.2"
minimist "^1.2.0"
-"@gitlab/at.js@^1.5.5":
+"@gitlab/at.js@1.5.5":
version "1.5.5"
resolved "https://registry.yarnpkg.com/@gitlab/at.js/-/at.js-1.5.5.tgz#5f6bfe6baaef360daa9b038fa78798d7a6a916b4"
integrity sha512-282Dn3SPVsUHVDhMsXgfnv+Rzog0uxecjttxGRQvxh25es1+xvkGQFsvJfkSKJ3X1kHVkSjKf+Tt5Rra+Jhp9g==
-"@gitlab/eslint-plugin@^2.0.0":
+"@gitlab/eslint-plugin@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@gitlab/eslint-plugin/-/eslint-plugin-2.0.0.tgz#4eedd16cf95cf82dc359c1b220d4f5a08361df9c"
integrity sha512-ctmsGnCuokhfh/5goLdz3NdBIUpwTMkx/17QxxutxkWW7yOGMPIY8Na+WhjnUSdst8Wjwzexc+snbh5NMs8H/A==
@@ -781,12 +781,12 @@
eslint-plugin-vue "^6.2.1"
vue-eslint-parser "^7.0.0"
-"@gitlab/svgs@^1.116.0":
+"@gitlab/svgs@1.116.0":
version "1.116.0"
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.116.0.tgz#a3c89f950bb256c2e109444c9a85fecdd261292c"
integrity sha512-sZLn3acu0IyrSnZRU1rE3UjxF6FlwvBNfjKQgn0qclxdbe8Ya6cGNVq4aGdCEkHwvb9rFpKbfHBujVgVKNkxSA==
-"@gitlab/ui@^10.1.2":
+"@gitlab/ui@10.1.2":
version "10.1.2"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-10.1.2.tgz#027f86f69ef08fb90cab5c69545adf37e20c6ceb"
integrity sha512-xTvLIHrBqvvvHLVPMGdktBv3hNL7FPGPSFbAC3IURrVa/9FIJbzkIYFGlUIbLu/QX1i0CJN+MLmyHhLtzhKgtA==