Commit a8ea1be92204259ab58a9f2aa1593328efa9ad0f

Authored by Daniel Westendorf
1 parent 599c1d5f

Add failing test for non-integer primary key models

Showing 2 changed files with 23 additions and 0 deletions   Show diff stats
test/reindex_test.rb
... ... @@ -39,6 +39,14 @@ class ReindexTest < Minitest::Test
39 39 assert_search "product", ["Product A"]
40 40 end
41 41  
  42 + def test_async_non_integer_pk
  43 + skip if !defined?(ActiveJob)
  44 +
  45 + Sku.create(id: SecureRandom.hex, name: "Test")
  46 +
  47 + reindex = Sku.reindex(async: true)
  48 + end
  49 +
42 50 def test_refresh_interval
43 51 reindex = Product.reindex(refresh_interval: "30s", async: true, import: false)
44 52 index = Searchkick::Index.new(reindex[:index_name])
... ...
test/test_helper.rb
... ... @@ -339,6 +339,10 @@ else
339 339 t.string :type
340 340 end
341 341  
  342 + ActiveRecord::Migration.create_table :skus, id: :uuid do |t|
  343 + t.string :name
  344 + end
  345 +
342 346 class Product < ActiveRecord::Base
343 347 belongs_to :store
344 348 end
... ... @@ -361,6 +365,9 @@ else
361 365  
362 366 class Cat < Animal
363 367 end
  368 +
  369 + class Sku < ActiveRecord::Base
  370 + end
364 371 end
365 372  
366 373 class Product
... ... @@ -477,6 +484,14 @@ class Animal
477 484 # wordnet: true
478 485 end
479 486  
  487 +class Sku
  488 + searchkick \
  489 + text_start: [:name],
  490 + suggest: [:name],
  491 + index_name: -> { "#{name.tableize}-#{Date.today.year}#{Searchkick.index_suffix}" },
  492 + callbacks: defined?(ActiveJob) ? :async : true
  493 +end
  494 +
480 495 Product.searchkick_index.delete if Product.searchkick_index.exists?
481 496 Product.reindex
482 497 Product.reindex # run twice for both index paths
... ...