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: ...@@ -743,12 +743,6 @@ Style/SymbolProc:
# Configuration parameters: AllowImplicitReturn, AllowedReceivers. # Configuration parameters: AllowImplicitReturn, AllowedReceivers.
Rails/SaveBang: Rails/SaveBang:
Exclude: 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/environments_controller_spec.rb'
- 'ee/spec/controllers/projects/issues_controller_spec.rb' - 'ee/spec/controllers/projects/issues_controller_spec.rb'
- 'ee/spec/controllers/projects/merge_requests/creations_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 ...@@ -8,7 +8,7 @@ RSpec.describe SentNotificationsController do
context 'Unsubscribing from an epic' do context 'Unsubscribing from an epic' do
let(:epic) do let(:epic) do
create(:epic, author: user) do |epic| 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
end end
let(:sent_notification) { create(:sent_notification, project: nil, noteable: epic, recipient: user) } let(:sent_notification) { create(:sent_notification, project: nil, noteable: epic, recipient: user) }
......
...@@ -55,7 +55,7 @@ RSpec.describe Groups::EpicIssuesController do ...@@ -55,7 +55,7 @@ RSpec.describe Groups::EpicIssuesController do
context 'when user does not have access to epic' do context 'when user does not have access to epic' do
it 'returns 404 status' do it 'returns 404 status' do
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE) group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
subject subject
......
...@@ -31,7 +31,7 @@ RSpec.describe Groups::EpicLinksController do ...@@ -31,7 +31,7 @@ RSpec.describe Groups::EpicLinksController do
let(:features_when_forbidden) { { epics: false } } let(:features_when_forbidden) { { epics: false } }
before do before do
epic1.update(parent: parent_epic) epic1.update!(parent: parent_epic)
end end
subject { get :index, params: { group_id: group, epic_id: parent_epic.to_param } } subject { get :index, params: { group_id: group, epic_id: parent_epic.to_param } }
...@@ -60,7 +60,7 @@ RSpec.describe Groups::EpicLinksController do ...@@ -60,7 +60,7 @@ RSpec.describe Groups::EpicLinksController do
context 'when user does not have access to epic' do context 'when user does not have access to epic' do
it 'returns 404 status' do it 'returns 404 status' do
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE) group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
subject subject
...@@ -118,8 +118,8 @@ RSpec.describe Groups::EpicLinksController do ...@@ -118,8 +118,8 @@ RSpec.describe Groups::EpicLinksController do
describe 'PUT #update' do describe 'PUT #update' do
before do before do
epic1.update(parent: parent_epic) epic1.update!(parent: parent_epic)
epic2.update(parent: parent_epic) epic2.update!(parent: parent_epic)
end end
let(:move_before_epic) { epic2 } let(:move_before_epic) { epic2 }
...@@ -173,7 +173,7 @@ RSpec.describe Groups::EpicLinksController do ...@@ -173,7 +173,7 @@ RSpec.describe Groups::EpicLinksController do
describe 'DELETE #destroy' do describe 'DELETE #destroy' do
before do before do
epic1.update(parent: parent_epic) epic1.update!(parent: parent_epic)
end end
let(:features_when_forbidden) { { epics: false } } let(:features_when_forbidden) { { epics: false } }
......
...@@ -83,7 +83,7 @@ RSpec.describe Groups::EpicsController do ...@@ -83,7 +83,7 @@ RSpec.describe Groups::EpicsController do
context 'when epics_sort is present' do context 'when epics_sort is present' do
it 'update epics_sort with current value' 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' } get :index, params: { group_id: group, sort: 'start_date_asc' }
......
...@@ -49,7 +49,7 @@ RSpec.describe Groups::RoadmapController do ...@@ -49,7 +49,7 @@ RSpec.describe Groups::RoadmapController do
end end
it 'defaults to sort_value_start_date_soon' do 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 } get :show, params: { group_id: group }
...@@ -59,7 +59,7 @@ RSpec.describe Groups::RoadmapController do ...@@ -59,7 +59,7 @@ RSpec.describe Groups::RoadmapController do
context 'when roadmaps_sort is present' do context 'when roadmaps_sort is present' do
it 'update roadmaps_sort with current value' 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' } get :show, params: { group_id: group, sort: 'start_date_asc' }
......
...@@ -92,7 +92,7 @@ RSpec.describe Groups::SsoController do ...@@ -92,7 +92,7 @@ RSpec.describe Groups::SsoController do
end end
context 'when group has moved' do 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 it 'redirects to new location' do
get :saml, params: { group_id: redirect_route.path } get :saml, params: { group_id: redirect_route.path }
...@@ -193,7 +193,7 @@ RSpec.describe Groups::SsoController do ...@@ -193,7 +193,7 @@ RSpec.describe Groups::SsoController do
context 'and group managed accounts enforcing is disabled' do context 'and group managed accounts enforcing is disabled' do
before do before do
saml_provider.update(enforced_group_managed_accounts: false) saml_provider.update!(enforced_group_managed_accounts: false)
end end
it 'renders 404' do 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