fix: ruby 2.7 kwarg warning in uploader process
This commit is contained in:
parent
83fcd75584
commit
c9bcb86709
|
@ -91,7 +91,17 @@ module CarrierWave
|
|||
next if self.send(condition, new_file)
|
||||
end
|
||||
end
|
||||
self.send(method, *args)
|
||||
|
||||
if args.is_a? Array
|
||||
kwargs, args = args.partition { |arg| arg.is_a? Hash }
|
||||
end
|
||||
|
||||
if kwargs.present?
|
||||
kwargs = kwargs.reduce(:merge)
|
||||
self.send(method, *args, **kwargs)
|
||||
else
|
||||
self.send(method, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -126,6 +126,15 @@ describe CarrierWave::Uploader do
|
|||
end
|
||||
end
|
||||
|
||||
context "when there are additional method key word arguments" do
|
||||
it "calls the processor if the condition method returns true" do
|
||||
uploader_class.process :resize => [200, 300, combine_options: { quality: 70 }], :if => :true?
|
||||
expect(uploader).to receive(:true?).with("test.jpg").once.and_return(true)
|
||||
expect(uploader).to receive(:resize).with(200, 300, combine_options: { quality: 70 })
|
||||
uploader.process!("test.jpg")
|
||||
end
|
||||
end
|
||||
|
||||
context "when using RMagick", :rmagick => true do
|
||||
before do
|
||||
def uploader.cover
|
||||
|
|
Loading…
Reference in New Issue