Commit 007c1c10fa831749359ab40f85addd048b53f7bb

Authored by Andrew Kane
1 parent 60fd9404
Exists in relation

Added unscope [skip ci]

lib/searchkick/relation.rb
... ... @@ -105,6 +105,15 @@ module Searchkick
105 105 self
106 106 end
107 107  
  108 + def unscope(*args)
  109 + spawn.unscope!(*args)
  110 + end
  111 +
  112 + def unscope!(*args)
  113 + @options = options.except(*args)
  114 + self
  115 + end
  116 +
108 117 # TODO make more efficient if loaded
109 118 def pluck(*fields)
110 119 result = select(*fields).load(false)
... ...
test/relation_test.rb
... ... @@ -28,6 +28,11 @@ class RelationTest < Minitest::Test
28 28 assert_search_relation ["Red"], Product.search("red").where(store_id: 1).unscoped
29 29 end
30 30  
  31 + def test_unscope
  32 + store_names ["Red", "Blue"]
  33 + assert_search_relation ["Red"], Product.search("red").where(store_id: 1).unscope(:where)
  34 + end
  35 +
31 36 def test_pluck
32 37 store_names ["Blue", "Red"]
33 38 assert_equal ["Blue", "Red"], Product.order(:name).pluck(:name) if defined?(ActiveRecord)
... ...