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 7, 2024
1 parent a1f4026 commit 166cf58
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
ruby-version: 2.7
- name: Install dependencies
run: bundle install
- name: Run tests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gem-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Ruby 3.0
- name: Set up Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
ruby-version: 2.7

- name: Publish to RubyGems
env:
Expand Down
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 166cf58

Please sign in to comment.