diff options
Diffstat (limited to 'spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb')
-rw-r--r-- | spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb | 24 |
1 files changed, 7 insertions, 17 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 |