should_index_test.rb
1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require_relative "test_helper"
class ShouldIndexTest < Minitest::Test
def test_basic
store_names ["INDEX", "DO NOT INDEX"]
assert_search "index", ["INDEX"]
end
def test_default_true
assert Store.new.should_index?
end
def test_change_to_true
store_names ["DO NOT INDEX"]
assert_search "index", []
product = Product.first
product.name = "INDEX"
product.save!
Product.searchkick_index.refresh
assert_search "index", ["INDEX"]
end
def test_change_to_false
store_names ["INDEX"]
assert_search "index", ["INDEX"]
product = Product.first
product.name = "DO NOT INDEX"
product.save!
Product.searchkick_index.refresh
assert_search "index", []
end
def test_bulk
store_names ["INDEX"]
product = Product.first
product.name = "DO NOT INDEX"
Searchkick.callbacks(false) do
product.save!
end
Product.where(id: product.id).reindex
Product.searchkick_index.refresh
assert_search "index", []
end
end