Commit b86fc7a5 authored by Peter Leitzen's avatar Peter Leitzen

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

Fix Rails/SaveBang RuboCop offenses for all `spec/helpers/*` and `ee/spec/helpers/*`

See merge request gitlab-org/gitlab!37446
parents 361cf070 a21167da
......@@ -1273,9 +1273,6 @@ Rails/SaveBang:
- 'ee/spec/finders/security/vulnerabilities_finder_spec.rb'
- 'ee/spec/frontend/fixtures/analytics.rb'
- 'ee/spec/graphql/resolvers/vulnerabilities_resolver_spec.rb'
- 'ee/spec/helpers/application_helper_spec.rb'
- 'ee/spec/helpers/ee/dashboard_helper_spec.rb'
- 'ee/spec/helpers/ee/issues_helper_spec.rb'
- 'ee/spec/initializers/fog_google_https_private_urls_spec.rb'
- 'ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb'
- 'ee/spec/lib/ee/gitlab/auth/ldap/sync/group_spec.rb'
......@@ -1571,16 +1568,6 @@ Rails/SaveBang:
- 'spec/graphql/mutations/merge_requests/set_locked_spec.rb'
- 'spec/graphql/mutations/merge_requests/set_wip_spec.rb'
- 'spec/graphql/resolvers/boards_resolver_spec.rb'
- 'spec/helpers/appearances_helper_spec.rb'
- 'spec/helpers/auto_devops_helper_spec.rb'
- 'spec/helpers/issuables_helper_spec.rb'
- 'spec/helpers/issues_helper_spec.rb'
- 'spec/helpers/members_helper_spec.rb'
- 'spec/helpers/notes_helper_spec.rb'
- 'spec/helpers/profiles_helper_spec.rb'
- 'spec/helpers/projects/alert_management_helper_spec.rb'
- 'spec/helpers/projects_helper_spec.rb'
- 'spec/helpers/visibility_level_helper_spec.rb'
- 'spec/initializers/active_record_locking_spec.rb'
- 'spec/initializers/fog_google_https_private_urls_spec.rb'
- 'spec/lib/after_commit_queue_spec.rb'
......
---
title: Refactor spec/helpers and ee/spec/helpers to fix SaveBang Cop
merge_request: 37446
author: Rajendra Kadam
type: fixed
......@@ -125,7 +125,7 @@ RSpec.describe ApplicationHelper do
end
it 'returns paths for autocomplete_sources_controller including epics for group projects' do
object.update(group: create(:group))
object.update!(group: create(:group))
expect_autocomplete_data_sources(object, noteable_type, [:members, :issues, :mergeRequests, :labels, :milestones, :commands, :snippets, :epics])
end
......
......@@ -185,7 +185,7 @@ RSpec.describe DashboardHelper, type: :helper do
end
with_them do
let(:user) { create(current_user) }
let(:user) { create(current_user) } # rubocop:disable Rails/SaveBang
let(:license) { has_license && create(:license) }
subject { helper.has_start_trial? }
......
......@@ -13,7 +13,7 @@ RSpec.describe EE::IssuesHelper do
context 'with linked issue' do
context 'with promoted issue' do
before do
issue.update(promoted_to_epic: new_epic)
issue.update!(promoted_to_epic: new_epic)
end
context 'when user has permission to see new epic' do
......
......@@ -70,7 +70,7 @@ RSpec.describe AppearancesHelper do
context 'when there is a logo but no associated upload' do
before do
# Legacy attachments were not tracked in the uploads table
appearance.logo.upload.destroy
appearance.logo.upload.destroy!
appearance.reload
end
......
......@@ -128,7 +128,7 @@ RSpec.describe AutoDevopsHelper do
context 'with groups' do
before do
receiver.update(parent: parent)
receiver.update!(parent: parent)
end
context 'when auto devops is enabled on parent' do
......
......@@ -160,7 +160,7 @@ RSpec.describe IssuablesHelper do
end
before do
user.destroy
user.destroy!
end
it 'returns "Ghost user" as edited_by' do
......
......@@ -162,7 +162,7 @@ RSpec.describe IssuesHelper do
context 'with linked issue' do
context 'with moved issue' do
before do
issue.update(moved_to: new_issue)
issue.update!(moved_to: new_issue)
end
context 'when user has permission to see new issue' do
......@@ -181,7 +181,7 @@ RSpec.describe IssuesHelper do
context 'with duplicated issue' do
before do
issue.update(duplicated_to: new_issue)
issue.update!(duplicated_to: new_issue)
end
context 'when user has permission to see new issue' do
......@@ -203,7 +203,7 @@ RSpec.describe IssuesHelper do
let(:user) { project.owner }
before do
issue.update(moved_to: nil, duplicated_to: nil)
issue.update!(moved_to: nil, duplicated_to: nil)
end
it_behaves_like 'does not display link'
......@@ -220,7 +220,7 @@ RSpec.describe IssuesHelper do
allow(Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
old_issue.update(moved_to: new_issue)
old_issue.update!(moved_to: new_issue)
end
it 'is true when moved issue project has service desk disabled' do
......
......@@ -25,7 +25,7 @@ RSpec.describe MembersHelper do
context 'an accepted user invitation with no user associated' do
before do
group_member_invite.update(invite_email: "#{SecureRandom.hex}@example.com", invite_token: nil, user_id: nil)
group_member_invite.update_columns(invite_email: "#{SecureRandom.hex}@example.com", invite_token: nil, user_id: nil)
end
it 'logs an exception and shows orphaned status' do
......
......@@ -77,9 +77,9 @@ RSpec.describe NotesHelper do
context 'for a merge request discusion' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, importing: true) }
let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
let!(:merge_request_diff2) { merge_request.merge_request_diffs.create(head_commit_sha: nil) }
let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
let!(:merge_request_diff1) { merge_request.merge_request_diffs.create!(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
let!(:merge_request_diff2) { merge_request.merge_request_diffs.create!(head_commit_sha: nil) }
let!(:merge_request_diff3) { merge_request.merge_request_diffs.create!(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
context 'for a diff discussion' do
context 'when the discussion is active' do
......
......@@ -31,7 +31,7 @@ RSpec.describe ProfilesHelper do
end
it 'returns DB stored commit_email' do
user.update(commit_email: Gitlab::PrivateCommitEmail::TOKEN)
user.update!(commit_email: Gitlab::PrivateCommitEmail::TOKEN)
expect(helper.selected_commit_email(user)).to eq(Gitlab::PrivateCommitEmail::TOKEN)
end
......
......@@ -49,7 +49,7 @@ RSpec.describe Projects::AlertManagementHelper do
context 'when alerts service is inactive' do
it 'disables alert management' do
alerts_service.update(active: false)
alerts_service.update!(active: false)
expect(data).to include(
'alert-management-enabled' => 'false'
......
......@@ -126,7 +126,7 @@ RSpec.describe ProjectsHelper do
it "returns false if there are permissions and origin project is PRIVATE" do
allow(helper).to receive(:can?) { true }
project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
expect(helper.can_change_visibility_level?(forked_project, user)).to be_falsey
end
......@@ -134,7 +134,7 @@ RSpec.describe ProjectsHelper do
it "returns true if there are permissions and origin project is INTERNAL" do
allow(helper).to receive(:can?) { true }
project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
expect(helper.can_change_visibility_level?(forked_project, user)).to be_truthy
end
......@@ -647,7 +647,7 @@ RSpec.describe ProjectsHelper do
context 'user has a configured commit email' do
before do
confirmed_email = create(:email, :confirmed, user: user)
user.update(commit_email: confirmed_email)
user.update!(commit_email: confirmed_email)
end
it 'returns the commit email' do
......@@ -866,7 +866,7 @@ RSpec.describe ProjectsHelper do
when :developer, :maintainer
project.add_user(user, access)
when :owner
project.namespace.update(owner: user)
project.namespace.update!(owner: user)
end
end
......
......@@ -171,13 +171,14 @@ RSpec.describe VisibilityLevelHelper do
with_them do
it "provides correct visibility level for forked project" do
project.update(visibility_level: max_allowed)
project.update!(visibility_level: max_allowed)
expect(selected_visibility_level(forked_project, requested_level)).to eq(expected)
end
it "provides correct visibiility level for project in group" do
project.group.update(visibility_level: max_allowed)
it "provides correct visibility level for project in group" do
project.update!(visibility_level: max_allowed)
project.group.update!(visibility_level: max_allowed)
expect(selected_visibility_level(project, requested_level)).to eq(expected)
end
......
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