diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/rubocop/cop/scalability | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/rubocop/cop/scalability')
4 files changed, 12 insertions, 32 deletions
diff --git a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb index 6e526f7ad8f..a19ddf9dbe6 100644 --- a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb +++ b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb @@ -5,54 +5,44 @@ require 'rubocop' require_relative '../../../../rubocop/cop/scalability/bulk_perform_with_context' RSpec.describe RuboCop::Cop::Scalability::BulkPerformWithContext do - include CopHelper - subject(:cop) { described_class.new } it "adds an offense when calling bulk_perform_async" do - inspect_source(<<~CODE) + expect_offense(<<~CODE) Worker.bulk_perform_async(args) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `Worker.bulk_perform_async_with_contexts` [...] CODE - - expect(cop.offenses.size).to eq(1) end it "adds an offense when calling bulk_perform_in" do - inspect_source(<<~CODE) + expect_offense(<<~CODE) diffs.each_batch(of: BATCH_SIZE) do |relation, index| ids = relation.pluck_primary_key.map { |id| [id] } DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `Worker.bulk_perform_async_with_contexts` [...] end CODE - - expect(cop.offenses.size).to eq(1) end it "does not add an offense for migrations" do allow(cop).to receive(:in_migration?).and_return(true) - inspect_source(<<~CODE) + expect_no_offenses(<<~CODE) Worker.bulk_perform_in(args) CODE - - expect(cop.offenses.size).to eq(0) end it "does not add an offence for specs" do allow(cop).to receive(:in_spec?).and_return(true) - inspect_source(<<~CODE) + expect_no_offenses(<<~CODE) Worker.bulk_perform_in(args) CODE - - expect(cop.offenses.size).to eq(0) end it "does not add an offense for scheduling BackgroundMigrations" do - inspect_source(<<~CODE) + expect_no_offenses(<<~CODE) BackgroundMigrationWorker.bulk_perform_in(args) CODE - - expect(cop.offenses.size).to eq(0) end end diff --git a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb index 4699e06e9cf..11b2b82d2f5 100644 --- a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb +++ b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb @@ -5,18 +5,15 @@ require 'rubocop' require_relative '../../../../rubocop/cop/scalability/cron_worker_context' RSpec.describe RuboCop::Cop::Scalability::CronWorkerContext do - include CopHelper - subject(:cop) { described_class.new } it 'adds an offense when including CronjobQueue' do - inspect_source(<<~CODE) + expect_offense(<<~CODE) class SomeWorker include CronjobQueue + ^^^^^^^^^^^^ Manually define an ApplicationContext for cronjob-workers.[...] end CODE - - expect(cop.offenses.size).to eq(1) end it 'does not add offenses for other workers' do diff --git a/spec/rubocop/cop/scalability/file_uploads_spec.rb b/spec/rubocop/cop/scalability/file_uploads_spec.rb index 78ff7fea55c..bda5c056b03 100644 --- a/spec/rubocop/cop/scalability/file_uploads_spec.rb +++ b/spec/rubocop/cop/scalability/file_uploads_spec.rb @@ -5,8 +5,6 @@ require 'rubocop' require_relative '../../../../rubocop/cop/scalability/file_uploads' RSpec.describe RuboCop::Cop::Scalability::FileUploads do - include CopHelper - subject(:cop) { described_class.new } let(:message) { 'Do not upload files without workhorse acceleration. Please refer to https://docs.gitlab.com/ee/development/uploads.html' } diff --git a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb index 666122a9de4..729f2613697 100644 --- a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb +++ b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb @@ -5,8 +5,6 @@ require 'rubocop' require_relative '../../../../rubocop/cop/scalability/idempotent_worker' RSpec.describe RuboCop::Cop::Scalability::IdempotentWorker do - include CopHelper - subject(:cop) { described_class.new } before do @@ -16,21 +14,18 @@ RSpec.describe RuboCop::Cop::Scalability::IdempotentWorker do end it 'adds an offense when not defining idempotent method' do - inspect_source(<<~CODE) + expect_offense(<<~CODE) class SomeWorker + ^^^^^^^^^^^^^^^^ Avoid adding not idempotent workers.[...] end CODE - - expect(cop.offenses.size).to eq(1) end it 'adds an offense when not defining idempotent method' do - inspect_source(<<~CODE) + expect_no_offenses(<<~CODE) class SomeWorker idempotent! end CODE - - expect(cop.offenses.size).to be_zero end end |