Commit c174d142c9a0dca2bb0104cae697c9a26f51a1f5
1 parent
c45424ee
Exists in
master
and in
1 other branch
Use search_index in tests
Showing
7 changed files
with
22 additions
and
22 deletions
Show diff stats
test/inheritance_test.rb
... | ... | @@ -13,7 +13,7 @@ class InheritanceTest < Minitest::Test |
13 | 13 | end |
14 | 14 | |
15 | 15 | def test_child_index_name |
16 | - assert_equal "animals_test#{ENV["TEST_ENV_NUMBER"]}", Dog.searchkick_index.name | |
16 | + assert_equal "animals_test#{ENV["TEST_ENV_NUMBER"]}", Dog.search_index.name | |
17 | 17 | end |
18 | 18 | |
19 | 19 | def test_child_search |
... | ... | @@ -116,7 +116,7 @@ class InheritanceTest < Minitest::Test |
116 | 116 | def test_index_name_string |
117 | 117 | store_names ["Product A"] |
118 | 118 | error = assert_raises Searchkick::Error do |
119 | - Searchkick.search("product", index_name: [Product.searchkick_index.name]).map(&:name) | |
119 | + Searchkick.search("product", index_name: [Product.search_index.name]).map(&:name) | |
120 | 120 | end |
121 | 121 | assert_includes error.message, "Unknown model" |
122 | 122 | end | ... | ... |
test/multi_indices_test.rb
... | ... | @@ -14,19 +14,19 @@ class MultiIndicesTest < Minitest::Test |
14 | 14 | |
15 | 15 | def test_index_name |
16 | 16 | store_names ["Product A"] |
17 | - assert_equal ["Product A"], Product.search("product", index_name: Product.searchkick_index.name).map(&:name) | |
17 | + assert_equal ["Product A"], Product.search("product", index_name: Product.search_index.name).map(&:name) | |
18 | 18 | assert_equal ["Product A"], Product.search("product", index_name: Product).map(&:name) |
19 | 19 | |
20 | 20 | Speaker.search_index.refresh |
21 | - assert_equal [], Product.search("product", index_name: Speaker.searchkick_index.name, conversions: false).map(&:name) | |
21 | + assert_equal [], Product.search("product", index_name: Speaker.search_index.name, conversions: false).map(&:name) | |
22 | 22 | end |
23 | 23 | |
24 | 24 | def test_models_and_index_name |
25 | 25 | store_names ["Product A"] |
26 | 26 | store_names ["Product B"], Speaker |
27 | - assert_equal ["Product A"], Searchkick.search("product", models: [Product, Store], index_name: Product.searchkick_index.name).map(&:name) | |
27 | + assert_equal ["Product A"], Searchkick.search("product", models: [Product, Store], index_name: Product.search_index.name).map(&:name) | |
28 | 28 | error = assert_raises(Searchkick::Error) do |
29 | - Searchkick.search("product", models: [Product, Store], index_name: Speaker.searchkick_index.name).map(&:name) | |
29 | + Searchkick.search("product", models: [Product, Store], index_name: Speaker.search_index.name).map(&:name) | |
30 | 30 | end |
31 | 31 | assert_includes error.message, "Unknown model" |
32 | 32 | # legacy | ... | ... |
test/partial_reindex_test.rb
... | ... | @@ -15,7 +15,7 @@ class PartialReindexTest < Minitest::Test |
15 | 15 | Searchkick.callbacks(false) do |
16 | 16 | product.save! |
17 | 17 | end |
18 | - Product.searchkick_index.refresh | |
18 | + Product.search_index.refresh | |
19 | 19 | |
20 | 20 | # index not updated |
21 | 21 | assert_search "hi", ["Hi"], fields: [:name], load: false |
... | ... | @@ -43,7 +43,7 @@ class PartialReindexTest < Minitest::Test |
43 | 43 | Searchkick.callbacks(false) do |
44 | 44 | product.save! |
45 | 45 | end |
46 | - Product.searchkick_index.refresh | |
46 | + Product.search_index.refresh | |
47 | 47 | |
48 | 48 | # index not updated |
49 | 49 | assert_search "hi", ["Hi"], fields: [:name], load: false | ... | ... |
test/reindex_test.rb
... | ... | @@ -30,7 +30,7 @@ class ReindexTest < Minitest::Test |
30 | 30 | end |
31 | 31 | |
32 | 32 | def test_record_queue |
33 | - reindex_queue = Product.searchkick_index.reindex_queue | |
33 | + reindex_queue = Product.search_index.reindex_queue | |
34 | 34 | reindex_queue.clear |
35 | 35 | |
36 | 36 | store_names ["Product A", "Product B"], reindex: false |
... | ... | @@ -133,7 +133,7 @@ class ReindexTest < Minitest::Test |
133 | 133 | end |
134 | 134 | |
135 | 135 | def test_relation_queue |
136 | - reindex_queue = Product.searchkick_index.reindex_queue | |
136 | + reindex_queue = Product.search_index.reindex_queue | |
137 | 137 | reindex_queue.clear |
138 | 138 | |
139 | 139 | store_names ["Product A"] |
... | ... | @@ -171,7 +171,7 @@ class ReindexTest < Minitest::Test |
171 | 171 | |
172 | 172 | assert Searchkick.reindex_status(reindex[:name]) |
173 | 173 | |
174 | - Product.searchkick_index.promote(reindex[:index_name]) | |
174 | + Product.search_index.promote(reindex[:index_name]) | |
175 | 175 | assert_search "product", ["Product A"] |
176 | 176 | end |
177 | 177 | |
... | ... | @@ -274,20 +274,20 @@ class ReindexTest < Minitest::Test |
274 | 274 | # TODO figure out which earlier test leaves records in index |
275 | 275 | Product.reindex |
276 | 276 | |
277 | - reindex_queue = Product.searchkick_index.reindex_queue | |
277 | + reindex_queue = Product.search_index.reindex_queue | |
278 | 278 | reindex_queue.clear |
279 | 279 | |
280 | 280 | Searchkick.callbacks(:queue) do |
281 | 281 | store_names ["Product A", "Product B"] |
282 | 282 | end |
283 | - Product.searchkick_index.refresh | |
283 | + Product.search_index.refresh | |
284 | 284 | assert_search "product", [], load: false, conversions: false |
285 | 285 | assert_equal 2, reindex_queue.length |
286 | 286 | |
287 | 287 | perform_enqueued_jobs do |
288 | 288 | Searchkick::ProcessQueueJob.perform_now(class_name: "Product") |
289 | 289 | end |
290 | - Product.searchkick_index.refresh | |
290 | + Product.search_index.refresh | |
291 | 291 | assert_search "product", ["Product A", "Product B"], load: false |
292 | 292 | assert_equal 0, reindex_queue.length |
293 | 293 | |
... | ... | @@ -295,14 +295,14 @@ class ReindexTest < Minitest::Test |
295 | 295 | Product.where(name: "Product B").destroy_all |
296 | 296 | Product.create!(name: "Product C") |
297 | 297 | end |
298 | - Product.searchkick_index.refresh | |
298 | + Product.search_index.refresh | |
299 | 299 | assert_search "product", ["Product A", "Product B"], load: false |
300 | 300 | assert_equal 2, reindex_queue.length |
301 | 301 | |
302 | 302 | perform_enqueued_jobs do |
303 | 303 | Searchkick::ProcessQueueJob.perform_now(class_name: "Product") |
304 | 304 | end |
305 | - Product.searchkick_index.refresh | |
305 | + Product.search_index.refresh | |
306 | 306 | assert_search "product", ["Product A", "Product C"], load: false |
307 | 307 | assert_equal 0, reindex_queue.length |
308 | 308 | |
... | ... | @@ -328,7 +328,7 @@ class ReindexTest < Minitest::Test |
328 | 328 | end |
329 | 329 | |
330 | 330 | def test_both_paths |
331 | - Product.searchkick_index.delete if Product.searchkick_index.exists? | |
331 | + Product.search_index.delete if Product.search_index.exists? | |
332 | 332 | Product.reindex |
333 | 333 | Product.reindex # run twice for both index paths |
334 | 334 | end | ... | ... |
test/routing_test.rb
test/search_test.rb
... | ... | @@ -44,7 +44,7 @@ class SearchTest < Minitest::Test |
44 | 44 | end |
45 | 45 | |
46 | 46 | def test_bad_mapping |
47 | - Product.searchkick_index.delete | |
47 | + Product.search_index.delete | |
48 | 48 | store_names ["Product A"] |
49 | 49 | error = assert_raises(Searchkick::InvalidQueryError) { Product.search("test").to_a } |
50 | 50 | assert_equal "Bad mapping - run Product.reindex", error.message | ... | ... |
test/should_index_test.rb
... | ... | @@ -16,7 +16,7 @@ class ShouldIndexTest < Minitest::Test |
16 | 16 | product = Product.first |
17 | 17 | product.name = "INDEX" |
18 | 18 | product.save! |
19 | - Product.searchkick_index.refresh | |
19 | + Product.search_index.refresh | |
20 | 20 | assert_search "index", ["INDEX"] |
21 | 21 | end |
22 | 22 | |
... | ... | @@ -26,7 +26,7 @@ class ShouldIndexTest < Minitest::Test |
26 | 26 | product = Product.first |
27 | 27 | product.name = "DO NOT INDEX" |
28 | 28 | product.save! |
29 | - Product.searchkick_index.refresh | |
29 | + Product.search_index.refresh | |
30 | 30 | assert_search "index", [] |
31 | 31 | end |
32 | 32 | |
... | ... | @@ -38,7 +38,7 @@ class ShouldIndexTest < Minitest::Test |
38 | 38 | product.save! |
39 | 39 | end |
40 | 40 | Product.where(id: product.id).reindex |
41 | - Product.searchkick_index.refresh | |
41 | + Product.search_index.refresh | |
42 | 42 | assert_search "index", [] |
43 | 43 | end |
44 | 44 | end | ... | ... |