Skip to content

Add configuration to disable ActiveJob job signature matching check #2801

Closed
@smathieu

Description

@smathieu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions