Skip to content

Commit

Permalink
Fix test that references Rails logger for Rails 7.2a change (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored Nov 26, 2023
1 parent 4957833 commit c6d3aa4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/lib/good_job/active_job_extensions/concurrency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def perform(name:)
end

it "does not enqueue if enqueue concurrency limit is exceeded for a particular key" do
allow(Rails.logger.formatter).to receive(:call).and_call_original
allow(TestJob.logger.formatter).to receive(:call).and_call_original

expect(TestJob.perform_later(name: "Alice")).to be_present
expect(TestJob.perform_later(name: "Alice")).to be_present
Expand All @@ -86,10 +86,10 @@ def perform(name:)
expect(GoodJob::Execution.where(concurrency_key: "Alice").count).to eq 2
expect(GoodJob::Execution.where(concurrency_key: "Bob").count).to eq 1

expect(Rails.logger.formatter).to have_received(:call).with("INFO", anything, anything, a_string_matching(/Aborted enqueue of TestJob \(Job ID: .*\) because the concurrency key 'Alice' has reached its limit of 2 jobs/)).exactly(:once)
expect(TestJob.logger.formatter).to have_received(:call).with("INFO", anything, anything, a_string_matching(/Aborted enqueue of TestJob \(Job ID: .*\) because the concurrency key 'Alice' has reached its limit of 2 jobs/)).exactly(:once)
if ActiveJob.gem_version >= Gem::Version.new("6.1.0")
expect(Rails.logger.formatter).to have_received(:call).with("INFO", anything, anything, a_string_matching(/Enqueued TestJob \(Job ID: .*\) to \(default\) with arguments: {:name=>"Alice"}/)).exactly(:twice)
expect(Rails.logger.formatter).to have_received(:call).with("INFO", anything, anything, a_string_matching(/Enqueued TestJob \(Job ID: .*\) to \(default\) with arguments: {:name=>"Bob"}/)).exactly(:once)
expect(TestJob.logger.formatter).to have_received(:call).with("INFO", anything, anything, a_string_matching(/Enqueued TestJob \(Job ID: .*\) to \(default\) with arguments: {:name=>"Alice"}/)).exactly(:twice)
expect(TestJob.logger.formatter).to have_received(:call).with("INFO", anything, anything, a_string_matching(/Enqueued TestJob \(Job ID: .*\) to \(default\) with arguments: {:name=>"Bob"}/)).exactly(:once)
end
end

Expand Down

0 comments on commit c6d3aa4

Please sign in to comment.