Commit 18afa810 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'rails-save-bang-2' into 'master'

Fix Rails/SaveBang RuboCop offenses for groups controllers

See merge request gitlab-org/gitlab!36853
parents 7a0fc86a cfce6cb3
......@@ -743,12 +743,6 @@ Style/SymbolProc:
# Configuration parameters: AllowImplicitReturn, AllowedReceivers.
Rails/SaveBang:
Exclude:
- 'ee/spec/controllers/ee/sent_notifications_controller_spec.rb'
- 'ee/spec/controllers/groups/epic_issues_controller_spec.rb'
- 'ee/spec/controllers/groups/epic_links_controller_spec.rb'
- 'ee/spec/controllers/groups/epics_controller_spec.rb'
- 'ee/spec/controllers/groups/roadmap_controller_spec.rb'
- 'ee/spec/controllers/groups/sso_controller_spec.rb'
- 'ee/spec/controllers/projects/environments_controller_spec.rb'
- 'ee/spec/controllers/projects/issues_controller_spec.rb'
- 'ee/spec/controllers/projects/merge_requests/creations_controller_spec.rb'
......
---
title: Refactor group controllers specs to fix SaveBang Cop
merge_request: 36853
author: Rajendra Kadam
type: fixed
......@@ -8,7 +8,7 @@ RSpec.describe SentNotificationsController do
context 'Unsubscribing from an epic' do
let(:epic) do
create(:epic, author: user) do |epic|
epic.subscriptions.create(user: user, project: nil, subscribed: true)
epic.subscriptions.create!(user: user, project: nil, subscribed: true)
end
end
let(:sent_notification) { create(:sent_notification, project: nil, noteable: epic, recipient: user) }
......
......@@ -55,7 +55,7 @@ RSpec.describe Groups::EpicIssuesController do
context 'when user does not have access to epic' do
it 'returns 404 status' do
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
subject
......
......@@ -31,7 +31,7 @@ RSpec.describe Groups::EpicLinksController do
let(:features_when_forbidden) { { epics: false } }
before do
epic1.update(parent: parent_epic)
epic1.update!(parent: parent_epic)
end
subject { get :index, params: { group_id: group, epic_id: parent_epic.to_param } }
......@@ -60,7 +60,7 @@ RSpec.describe Groups::EpicLinksController do
context 'when user does not have access to epic' do
it 'returns 404 status' do
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
subject
......@@ -118,8 +118,8 @@ RSpec.describe Groups::EpicLinksController do
describe 'PUT #update' do
before do
epic1.update(parent: parent_epic)
epic2.update(parent: parent_epic)
epic1.update!(parent: parent_epic)
epic2.update!(parent: parent_epic)
end
let(:move_before_epic) { epic2 }
......@@ -173,7 +173,7 @@ RSpec.describe Groups::EpicLinksController do
describe 'DELETE #destroy' do
before do
epic1.update(parent: parent_epic)
epic1.update!(parent: parent_epic)
end
let(:features_when_forbidden) { { epics: false } }
......
......@@ -83,7 +83,7 @@ RSpec.describe Groups::EpicsController do
context 'when epics_sort is present' do
it 'update epics_sort with current value' do
user.user_preference.update(epics_sort: 'created_desc')
user.user_preference.update!(epics_sort: 'created_desc')
get :index, params: { group_id: group, sort: 'start_date_asc' }
......
......@@ -49,7 +49,7 @@ RSpec.describe Groups::RoadmapController do
end
it 'defaults to sort_value_start_date_soon' do
user.user_preference.update(roadmaps_sort: nil)
user.user_preference.update!(roadmaps_sort: nil)
get :show, params: { group_id: group }
......@@ -59,7 +59,7 @@ RSpec.describe Groups::RoadmapController do
context 'when roadmaps_sort is present' do
it 'update roadmaps_sort with current value' do
user.user_preference.update(roadmaps_sort: 'created_desc')
user.user_preference.update!(roadmaps_sort: 'created_desc')
get :show, params: { group_id: group, sort: 'start_date_asc' }
......
......@@ -92,7 +92,7 @@ RSpec.describe Groups::SsoController do
end
context 'when group has moved' do
let(:redirect_route) { group.redirect_routes.create(path: 'old-path') }
let(:redirect_route) { group.redirect_routes.create!(path: 'old-path') }
it 'redirects to new location' do
get :saml, params: { group_id: redirect_route.path }
......@@ -193,7 +193,7 @@ RSpec.describe Groups::SsoController do
context 'and group managed accounts enforcing is disabled' do
before do
saml_provider.update(enforced_group_managed_accounts: false)
saml_provider.update!(enforced_group_managed_accounts: false)
end
it 'renders 404' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment