Commit 2fbd4acc authored by Jarka Košanová's avatar Jarka Košanová

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

Fix Rails/SaveBang offenses for spec/workers/*

See merge request gitlab-org/gitlab!38399
parents 56a10a59 941e2a7b
......@@ -1910,20 +1910,3 @@ Rails/SaveBang:
- 'spec/views/projects/imports/new.html.haml_spec.rb'
- 'spec/views/projects/merge_requests/show.html.haml_spec.rb'
- 'spec/views/shared/_label_row.html.haml_spec.rb'
- 'spec/workers/concerns/project_export_options_spec.rb'
- 'spec/workers/gitlab/import/stuck_project_import_jobs_worker_spec.rb'
- 'spec/workers/gitlab/jira_import/stuck_jira_import_jobs_worker_spec.rb'
- 'spec/workers/migrate_external_diffs_worker_spec.rb'
- 'spec/workers/namespaceless_project_destroy_worker_spec.rb'
- 'spec/workers/namespaces/root_statistics_worker_spec.rb'
- 'spec/workers/pages_domain_verification_worker_spec.rb'
- 'spec/workers/process_commit_worker_spec.rb'
- 'spec/workers/propagate_integration_worker_spec.rb'
- 'spec/workers/propagate_service_template_worker_spec.rb'
- 'spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb'
- 'spec/workers/repository_check/single_repository_worker_spec.rb'
- 'spec/workers/repository_cleanup_worker_spec.rb'
- 'spec/workers/repository_import_worker_spec.rb'
- 'spec/workers/repository_update_remote_mirror_worker_spec.rb'
- 'spec/workers/stuck_ci_jobs_worker_spec.rb'
- 'spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb'
---
title: Refactor spec/workers/* to fix SaveBang Cop
merge_request: 38399
author: Rajendra Kadam
type: fixed
......@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Import::StuckProjectImportJobsWorker do
let(:import_state) { create(:project, :import_scheduled).import_state }
before do
import_state.update(jid: '123')
import_state.update!(jid: '123')
end
end
end
......@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Import::StuckProjectImportJobsWorker do
let(:import_state) { create(:project, :import_started).import_state }
before do
import_state.update(jid: '123')
import_state.update!(jid: '123')
end
end
end
......
......@@ -12,7 +12,7 @@ RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do
let(:import_state) { create(:jira_import_state, :scheduled, project: project) }
before do
import_state.update(jid: '123')
import_state.update!(jid: '123')
end
end
end
......@@ -22,7 +22,7 @@ RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do
let(:import_state) { create(:jira_import_state, :started, project: project) }
before do
import_state.update(jid: '123')
import_state.update!(jid: '123')
end
end
end
......
......@@ -17,7 +17,7 @@ RSpec.describe MigrateExternalDiffsWorker do
end
it 'does nothing if the diff is missing' do
diff.destroy
diff.destroy!
worker.perform(diff.id)
end
......
......@@ -60,7 +60,7 @@ RSpec.describe NamespacelessProjectDestroyWorker do
let!(:parent_project) { create(:project) }
let(:project) do
namespaceless_project = fork_project(parent_project)
namespaceless_project.save
namespaceless_project.save!
namespaceless_project
end
......
......@@ -51,7 +51,7 @@ RSpec.describe Namespaces::RootStatisticsWorker, '#perform' do
context 'with no namespace' do
before do
group.destroy
group.destroy!
end
it 'does not execute the refresher service' do
......@@ -64,7 +64,7 @@ RSpec.describe Namespaces::RootStatisticsWorker, '#perform' do
context 'with a namespace with no aggregation scheduled' do
before do
group.aggregation_schedule.destroy
group.aggregation_schedule.destroy!
end
it 'does not execute the refresher service' do
......
......@@ -16,7 +16,7 @@ RSpec.describe PagesDomainVerificationWorker do
end
it 'does nothing for a non-existent domain' do
domain.destroy
domain.destroy!
expect(VerifyPagesDomainService).not_to receive(:new)
......
......@@ -160,7 +160,7 @@ RSpec.describe ProcessCommitWorker do
context 'when issue has first_mentioned_in_commit_at earlier than given committed_date' do
before do
issue.metrics.update(first_mentioned_in_commit_at: commit.committed_date - 1.day)
issue.metrics.update!(first_mentioned_in_commit_at: commit.committed_date - 1.day)
end
it "doesn't update issue metrics" do
......@@ -170,7 +170,7 @@ RSpec.describe ProcessCommitWorker do
context 'when issue has first_mentioned_in_commit_at later than given committed_date' do
before do
issue.metrics.update(first_mentioned_in_commit_at: commit.committed_date + 1.day)
issue.metrics.update!(first_mentioned_in_commit_at: commit.committed_date + 1.day)
end
it "doesn't update issue metrics" do
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe PropagateIntegrationWorker do
describe '#perform' do
let(:integration) do
PushoverService.create(
PushoverService.create!(
template: true,
active: true,
device: 'MyDevice',
......
......@@ -7,7 +7,7 @@ RSpec.describe PropagateServiceTemplateWorker do
describe '#perform' do
it 'calls the propagate service with the template' do
template = PushoverService.create(
template = PushoverService.create!(
template: true,
active: true,
properties: {
......
......@@ -46,7 +46,7 @@ RSpec.describe RemoveUnreferencedLfsObjectsWorker do
end
it 'removes unreferenced lfs objects after project removal' do
project1.destroy
project1.destroy!
worker.perform
......
......@@ -86,7 +86,7 @@ RSpec.describe RepositoryCheck::SingleRepositoryWorker do
end
def create_push_event(project)
project.events.create(action: :pushed, author_id: create(:user).id)
project.events.create!(action: :pushed, author_id: create(:user).id)
end
def break_wiki(project)
......
......@@ -25,13 +25,13 @@ RSpec.describe RepositoryCleanupWorker do
end
it 'raises an error if the project cannot be found' do
project.destroy
project.destroy!
expect { worker.perform(project.id, user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
it 'raises an error if the user cannot be found' do
user.destroy
user.destroy!
expect { worker.perform(project.id, user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
......
......@@ -49,7 +49,7 @@ RSpec.describe RepositoryImportWorker do
it 'hide the credentials that were used in the import URL' do
error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
import_state.update(jid: '123')
import_state.update!(jid: '123')
expect_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :error, message: error })
end
......@@ -63,8 +63,8 @@ RSpec.describe RepositoryImportWorker do
it 'updates the error on Import/Export' do
error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
project.update(import_type: 'gitlab_project')
import_state.update(jid: '123')
project.update!(import_type: 'gitlab_project')
import_state.update!(jid: '123')
expect_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :error, message: error })
end
......
......@@ -26,7 +26,7 @@ RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_st
end
it 'does not do anything if the mirror was already updated' do
remote_mirror.update(last_update_started_at: Time.current, update_status: :finished)
remote_mirror.update!(last_update_started_at: Time.current, update_status: :finished)
expect(Projects::UpdateRemoteMirrorService).not_to receive(:new)
......
......@@ -132,7 +132,7 @@ RSpec.describe StuckCiJobsWorker do
let(:updated_at) { 2.days.ago }
before do
job.project.update(pending_delete: true)
job.project.update!(pending_delete: true)
end
it 'does drop job' do
......
......@@ -29,7 +29,7 @@ RSpec.describe UpdateHeadPipelineForMergeRequestWorker do
context 'when merge request sha does not equal pipeline sha' do
before do
merge_request.merge_request_diff.update(head_commit_sha: Digest::SHA1.hexdigest(SecureRandom.hex))
merge_request.merge_request_diff.update!(head_commit_sha: Digest::SHA1.hexdigest(SecureRandom.hex))
end
it 'does not update head pipeline' 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