Commit 8a0303c5802ecc0ed82424b6e437e67a009a2da8

Authored by Andrew Kane
1 parent 9bbbe73c
Exists in master

Fixed respond_to? method on relation loading relation - #1395

CHANGELOG.md
... ... @@ -2,6 +2,7 @@
2 2  
3 3 - Added `model` method to `Searchkick::Relation`
4 4 - Fixed deprecation warning with `redis` gem
  5 +- Fixed `respond_to?` method on relation loading relation
5 6  
6 7 ## 5.0.4 (2022-06-16)
7 8  
... ...
lib/searchkick/relation.rb
... ... @@ -202,6 +202,10 @@ module Searchkick
202 202 !@execute.nil?
203 203 end
204 204  
  205 + def respond_to_missing?(method_name, include_all)
  206 + Results.new(nil, nil, nil).respond_to?(method_name, include_all) || super
  207 + end
  208 +
205 209 # TODO uncomment in 6.0
206 210 # def to_yaml
207 211 # private_execute.to_a.to_yaml
... ...
test/relation_test.rb
... ... @@ -44,6 +44,15 @@ class RelationTest < Minitest::Test
44 44 assert_nil Searchkick.search("product").klass
45 45 end
46 46  
  47 + def test_respond_to
  48 + relation = Product.search("product")
  49 + assert relation.respond_to?(:page)
  50 + assert relation.respond_to?(:response)
  51 + assert relation.respond_to?(:size)
  52 + refute relation.respond_to?(:hello)
  53 + refute relation.loaded?
  54 + end
  55 +
47 56 # TODO uncomment in 6.0
48 57 # def test_to_yaml
49 58 # store_names ["Product A", "Product B"]
... ...