Commit 3169272b4ef4ef02b8f4b001bae4fd4e37b2a6ae

Authored by Andrew Kane
1 parent 43ad7252
Exists in relation

Added unscoped [skip ci]

lib/searchkick/relation.rb
... ... @@ -96,6 +96,15 @@ module Searchkick
96 96 self
97 97 end
98 98  
  99 + def unscoped
  100 + spawn.unscoped!
  101 + end
  102 +
  103 + def unscoped!
  104 + @options = {}
  105 + self
  106 + end
  107 +
99 108 def select(*fields, &block)
100 109 if block_given?
101 110 # TODO better error message
... ...
test/relation_test.rb
... ... @@ -22,6 +22,12 @@ class RelationTest < Minitest::Test
22 22 assert_search_relation [], Product.search("*").none
23 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 31 def test_parameters
26 32 skip unless defined?(ActiveRecord)
27 33 require "action_controller"
... ...