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 spec to have_enqueued_job for arguments added in callbacks of jobs #2802

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions spec/rspec/rails/matchers/active_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def self.name; "KeywordArgsJob"; end
end
end

let(:callback_job) do
Class.new(ActiveJob::Base) do
before_enqueue do |job|
job.arguments << 3
end

def perform(one, two); end
def self.name; "CallbackJob"; end
end
end

before do
ActiveJob::Base.queue_adapter = :test
end
Expand Down Expand Up @@ -372,6 +383,12 @@ def perform; raise StandardError; end
}.to have_enqueued_job.with(42, "David")
end

it "will match arguments added in callbacks" do
expect {
callback_job.perform_later(1, 2)
}.to have_enqueued_job.with(1, 2, 3)
end

it "fails if the arguments do not match the job's signature" do
expect {
expect {
Expand Down
Loading