Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration to disable ActiveJob job signature matching check #2801

Open
smathieu opened this issue Sep 10, 2024 · 0 comments
Open

Add configuration to disable ActiveJob job signature matching check #2801

smathieu opened this issue Sep 10, 2024 · 0 comments

Comments

@smathieu
Copy link

Is your feature request related to a problem? Please describe.

The 7.0 version of RSpec Rails introduced #2745 by @odlp which is overall a great addition, but doesn't provide a configuration to disable this check.

This is a problem for one of our app that uses before_enqueue and around_perform callbacks that modifies the arguments passed to the job.

Describe the solution you'd like

I would like a way to disable this check.

Describe alternatives you've considered

I'm not sure there are other solutions short of updating all the jobs in our app.

Additional context

Here are the callbacks being used:

class ApplicationJob < ActiveJob::Base
  # Automatically retry jobs that encountered a deadlock
  # retry_on ActiveRecord::Deadlocked

  # Most jobs are safe to ignore if the underlying records are no longer available
  discard_on ActiveJob::DeserializationError

  before_enqueue do |job|
    if Actor.current?
      job.arguments << { actor: Actor.current }
    end
  end

  around_perform do |job, block|
    arg = job.arguments.find { |a| a.is_a?(Hash) && a.key?(:actor) }
    if arg
      job.arguments.delete(arg)
      actor = arg[:actor]
    end

    if actor
      Actor.with(actor) do
        block.call
      end
    else
      block.call
    end
  end
end
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

No branches or pull requests

1 participant