From 5d2621f459e7e50b4d2ef76178f25c4c3690132b Mon Sep 17 00:00:00 2001 From: Wendy Chen Date: Wed, 5 Jun 2024 13:00:06 -0400 Subject: [PATCH] add test scenario to make sure deprecated warning is triggered --- lib/jit_preloader/preloader.rb | 4 ++++ spec/lib/jit_preloader/preloader_spec.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/jit_preloader/preloader.rb b/lib/jit_preloader/preloader.rb index d8c9c5d..e9b8035 100644 --- a/lib/jit_preloader/preloader.rb +++ b/lib/jit_preloader/preloader.rb @@ -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| diff --git a/spec/lib/jit_preloader/preloader_spec.rb b/spec/lib/jit_preloader/preloader_spec.rb index 92e5c11..f110704 100644 --- a/spec/lib/jit_preloader/preloader_spec.rb +++ b/spec/lib/jit_preloader/preloader_spec.rb @@ -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") }