Skip to content

Commit 4487727

Browse files
committed
add test scenario to make sure deprecated warning is triggered
1 parent 0c68f55 commit 4487727

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/jit_preloader/preloader.rb

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ class Preloader < ActiveRecord::Associations::Preloader
33

44
attr_accessor :records
55

6+
def foo(**kwargs)
7+
kwargs
8+
end
9+
610
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("7.0.0")
711
def self.attach(records)
812
new(records: records.dup, associations: nil).tap do |loader|

spec/lib/jit_preloader/preloader_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
->(event, data){ source_map[data[:source]] << data[:association] }
5050
end
5151

52+
53+
it "should warn about keyword arguments" do
54+
expect(described_class.new(records: nil, associations: nil).foo({a: 1})).to eq({a: 1})
55+
end
56+
5257
context "for single table inheritance" do
5358
context "when preloading an aggregate for a child model" do
5459
let!(:contact_book) { ContactBook.create(name: "The Yellow Pages") }

0 commit comments

Comments
 (0)