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: ...@@ -1910,20 +1910,3 @@ Rails/SaveBang:
- 'spec/views/projects/imports/new.html.haml_spec.rb' - 'spec/views/projects/imports/new.html.haml_spec.rb'
- 'spec/views/projects/merge_requests/show.html.haml_spec.rb' - 'spec/views/projects/merge_requests/show.html.haml_spec.rb'
- 'spec/views/shared/_label_row.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 ...@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Import::StuckProjectImportJobsWorker do
let(:import_state) { create(:project, :import_scheduled).import_state } let(:import_state) { create(:project, :import_scheduled).import_state }
before do before do
import_state.update(jid: '123') import_state.update!(jid: '123')
end end
end end
end end
...@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Import::StuckProjectImportJobsWorker do ...@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Import::StuckProjectImportJobsWorker do
let(:import_state) { create(:project, :import_started).import_state } let(:import_state) { create(:project, :import_started).import_state }
before do before do
import_state.update(jid: '123') import_state.update!(jid: '123')
end end
end end
end end
......
...@@ -12,7 +12,7 @@ RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do ...@@ -12,7 +12,7 @@ RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do
let(:import_state) { create(:jira_import_state, :scheduled, project: project) } let(:import_state) { create(:jira_import_state, :scheduled, project: project) }
before do before do
import_state.update(jid: '123') import_state.update!(jid: '123')
end end
end end
end end
...@@ -22,7 +22,7 @@ RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do ...@@ -22,7 +22,7 @@ RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do
let(:import_state) { create(:jira_import_state, :started, project: project) } let(:import_state) { create(:jira_import_state, :started, project: project) }
before do before do
import_state.update(jid: '123') import_state.update!(jid: '123')
end end
end end
end end
......
...@@ -17,7 +17,7 @@ RSpec.describe MigrateExternalDiffsWorker do ...@@ -17,7 +17,7 @@ RSpec.describe MigrateExternalDiffsWorker do
end end
it 'does nothing if the diff is missing' do it 'does nothing if the diff is missing' do
diff.destroy diff.destroy!
worker.perform(diff.id) worker.perform(diff.id)
end end
......
...@@ -60,7 +60,7 @@ RSpec.describe NamespacelessProjectDestroyWorker do ...@@ -60,7 +60,7 @@ RSpec.describe NamespacelessProjectDestroyWorker do
let!(:parent_project) { create(:project) } let!(:parent_project) { create(:project) }
let(:project) do let(:project) do
namespaceless_project = fork_project(parent_project) namespaceless_project = fork_project(parent_project)
namespaceless_project.save namespaceless_project.save!
namespaceless_project namespaceless_project
end end
......
...@@ -51,7 +51,7 @@ RSpec.describe Namespaces::RootStatisticsWorker, '#perform' do ...@@ -51,7 +51,7 @@ RSpec.describe Namespaces::RootStatisticsWorker, '#perform' do
context 'with no namespace' do context 'with no namespace' do
before do before do
group.destroy group.destroy!
end end
it 'does not execute the refresher service' do it 'does not execute the refresher service' do
...@@ -64,7 +64,7 @@ RSpec.describe Namespaces::RootStatisticsWorker, '#perform' do ...@@ -64,7 +64,7 @@ RSpec.describe Namespaces::RootStatisticsWorker, '#perform' do
context 'with a namespace with no aggregation scheduled' do context 'with a namespace with no aggregation scheduled' do
before do before do
group.aggregation_schedule.destroy group.aggregation_schedule.destroy!
end end
it 'does not execute the refresher service' do it 'does not execute the refresher service' do
......
...@@ -16,7 +16,7 @@ RSpec.describe PagesDomainVerificationWorker do ...@@ -16,7 +16,7 @@ RSpec.describe PagesDomainVerificationWorker do
end end
it 'does nothing for a non-existent domain' do it 'does nothing for a non-existent domain' do
domain.destroy domain.destroy!
expect(VerifyPagesDomainService).not_to receive(:new) expect(VerifyPagesDomainService).not_to receive(:new)
......
...@@ -160,7 +160,7 @@ RSpec.describe ProcessCommitWorker do ...@@ -160,7 +160,7 @@ RSpec.describe ProcessCommitWorker do
context 'when issue has first_mentioned_in_commit_at earlier than given committed_date' do context 'when issue has first_mentioned_in_commit_at earlier than given committed_date' do
before 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 end
it "doesn't update issue metrics" do it "doesn't update issue metrics" do
...@@ -170,7 +170,7 @@ RSpec.describe ProcessCommitWorker do ...@@ -170,7 +170,7 @@ RSpec.describe ProcessCommitWorker do
context 'when issue has first_mentioned_in_commit_at later than given committed_date' do context 'when issue has first_mentioned_in_commit_at later than given committed_date' do
before 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 end
it "doesn't update issue metrics" do it "doesn't update issue metrics" do
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe PropagateIntegrationWorker do RSpec.describe PropagateIntegrationWorker do
describe '#perform' do describe '#perform' do
let(:integration) do let(:integration) do
PushoverService.create( PushoverService.create!(
template: true, template: true,
active: true, active: true,
device: 'MyDevice', device: 'MyDevice',
......
...@@ -7,7 +7,7 @@ RSpec.describe PropagateServiceTemplateWorker do ...@@ -7,7 +7,7 @@ RSpec.describe PropagateServiceTemplateWorker do
describe '#perform' do describe '#perform' do
it 'calls the propagate service with the template' do it 'calls the propagate service with the template' do
template = PushoverService.create( template = PushoverService.create!(
template: true, template: true,
active: true, active: true,
properties: { properties: {
......
...@@ -46,7 +46,7 @@ RSpec.describe RemoveUnreferencedLfsObjectsWorker do ...@@ -46,7 +46,7 @@ RSpec.describe RemoveUnreferencedLfsObjectsWorker do
end end
it 'removes unreferenced lfs objects after project removal' do it 'removes unreferenced lfs objects after project removal' do
project1.destroy project1.destroy!
worker.perform worker.perform
......
...@@ -86,7 +86,7 @@ RSpec.describe RepositoryCheck::SingleRepositoryWorker do ...@@ -86,7 +86,7 @@ RSpec.describe RepositoryCheck::SingleRepositoryWorker do
end end
def create_push_event(project) 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 end
def break_wiki(project) def break_wiki(project)
......
...@@ -25,13 +25,13 @@ RSpec.describe RepositoryCleanupWorker do ...@@ -25,13 +25,13 @@ RSpec.describe RepositoryCleanupWorker do
end end
it 'raises an error if the project cannot be found' do 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) expect { worker.perform(project.id, user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end end
it 'raises an error if the user cannot be found' do 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) expect { worker.perform(project.id, user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end end
......
...@@ -49,7 +49,7 @@ RSpec.describe RepositoryImportWorker do ...@@ -49,7 +49,7 @@ RSpec.describe RepositoryImportWorker do
it 'hide the credentials that were used in the import URL' 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 } 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_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :error, message: error }) expect(instance).to receive(:execute).and_return({ status: :error, message: error })
end end
...@@ -63,8 +63,8 @@ RSpec.describe RepositoryImportWorker do ...@@ -63,8 +63,8 @@ RSpec.describe RepositoryImportWorker do
it 'updates the error on Import/Export' 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 } error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
project.update(import_type: 'gitlab_project') project.update!(import_type: 'gitlab_project')
import_state.update(jid: '123') import_state.update!(jid: '123')
expect_next_instance_of(Projects::ImportService) do |instance| expect_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :error, message: error }) expect(instance).to receive(:execute).and_return({ status: :error, message: error })
end end
......
...@@ -26,7 +26,7 @@ RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_st ...@@ -26,7 +26,7 @@ RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_st
end end
it 'does not do anything if the mirror was already updated' do 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) expect(Projects::UpdateRemoteMirrorService).not_to receive(:new)
......
...@@ -132,7 +132,7 @@ RSpec.describe StuckCiJobsWorker do ...@@ -132,7 +132,7 @@ RSpec.describe StuckCiJobsWorker do
let(:updated_at) { 2.days.ago } let(:updated_at) { 2.days.ago }
before do before do
job.project.update(pending_delete: true) job.project.update!(pending_delete: true)
end end
it 'does drop job' do it 'does drop job' do
......
...@@ -29,7 +29,7 @@ RSpec.describe UpdateHeadPipelineForMergeRequestWorker do ...@@ -29,7 +29,7 @@ RSpec.describe UpdateHeadPipelineForMergeRequestWorker do
context 'when merge request sha does not equal pipeline sha' do context 'when merge request sha does not equal pipeline sha' do
before 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 end
it 'does not update head pipeline' do 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