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