diff --git a/lib/searchkick/relation.rb b/lib/searchkick/relation.rb index 2fec0fc..6cf5b43 100644 --- a/lib/searchkick/relation.rb +++ b/lib/searchkick/relation.rb @@ -202,6 +202,11 @@ module Searchkick !@execute.nil? end + def load + private_execute + self + end + def respond_to_missing?(method_name, include_all) Results.new(nil, nil, nil).respond_to?(method_name, include_all) || super end diff --git a/test/relation_test.rb b/test/relation_test.rb index 3970bf3..8065e6f 100644 --- a/test/relation_test.rb +++ b/test/relation_test.rb @@ -23,6 +23,14 @@ class RelationTest < Minitest::Test assert_equal ["Product A"], products.map(&:name) end + def test_load + Product.search_index.refresh + products = Product.search("*") + refute products.loaded? + assert products.load.loaded? + assert products.load.load.loaded? + end + def test_clone products = Product.search("*") assert_equal 10, products.limit(10).limit_value -- libgit2 0.21.0