Commit 3d9025225f078cb3d8e37fdfa52ae4a1e06a5988
1 parent
a7b7908f
Exists in
relation
and in
1 other branch
Added debug and explain
Showing
2 changed files
with
26 additions
and
0 deletions
Show diff stats
lib/searchkick/relation.rb
... | ... | @@ -294,6 +294,24 @@ module Searchkick |
294 | 294 | self |
295 | 295 | end |
296 | 296 | |
297 | + def debug(value) | |
298 | + spawn.debug!(value) | |
299 | + end | |
300 | + | |
301 | + def debug!(value) | |
302 | + options[:debug] = value | |
303 | + self | |
304 | + end | |
305 | + | |
306 | + def explain(value) | |
307 | + spawn.explain!(value) | |
308 | + end | |
309 | + | |
310 | + def explain!(value) | |
311 | + options[:explain] = value | |
312 | + self | |
313 | + end | |
314 | + | |
297 | 315 | # same as Active Record |
298 | 316 | def inspect |
299 | 317 | entries = results.first(11).map!(&:inspect) | ... | ... |
test/query_test.rb
... | ... | @@ -39,4 +39,12 @@ class QueryTest < Minitest::Test |
39 | 39 | end |
40 | 40 | refute_includes out, "Error" |
41 | 41 | end |
42 | + | |
43 | + def test_debug_relation | |
44 | + store_names ["Milk"] | |
45 | + out, _ = capture_io do | |
46 | + assert_search_relation ["Milk"], Product.search("milk", relation: true).debug(true) | |
47 | + end | |
48 | + refute_includes out, "Error" | |
49 | + end | |
42 | 50 | end | ... | ... |