Skip to content

Conversation

@DmitryTsepelev
Copy link

That's a pretty dumb strategy to implement, but I feel like writing unique :until_executed, on_conflict: :reject is a bit more readable than unique :until_executed, on_conflict: ->(_) {} in cases, when I know that there will be a ton of conflicts, I expect that and do not want to be notified

Copilot AI review requested due to automatic review settings May 10, 2025 18:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new conflict strategy (:reject) for ActiveJob uniqueness, allowing jobs to be silently skipped when a conflict occurs. Key changes include:

  • Adding test contexts to verify that using on_conflict: :reject does not raise errors or log skipped jobs.
  • Updating the base strategy and configuration files to accept the :reject value.
  • Extending test coverage across multiple contexts for different strategies.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
spec/support/shared_examples/enqueuing.rb Added tests for on_conflict: :reject behavior
spec/active_job/uniqueness/strategies/while_executing_spec.rb Added tests verifying no exceptions or logging with :reject
spec/active_job/uniqueness/strategies/until_and_while_executing_spec.rb Added tests verifying no exceptions or logging with :reject
spec/active_job/uniqueness/active_job_patch/unique_spec.rb Added tests to assert correct lock options with :reject
lib/active_job/uniqueness/strategies/base.rb Updated conflict handling to support :reject
lib/active_job/uniqueness/configuration.rb Updated on_conflict validation to accept :reject

context 'when on_conflict: :reject given' do
before { job_class.unique strategy, on_conflict: :reject }

it 'not raises ActiveJob::Uniqueness::JobNotUnique' do
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider rephrasing the test description to 'does not raise ActiveJob::Uniqueness::JobNotUnique' for improved clarity.

Suggested change
it 'not raises ActiveJob::Uniqueness::JobNotUnique' do
it 'does not raise ActiveJob::Uniqueness::JobNotUnique' do

Copilot uses AI. Check for mistakes.
expect { subject }.not_to raise_error
end

it 'not logs the skipped job' do
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider rephrasing the test description to 'does not log the skipped job' for improved clarity.

Suggested change
it 'not logs the skipped job' do
it 'does not log the skipped job' do

Copilot uses AI. Check for mistakes.

include_examples 'of a not unique job processing'

it 'not raises ActiveJob::Uniqueness::JobNotUnique' do
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider rephrasing to 'does not raise ActiveJob::Uniqueness::JobNotUnique' to improve readability.

Suggested change
it 'not raises ActiveJob::Uniqueness::JobNotUnique' do
it 'does not raise ActiveJob::Uniqueness::JobNotUnique' do

Copilot uses AI. Check for mistakes.
expect { process }.not_to raise_error
end

it 'not logs the skipped job' do
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider rephrasing to 'does not log the skipped job' to improve readability.

Suggested change
it 'not logs the skipped job' do
it 'does not log the skipped job' do

Copilot uses AI. Check for mistakes.

include_examples 'of a not unique job processing'

it 'not raises ActiveJob::Uniqueness::JobNotUnique' do
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider rephrasing to 'does not raise ActiveJob::Uniqueness::JobNotUnique' for clarity.

Suggested change
it 'not raises ActiveJob::Uniqueness::JobNotUnique' do
it 'does not raise ActiveJob::Uniqueness::JobNotUnique' do

Copilot uses AI. Check for mistakes.
expect { process }.not_to raise_error
end

it 'not logs the skipped job' do
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider rephrasing to 'does not log the skipped job' for clarity.

Suggested change
it 'not logs the skipped job' do
it 'does not log the skipped job' do

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@sharshenov sharshenov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants