Commit dc8e6a8a authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rails-save-bang-ee-spec-workers' into 'master'

Fix Rails/SaveBang offenses in ee/spec/workers

See merge request gitlab-org/gitlab!58070
parents 24be4573 9ec9fb6a
......@@ -132,17 +132,6 @@ Rails/SaveBang:
- 'ee/spec/support/shared_examples/graphql/geo/geo_registries_resolver_shared_examples.rb'
- 'ee/spec/support/shared_examples/lib/analytics/common_merge_request_metrics_refresh_shared_examples.rb'
- 'ee/spec/support/shared_examples/policies/protected_environments_shared_examples.rb'
- 'ee/spec/workers/adjourned_project_deletion_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/elastic_namespace_rollout_worker_spec.rb'
- 'ee/spec/workers/geo/container_repository_sync_dispatch_worker_spec.rb'
- 'ee/spec/workers/geo/file_download_dispatch_worker_spec.rb'
- 'ee/spec/workers/geo/prune_event_log_worker_spec.rb'
- 'ee/spec/workers/geo/registry_sync_worker_spec.rb'
- 'ee/spec/workers/geo/repository_shard_sync_worker_spec.rb'
- 'ee/spec/workers/repository_import_worker_spec.rb'
- 'ee/spec/workers/update_all_mirrors_worker_spec.rb'
- 'qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb'
- 'qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_lfs_over_http_spec.rb'
- 'qa/qa/specs/features/ee/browser_ui/3_create/repository/pull_mirroring_over_http_spec.rb'
......
---
title: Fix Rails/SaveBang rubocop offenses in ee/spec/workers
merge_request: 58070
author: Abdul Wadood @abdulwd
type: fixed
......@@ -18,7 +18,7 @@ RSpec.describe AdjournedProjectDeletionWorker do
end
it 'stops execution if user was deleted' do
project.update(deleting_user: nil)
project.update!(deleting_user: nil)
expect(Projects::DestroyService).not_to receive(:new)
......
......@@ -24,7 +24,7 @@ RSpec.describe ClearSharedRunnersMinutesWorker do
let(:statistics) { project.statistics }
before do
statistics.update(shared_runners_seconds: 100)
statistics.update!(shared_runners_seconds: 100)
end
it 'clears counters' do
......
......@@ -19,7 +19,7 @@ RSpec.describe CreateGithubWebhookWorker do
describe '#perform' do
before do
project.ensure_external_webhook_token
project.save
project.save!
end
it 'creates the webhook' do
......
......@@ -10,7 +10,7 @@ RSpec.describe ElasticNamespaceRolloutWorker do
Plan::PAID_HOSTED_PLANS.each do |plan|
plan_factory = "#{plan}_plan"
let_it_be(plan_factory) { create(plan_factory) }
let_it_be(plan_factory) { create(plan_factory) } # rubocop:disable Rails/SaveBang
end
before_all do
......
......@@ -38,7 +38,7 @@ RSpec.describe Geo::FileDownloadDispatchWorker, :geo, :use_sql_query_cache_for_t
create(:lfs_object, :with_file)
secondary.enabled = false
secondary.save
secondary.save!
expect(Geo::FileDownloadWorker).not_to receive(:perform_async)
......@@ -76,7 +76,7 @@ RSpec.describe Geo::FileDownloadDispatchWorker, :geo, :use_sql_query_cache_for_t
expect(Geo::FileDownloadWorker).to receive(:perform_async).with('lfs', lfs_object_1.id).once do
Thread.new do
# Rails will invalidate the query cache if the update happens in the same thread
Geo::LfsObjectRegistry.update(success: true)
Geo::LfsObjectRegistry.update(success: true) # rubocop:disable Rails/SaveBang
end
end
......
......@@ -63,7 +63,7 @@ RSpec.describe Geo::PruneEventLogWorker, :geo do
context 'no Geo secondary nodes' do
before do
secondary.destroy
secondary.destroy!
end
it 'deletes everything from the Geo event log' do
......@@ -76,7 +76,7 @@ RSpec.describe Geo::PruneEventLogWorker, :geo do
context 'no Geo primary node' do
before do
primary.destroy
primary.destroy!
end
it 'deletes everything from the Geo event log' do
......
......@@ -74,7 +74,7 @@ RSpec.describe Geo::RegistrySyncWorker, :geo, :use_sql_query_cache_for_tracking_
expect(Geo::EventWorker).to receive(:perform_async).with('package_file', :created, { model_record_id: package_file_1.package_file.id }).once do
Thread.new do
# Rails will invalidate the query cache if the update happens in the same thread
Geo::PackageFileRegistry.update(state: Geo::PackageFileRegistry::STATE_VALUES[:synced])
Geo::PackageFileRegistry.update(state: Geo::PackageFileRegistry::STATE_VALUES[:synced]) # rubocop:disable Rails/SaveBang
end
end
......
......@@ -146,8 +146,8 @@ RSpec.describe Geo::RepositoryShardSyncWorker, :geo, :clean_gitlab_redis_cache,
abandoned_project.update_column(:last_repository_updated_at, 1.year.ago)
# Neither of these are needed for this spec
project_2.destroy
project_1.destroy
project_2.destroy!
project_1.destroy!
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:db_retrieve_batch_size).and_return(2) # Must be >1 because of the Geo::BaseSchedulerWorker#interleave
......@@ -191,8 +191,8 @@ RSpec.describe Geo::RepositoryShardSyncWorker, :geo, :clean_gitlab_redis_cache,
before do
# Neither of these are needed for this spec
project_2.destroy
project_1.destroy
project_2.destroy!
project_1.destroy!
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:db_retrieve_batch_size).and_return(2) # Must be >1 because of the Geo::BaseSchedulerWorker#interleave
......
......@@ -9,8 +9,8 @@ RSpec.describe RepositoryImportWorker do
stub_licensed_features(custom_project_templates: true)
error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
project.update(import_type: 'gitlab_custom_project_template')
project.import_state.update(jid: '123')
project.update!(import_type: 'gitlab_custom_project_template')
project.import_state.update!(jid: '123')
expect_next_instance_of(Projects::ImportService) do |service|
expect(service).to receive(:execute).and_return({ status: :error, message: error })
end
......
......@@ -160,7 +160,7 @@ RSpec.describe UpdateAllMirrorsWorker do
context 'when the instance checks namespace plans' do
def scheduled_mirror(at:, licensed:, public: false, subgroup: nil)
group_args = [:group, :public, subgroup && :nested].compact
namespace = create(*group_args)
namespace = create(*group_args) # rubocop:disable Rails/SaveBang
project = create(:project, :public, :mirror, namespace: namespace)
create(:gitlab_subscription, (licensed ? :bronze : :free), namespace: namespace.root_ancestor)
......
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