Skip to content

Commit

Permalink
add test scenario to make sure deprecated warning is triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
wendy-clio committed Jun 11, 2024
1 parent 24efc6a commit 5d2621f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/jit_preloader/preloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class Preloader < ActiveRecord::Associations::Preloader

attr_accessor :records

def foo(**kwargs)
kwargs
end

if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("7.0.0")
def self.attach(records)
new(records: records.dup, associations: nil).tap do |loader|
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/jit_preloader/preloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
->(event, data){ source_map[data[:source]] << data[:association] }
end


it "should warn about keyword arguments" do
expect(described_class.new(records: nil, associations: nil).foo({a: 1})).to eq({a: 1})
end

context "for single table inheritance" do
context "when preloading an aggregate for a child model" do
let!(:contact_book) { ContactBook.create(name: "The Yellow Pages") }
Expand Down

0 comments on commit 5d2621f

Please sign in to comment.