Commit 3169272b4ef4ef02b8f4b001bae4fd4e37b2a6ae
1 parent
43ad7252
Exists in
relation
Added unscoped [skip ci]
Showing
2 changed files
with
15 additions
and
0 deletions
Show diff stats
lib/searchkick/relation.rb
@@ -96,6 +96,15 @@ module Searchkick | @@ -96,6 +96,15 @@ module Searchkick | ||
96 | self | 96 | self |
97 | end | 97 | end |
98 | 98 | ||
99 | + def unscoped | ||
100 | + spawn.unscoped! | ||
101 | + end | ||
102 | + | ||
103 | + def unscoped! | ||
104 | + @options = {} | ||
105 | + self | ||
106 | + end | ||
107 | + | ||
99 | def select(*fields, &block) | 108 | def select(*fields, &block) |
100 | if block_given? | 109 | if block_given? |
101 | # TODO better error message | 110 | # TODO better error message |
test/relation_test.rb
@@ -22,6 +22,12 @@ class RelationTest < Minitest::Test | @@ -22,6 +22,12 @@ class RelationTest < Minitest::Test | ||
22 | assert_search_relation [], Product.search("*").none | 22 | assert_search_relation [], Product.search("*").none |
23 | end | 23 | end |
24 | 24 | ||
25 | + def test_unscoped | ||
26 | + store_names ["Red", "Blue"] | ||
27 | + # keeps term | ||
28 | + assert_search_relation ["Red"], Product.search("red").where(store_id: 1).unscoped | ||
29 | + end | ||
30 | + | ||
25 | def test_parameters | 31 | def test_parameters |
26 | skip unless defined?(ActiveRecord) | 32 | skip unless defined?(ActiveRecord) |
27 | require "action_controller" | 33 | require "action_controller" |