From 43ad72520f6d9b6ae5c9514f40a1aa638a48f96e Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Mar 2020 03:00:02 -0700 Subject: [PATCH] Added none [skip ci] --- lib/searchkick/relation.rb | 9 +++++++++ test/relation_test.rb | 5 +++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/lib/searchkick/relation.rb b/lib/searchkick/relation.rb index 2d241b7..f2b9e88 100644 --- a/lib/searchkick/relation.rb +++ b/lib/searchkick/relation.rb @@ -87,6 +87,15 @@ module Searchkick self end + def none + spawn.none! + end + + def none! + options[:limit] = 0 # TODO use where? + self + end + def select(*fields, &block) if block_given? # TODO better error message diff --git a/test/relation_test.rb b/test/relation_test.rb index 9407a0f..359b42f 100644 --- a/test/relation_test.rb +++ b/test/relation_test.rb @@ -17,6 +17,11 @@ class RelationTest < Minitest::Test assert_search_relation [], Product.search("*").where(name: "Product A").where(name: "Product B") end + def test_none + store_names ["Product A", "Product B"] + assert_search_relation [], Product.search("*").none + end + def test_parameters skip unless defined?(ActiveRecord) require "action_controller" -- libgit2 0.21.0