Skip to content

Commit

Permalink
Add back-compat coverage for 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
smudge committed Nov 29, 2021
1 parent 0e0f9c4 commit fddec5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/delayed/performable_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def display_name
def perform
return unless object

if kwargs.nil? # TODO: Remove this branch in the next major release. (It will be 'nil' for jobs enqueued before we split out kwargs.)
if kwargs.nil? || (RUBY_VERSION < '2.7' && kwargs.empty?)
object.send(method_name, *args)
else
object.send(method_name, *args, **kwargs)
Expand Down
14 changes: 14 additions & 0 deletions spec/performable_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ def foo(arg, kwarg:)
.to change { test_class.result }
.from(nil).to %w(a b)
end

if RUBY_VERSION < '3.0'
context 'when kwargs are nil (job was delayed via prior gem version)' do
before do
@method = described_class.new(test_class.new, :foo, ['a', { kwarg: 'b' }], nil)
end

it 'calls the method on the object' do
expect { @method.perform }
.to change { test_class.result }
.from(nil).to %w(a b)
end
end
end
end

it "raises a NoMethodError if target method doesn't exist" do
Expand Down

0 comments on commit fddec5e

Please sign in to comment.