diff --git a/test/reindex_test.rb b/test/reindex_test.rb index 21d2e9f..cc9e745 100644 --- a/test/reindex_test.rb +++ b/test/reindex_test.rb @@ -39,6 +39,14 @@ class ReindexTest < Minitest::Test assert_search "product", ["Product A"] end + def test_async_non_integer_pk + skip if !defined?(ActiveJob) + + Sku.create(id: SecureRandom.hex, name: "Test") + + reindex = Sku.reindex(async: true) + end + def test_refresh_interval reindex = Product.reindex(refresh_interval: "30s", async: true, import: false) index = Searchkick::Index.new(reindex[:index_name]) diff --git a/test/test_helper.rb b/test/test_helper.rb index 083d6e9..12d9a44 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -339,6 +339,10 @@ else t.string :type end + ActiveRecord::Migration.create_table :skus, id: :uuid do |t| + t.string :name + end + class Product < ActiveRecord::Base belongs_to :store end @@ -361,6 +365,9 @@ else class Cat < Animal end + + class Sku < ActiveRecord::Base + end end class Product @@ -477,6 +484,14 @@ class Animal # wordnet: true end +class Sku + searchkick \ + text_start: [:name], + suggest: [:name], + index_name: -> { "#{name.tableize}-#{Date.today.year}#{Searchkick.index_suffix}" }, + callbacks: defined?(ActiveJob) ? :async : true +end + Product.searchkick_index.delete if Product.searchkick_index.exists? Product.reindex Product.reindex # run twice for both index paths -- libgit2 0.21.0