Commit 11d740c4dd78c4a9d7e432e4ff7e767aa9ca2be3
1 parent
1d21993d
Exists in
master
and in
2 other branches
Added only and except methods on relation
Showing
2 changed files
with
16 additions
and
0 deletions
Show diff stats
lib/searchkick/relation.rb
... | ... | @@ -80,6 +80,14 @@ module Searchkick |
80 | 80 | self |
81 | 81 | end |
82 | 82 | |
83 | + def only(*keys) | |
84 | + Relation.new(@model, @term, **@options.slice(*keys)) | |
85 | + end | |
86 | + | |
87 | + def except(*keys) | |
88 | + Relation.new(@model, @term, **@options.except(*keys)) | |
89 | + end | |
90 | + | |
83 | 91 | def loaded? |
84 | 92 | !@execute.nil? |
85 | 93 | end | ... | ... |
test/pagination_test.rb
... | ... | @@ -29,6 +29,14 @@ class PaginationTest < Minitest::Test |
29 | 29 | assert_equal 10000, products.limit_value |
30 | 30 | end |
31 | 31 | |
32 | + def test_limit_relation_only | |
33 | + assert_equal 10, Product.search("*").limit(10).only(:limit).limit_value | |
34 | + end | |
35 | + | |
36 | + def test_limit_relation_except | |
37 | + assert_equal 10000, Product.search("*").limit(10).except(:limit).limit_value | |
38 | + end | |
39 | + | |
32 | 40 | def test_no_limit |
33 | 41 | names = 20.times.map { |i| "Product #{i}" } |
34 | 42 | store_names names | ... | ... |