Commit 815dee64fab3f16d0b69e915ea9a207fbd3130ff

Authored by Andrew Kane
1 parent 2cf1c444

Changed record reindex to return true to match model and relation reindex

@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 - Changed async full reindex to fetch ids instead of using ranges for numeric primary keys with Active Record 8 - Changed async full reindex to fetch ids instead of using ranges for numeric primary keys with Active Record
9 - Changed `searchkick_index_options` to return symbol keys (instead of mix of strings and symbols) 9 - Changed `searchkick_index_options` to return symbol keys (instead of mix of strings and symbols)
10 - Changed non-anchored regular expressions to match expected results (previously warned) 10 - Changed non-anchored regular expressions to match expected results (previously warned)
  11 +- Changed record reindex to return `true` to match model and relation reindex
11 - Updated async reindex job to call `search_import` for nested associations 12 - Updated async reindex job to call `search_import` for nested associations
12 - Fixed removing records when `should_index?` is `false` when `reindex` called on relation 13 - Fixed removing records when `should_index?` is `false` when `reindex` called on relation
13 - Fixed issue with `merge_mappings` for fields that use `searchkick` options 14 - Fixed issue with `merge_mappings` for fields that use `searchkick` options
lib/searchkick/record_indexer.rb
@@ -55,6 +55,9 @@ module Searchkick @@ -55,6 +55,9 @@ module Searchkick
55 else 55 else
56 raise ArgumentError, "Invalid value for mode" 56 raise ArgumentError, "Invalid value for mode"
57 end 57 end
  58 +
  59 + # return true like model and relation reindex for now
  60 + true
58 end 61 end
59 62
60 def reindex_items(klass, items, method_name:, single: false) 63 def reindex_items(klass, items, method_name:, single: false)
test/reindex_test.rb
@@ -5,7 +5,7 @@ class ReindexTest < Minitest::Test @@ -5,7 +5,7 @@ class ReindexTest < Minitest::Test
5 store_names ["Product A", "Product B"], reindex: false 5 store_names ["Product A", "Product B"], reindex: false
6 6
7 product = Product.find_by!(name: "Product A") 7 product = Product.find_by!(name: "Product A")
8 - assert_nil product.reindex(refresh: true) 8 + assert_equal true, product.reindex(refresh: true)
9 assert_search "product", ["Product A"] 9 assert_search "product", ["Product A"]
10 end 10 end
11 11
@@ -15,16 +15,15 @@ class ReindexTest < Minitest::Test @@ -15,16 +15,15 @@ class ReindexTest < Minitest::Test
15 product = Product.find_by!(name: "Product A") 15 product = Product.find_by!(name: "Product A")
16 product.destroy 16 product.destroy
17 Product.search_index.refresh 17 Product.search_index.refresh
18 - assert_nil product.reindex 18 + assert_equal true, product.reindex
19 end 19 end
20 20
21 def test_record_async 21 def test_record_async
22 store_names ["Product A", "Product B"], reindex: false 22 store_names ["Product A", "Product B"], reindex: false
23 23
24 product = Product.find_by!(name: "Product A") 24 product = Product.find_by!(name: "Product A")
25 - # TODO decide on return value  
26 perform_enqueued_jobs do 25 perform_enqueued_jobs do
27 - assert_kind_of ActiveJob::Base, product.reindex(mode: :async) 26 + assert_equal true, product.reindex(mode: :async)
28 end 27 end
29 Product.search_index.refresh 28 Product.search_index.refresh
30 assert_search "product", ["Product A"] 29 assert_search "product", ["Product A"]
@@ -37,8 +36,7 @@ class ReindexTest < Minitest::Test @@ -37,8 +36,7 @@ class ReindexTest < Minitest::Test
37 store_names ["Product A", "Product B"], reindex: false 36 store_names ["Product A", "Product B"], reindex: false
38 37
39 product = Product.find_by!(name: "Product A") 38 product = Product.find_by!(name: "Product A")
40 - # TODO improve return value  
41 - assert_equal 1, product.reindex(mode: :queue) 39 + assert_equal true, product.reindex(mode: :queue)
42 Product.search_index.refresh 40 Product.search_index.refresh
43 assert_search "product", [] 41 assert_search "product", []
44 42