From 26ee15919967f5649c8ed3b89e6a36bba648518c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Sun, 4 Apr 2021 06:09:06 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .rubocop_manual_todo.yml | 4 ---- .../rails-save-bang-groups-controllers.yml | 5 +++++ .../groups/milestones_controller_spec.rb | 10 +++++----- .../groups/runners_controller_spec.rb | 16 ++++++++-------- .../groups/uploads_controller_spec.rb | 2 +- spec/controllers/groups_controller_spec.rb | 18 +++++++++--------- 6 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 changelogs/unreleased/rails-save-bang-groups-controllers.yml diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index a5b6a6691b1..ce12cfedfdb 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -174,10 +174,6 @@ Rails/SaveBang: - 'qa/qa/specs/features/ee/browser_ui/3_create/repository/pull_mirroring_over_ssh_with_key_spec.rb' - 'spec/controllers/abuse_reports_controller_spec.rb' - 'spec/controllers/boards/issues_controller_spec.rb' - - 'spec/controllers/groups/milestones_controller_spec.rb' - - 'spec/controllers/groups/runners_controller_spec.rb' - - 'spec/controllers/groups/uploads_controller_spec.rb' - - 'spec/controllers/groups_controller_spec.rb' - 'spec/controllers/sent_notifications_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/factories_spec.rb' diff --git a/changelogs/unreleased/rails-save-bang-groups-controllers.yml b/changelogs/unreleased/rails-save-bang-groups-controllers.yml new file mode 100644 index 00000000000..444215e0128 --- /dev/null +++ b/changelogs/unreleased/rails-save-bang-groups-controllers.yml @@ -0,0 +1,5 @@ +--- +title: Fix Rails/SaveBang rubocop offenses in spec/controllers/groups* +merge_request: 57879 +author: Abdul Wadood @abdulwd +type: fixed diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb index 05e93da18e7..a3c4c47ab15 100644 --- a/spec/controllers/groups/milestones_controller_spec.rb +++ b/spec/controllers/groups/milestones_controller_spec.rb @@ -322,7 +322,7 @@ RSpec.describe Groups::MilestonesController do end context 'when requesting a redirected path' do - let(:redirect_route) { group.redirect_routes.create(path: 'old-path') } + let(:redirect_route) { group.redirect_routes.create!(path: 'old-path') } it 'redirects to the canonical path' do get :merge_requests, params: { group_id: redirect_route.path, id: title } @@ -350,7 +350,7 @@ RSpec.describe Groups::MilestonesController do end context 'when the old group path is a substring of the scheme or host' do - let(:redirect_route) { group.redirect_routes.create(path: 'http') } + let(:redirect_route) { group.redirect_routes.create!(path: 'http') } it 'does not modify the requested host' do get :merge_requests, params: { group_id: redirect_route.path, id: title } @@ -362,7 +362,7 @@ RSpec.describe Groups::MilestonesController do context 'when the old group path is substring of groups' do # I.e. /groups/oups should not become /grfoo/oups - let(:redirect_route) { group.redirect_routes.create(path: 'oups') } + let(:redirect_route) { group.redirect_routes.create!(path: 'oups') } it 'does not modify the /groups part of the path' do get :merge_requests, params: { group_id: redirect_route.path, id: title } @@ -374,7 +374,7 @@ RSpec.describe Groups::MilestonesController do context 'when the old group path is substring of groups plus the new path' do # I.e. /groups/oups/oup should not become /grfoos - let(:redirect_route) { group.redirect_routes.create(path: 'oups/oup') } + let(:redirect_route) { group.redirect_routes.create!(path: 'oups/oup') } it 'does not modify the /groups part of the path' do get :merge_requests, params: { group_id: redirect_route.path, id: title } @@ -411,7 +411,7 @@ RSpec.describe Groups::MilestonesController do end context 'when requesting a redirected path' do - let(:redirect_route) { group.redirect_routes.create(path: 'old-path') } + let(:redirect_route) { group.redirect_routes.create!(path: 'old-path') } it 'returns not found' do post :create, diff --git a/spec/controllers/groups/runners_controller_spec.rb b/spec/controllers/groups/runners_controller_spec.rb index 91ff0a53ec7..d6da9a4e8d0 100644 --- a/spec/controllers/groups/runners_controller_spec.rb +++ b/spec/controllers/groups/runners_controller_spec.rb @@ -220,7 +220,7 @@ RSpec.describe Groups::RunnersController do end it 'marks the runner as active, ticks the queue, and redirects' do - runner.update(active: false) + runner.update!(active: false) expect do post :resume, params: params @@ -231,7 +231,7 @@ RSpec.describe Groups::RunnersController do end it 'marks the project runner as active, ticks the queue, and redirects' do - runner_project.update(active: false) + runner_project.update!(active: false) expect do post :resume, params: params_runner_project @@ -248,7 +248,7 @@ RSpec.describe Groups::RunnersController do end it 'responds 404 and does not activate the runner' do - runner.update(active: false) + runner.update!(active: false) expect do post :resume, params: params @@ -259,7 +259,7 @@ RSpec.describe Groups::RunnersController do end it 'responds 404 and does not activate the project runner' do - runner_project.update(active: false) + runner_project.update!(active: false) expect do post :resume, params: params_runner_project @@ -278,7 +278,7 @@ RSpec.describe Groups::RunnersController do end it 'marks the runner as inactive, ticks the queue, and redirects' do - runner.update(active: true) + runner.update!(active: true) expect do post :pause, params: params @@ -289,7 +289,7 @@ RSpec.describe Groups::RunnersController do end it 'marks the project runner as inactive, ticks the queue, and redirects' do - runner_project.update(active: true) + runner_project.update!(active: true) expect do post :pause, params: params_runner_project @@ -306,7 +306,7 @@ RSpec.describe Groups::RunnersController do end it 'responds 404 and does not update the runner or queue' do - runner.update(active: true) + runner.update!(active: true) expect do post :pause, params: params @@ -317,7 +317,7 @@ RSpec.describe Groups::RunnersController do end it 'responds 404 and does not update the project runner or queue' do - runner_project.update(active: true) + runner_project.update!(active: true) expect do post :pause, params: params diff --git a/spec/controllers/groups/uploads_controller_spec.rb b/spec/controllers/groups/uploads_controller_spec.rb index ea6a5ce8841..7dafb813545 100644 --- a/spec/controllers/groups/uploads_controller_spec.rb +++ b/spec/controllers/groups/uploads_controller_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Groups::UploadsController do let!(:upload) { create(:upload, :issuable_upload, :with_file, model: model) } let(:group) { model } let(:old_path) { group.to_param + 'old' } - let!(:redirect_route) { model.redirect_routes.create(path: old_path) } + let!(:redirect_route) { model.redirect_routes.create!(path: old_path) } let(:upload_path) { File.basename(upload.path) } it 'redirects to a file with the proper extension' do diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 931f08e17ce..988b11dad1c 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -636,7 +636,7 @@ RSpec.describe GroupsController, factory_default: :keep do end context 'when requesting a redirected path' do - let(:redirect_route) { group.redirect_routes.create(path: 'old-path') } + let(:redirect_route) { group.redirect_routes.create!(path: 'old-path') } let(:group_full_path) { redirect_route.path } it 'redirects to the canonical path' do @@ -645,7 +645,7 @@ RSpec.describe GroupsController, factory_default: :keep do end context 'when the old group path is a substring of the scheme or host' do - let(:redirect_route) { group.redirect_routes.create(path: 'http') } + let(:redirect_route) { group.redirect_routes.create!(path: 'http') } it 'does not modify the requested host' do expect(response).to redirect_to(group) @@ -655,7 +655,7 @@ RSpec.describe GroupsController, factory_default: :keep do context 'when the old group path is substring of groups' do # I.e. /groups/oups should not become /grfoo/oups - let(:redirect_route) { group.redirect_routes.create(path: 'oups') } + let(:redirect_route) { group.redirect_routes.create!(path: 'oups') } it 'does not modify the /groups part of the path' do expect(response).to redirect_to(group) @@ -707,7 +707,7 @@ RSpec.describe GroupsController, factory_default: :keep do end context 'when requesting a redirected path' do - let(:redirect_route) { group.redirect_routes.create(path: 'old-path') } + let(:redirect_route) { group.redirect_routes.create!(path: 'old-path') } it 'redirects to the canonical path' do get :issues, params: { id: redirect_route.path } @@ -717,7 +717,7 @@ RSpec.describe GroupsController, factory_default: :keep do end context 'when the old group path is a substring of the scheme or host' do - let(:redirect_route) { group.redirect_routes.create(path: 'http') } + let(:redirect_route) { group.redirect_routes.create!(path: 'http') } it 'does not modify the requested host' do get :issues, params: { id: redirect_route.path } @@ -729,7 +729,7 @@ RSpec.describe GroupsController, factory_default: :keep do context 'when the old group path is substring of groups' do # I.e. /groups/oups should not become /grfoo/oups - let(:redirect_route) { group.redirect_routes.create(path: 'oups') } + let(:redirect_route) { group.redirect_routes.create!(path: 'oups') } it 'does not modify the /groups part of the path' do get :issues, params: { id: redirect_route.path } @@ -741,7 +741,7 @@ RSpec.describe GroupsController, factory_default: :keep do context 'when the old group path is substring of groups plus the new path' do # I.e. /groups/oups/oup should not become /grfoos - let(:redirect_route) { group.redirect_routes.create(path: 'oups/oup') } + let(:redirect_route) { group.redirect_routes.create!(path: 'oups/oup') } it 'does not modify the /groups part of the path' do get :issues, params: { id: redirect_route.path } @@ -769,7 +769,7 @@ RSpec.describe GroupsController, factory_default: :keep do end context 'when requesting a redirected path' do - let(:redirect_route) { group.redirect_routes.create(path: 'old-path') } + let(:redirect_route) { group.redirect_routes.create!(path: 'old-path') } it 'returns not found' do post :update, params: { id: redirect_route.path, group: { path: 'new_path' } } @@ -795,7 +795,7 @@ RSpec.describe GroupsController, factory_default: :keep do end context 'when requesting a redirected path' do - let(:redirect_route) { group.redirect_routes.create(path: 'old-path') } + let(:redirect_route) { group.redirect_routes.create!(path: 'old-path') } it 'returns not found' do delete :destroy, params: { id: redirect_route.path }