Commit e2969b4e953df4d2b59a82f68c65850e248d889d
1 parent
761d594c
Exists in
master
Added load method to relation
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
lib/searchkick/relation.rb
@@ -202,6 +202,11 @@ module Searchkick | @@ -202,6 +202,11 @@ module Searchkick | ||
202 | !@execute.nil? | 202 | !@execute.nil? |
203 | end | 203 | end |
204 | 204 | ||
205 | + def load | ||
206 | + private_execute | ||
207 | + self | ||
208 | + end | ||
209 | + | ||
205 | def respond_to_missing?(method_name, include_all) | 210 | def respond_to_missing?(method_name, include_all) |
206 | Results.new(nil, nil, nil).respond_to?(method_name, include_all) || super | 211 | Results.new(nil, nil, nil).respond_to?(method_name, include_all) || super |
207 | end | 212 | end |
test/relation_test.rb
@@ -23,6 +23,14 @@ class RelationTest < Minitest::Test | @@ -23,6 +23,14 @@ class RelationTest < Minitest::Test | ||
23 | assert_equal ["Product A"], products.map(&:name) | 23 | assert_equal ["Product A"], products.map(&:name) |
24 | end | 24 | end |
25 | 25 | ||
26 | + def test_load | ||
27 | + Product.search_index.refresh | ||
28 | + products = Product.search("*") | ||
29 | + refute products.loaded? | ||
30 | + assert products.load.loaded? | ||
31 | + assert products.load.load.loaded? | ||
32 | + end | ||
33 | + | ||
26 | def test_clone | 34 | def test_clone |
27 | products = Product.search("*") | 35 | products = Product.search("*") |
28 | assert_equal 10, products.limit(10).limit_value | 36 | assert_equal 10, products.limit(10).limit_value |