Commit 675f7e21 authored by Rajendra Kadam's avatar Rajendra Kadam

Fix Rails/SaveBang offenses for spec/support/shared_examples/services/*

Fix Rais/SaveBang cop for ee/spec/support/shared_examples/services/*

Add changelog for the cop fixes

Disable cop for create method in shared examples

Fix spec failure

Fix specs
parent a1c27e95
...@@ -1033,8 +1033,6 @@ Rails/SaveBang: ...@@ -1033,8 +1033,6 @@ Rails/SaveBang:
- 'ee/spec/support/shared_examples/models/member_shared_examples.rb' - 'ee/spec/support/shared_examples/models/member_shared_examples.rb'
- 'ee/spec/support/shared_examples/models/mentionable_shared_examples.rb' - 'ee/spec/support/shared_examples/models/mentionable_shared_examples.rb'
- 'ee/spec/support/shared_examples/policies/protected_environments_shared_examples.rb' - 'ee/spec/support/shared_examples/policies/protected_environments_shared_examples.rb'
- 'ee/spec/support/shared_examples/services/build_execute_shared_examples.rb'
- 'ee/spec/support/shared_examples/services/issue_epic_shared_examples.rb'
- 'ee/spec/workers/adjourned_project_deletion_worker_spec.rb' - 'ee/spec/workers/adjourned_project_deletion_worker_spec.rb'
- 'ee/spec/workers/clear_shared_runners_minutes_worker_spec.rb' - 'ee/spec/workers/clear_shared_runners_minutes_worker_spec.rb'
- 'ee/spec/workers/create_github_webhook_worker_spec.rb' - 'ee/spec/workers/create_github_webhook_worker_spec.rb'
...@@ -1488,9 +1486,6 @@ Rails/SaveBang: ...@@ -1488,9 +1486,6 @@ Rails/SaveBang:
- 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb' - 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb'
- 'spec/support/shared_examples/quick_actions/merge_request/merge_quick_action_shared_examples.rb' - 'spec/support/shared_examples/quick_actions/merge_request/merge_quick_action_shared_examples.rb'
- 'spec/support/shared_examples/serializers/note_entity_shared_examples.rb' - 'spec/support/shared_examples/serializers/note_entity_shared_examples.rb'
- 'spec/support/shared_examples/services/common_system_notes_shared_examples.rb'
- 'spec/support/shared_examples/services/issuable_shared_examples.rb'
- 'spec/support/shared_examples/services/wiki_pages/destroy_service_shared_examples.rb'
- 'spec/tasks/gitlab/web_hook_rake_spec.rb' - 'spec/tasks/gitlab/web_hook_rake_spec.rb'
- 'spec/uploaders/file_uploader_spec.rb' - 'spec/uploaders/file_uploader_spec.rb'
- 'spec/uploaders/object_storage_spec.rb' - 'spec/uploaders/object_storage_spec.rb'
---
title: Refactor spec/support/shared_examples/services/* and ee/spec/support/shared_examples/services/* to fix Rails/SaveBang Cop
merge_request: 39538
author: Rajendra Kadam
type: fixed
...@@ -29,7 +29,7 @@ RSpec.shared_examples 'restricts access to protected environments' do |developer ...@@ -29,7 +29,7 @@ RSpec.shared_examples 'restricts access to protected environments' do |developer
context 'when user has access to the environment' do context 'when user has access to the environment' do
before do before do
protected_environment.deploy_access_levels.create(user: user) protected_environment.deploy_access_levels.create!(user: user)
end end
it 'enqueues the build' do it 'enqueues the build' do
......
...@@ -38,7 +38,7 @@ RSpec.shared_examples 'issue with epic_id parameter' do ...@@ -38,7 +38,7 @@ RSpec.shared_examples 'issue with epic_id parameter' do
context 'when user can add issues to the epic' do context 'when user can add issues to the epic' do
before do before do
group.add_owner(user) group.add_maintainer(user)
project.add_maintainer(user) project.add_maintainer(user)
end end
...@@ -57,7 +57,7 @@ RSpec.shared_examples 'issue with epic_id parameter' do ...@@ -57,7 +57,7 @@ RSpec.shared_examples 'issue with epic_id parameter' do
before do before do
subgroup = create(:group, parent: group) subgroup = create(:group, parent: group)
create(:epic, group: subgroup) create(:epic, group: subgroup)
project.update(group: subgroup) project.update!(group: subgroup)
end end
it 'creates epic issue link' do it 'creates epic issue link' do
......
...@@ -5,7 +5,7 @@ RSpec.shared_examples 'system note creation' do |update_params, note_text| ...@@ -5,7 +5,7 @@ RSpec.shared_examples 'system note creation' do |update_params, note_text|
before do before do
issuable.assign_attributes(update_params) issuable.assign_attributes(update_params)
issuable.save issuable.save!
end end
it 'creates 1 system note with the correct content' do it 'creates 1 system note with the correct content' do
......
...@@ -19,7 +19,7 @@ RSpec.shared_examples 'system notes for milestones' do ...@@ -19,7 +19,7 @@ RSpec.shared_examples 'system notes for milestones' do
let(:group_milestone) { create(:milestone, group: group) } let(:group_milestone) { create(:milestone, group: group) }
before do before do
project.update(namespace: group) project.update!(namespace: group)
create(:group_member, group: group, user: user) create(:group_member, group: group, user: user)
end end
......
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'WikiPages::DestroyService#execute' do |container_type| RSpec.shared_examples 'WikiPages::DestroyService#execute' do |container_type|
let(:container) { create(container_type) } let(:container) { create(container_type) } # rubocop:disable Rails/SaveBang
let(:user) { create(:user) } let(:user) { create(:user) }
let(:page) { create(:wiki_page) } let(:page) { create(:wiki_page) }
......
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