diff --git a/lib/shrine/plugins/backgrounding.rb b/lib/shrine/plugins/backgrounding.rb index 3fdc3755..4e9be599 100644 --- a/lib/shrine/plugins/backgrounding.rb +++ b/lib/shrine/plugins/backgrounding.rb @@ -69,7 +69,7 @@ def destroy_block(&block) # Does a background promote if promote block was registered. def promote_cached(**options) if promote? && promote_block - promote_background + promote_background(**options) else super end diff --git a/test/plugin/backgrounding_test.rb b/test/plugin/backgrounding_test.rb index fd974281..0406e819 100644 --- a/test/plugin/backgrounding_test.rb +++ b/test/plugin/backgrounding_test.rb @@ -124,6 +124,22 @@ assert @attacher.stored? end + it "forwards additional options to the block" do + @attacher.promote_block do |attacher, **options| + @job = Fiber.new { attacher.promote(**options) } + end + + @attacher.attach_cached(fakeio) + @attacher.promote_cached(location: "foo") + + assert @attacher.cached? + + @job.resume + + assert @attacher.stored? + assert_equal "foo", @attacher.file.id + end + it "calls default promotion when no promote blocks are registered" do @attacher.attach_cached(fakeio) @attacher.promote_cached