Sha256: 11b703c9dc5a39bb8e923fdd6d94b9e6b35eed20b2ed57c6f2ed6190d1d7610b

Contents?: true

Size: 1.52 KB

Versions: 7

Compression:

Stored size: 1.52 KB

Contents

require_relative "test_helper"

class ReindexTest < Minitest::Test
  def test_scoped
    skip if nobrainer? || cequel?

    store_names ["Product A"]
    Searchkick.callbacks(false) do
      store_names ["Product B", "Product C"]
    end
    Product.where(name: "Product B").reindex(refresh: true)
    assert_search "product", ["Product A", "Product B"]
  end

  def test_associations
    skip if nobrainer? || cequel?

    store_names ["Product A"]
    store = Store.create!(name: "Test")
    Product.create!(name: "Product B", store_id: store.id)
    store.products.reindex(refresh: true)
    assert_search "product", ["Product A", "Product B"]
  end

  def test_async
    skip if !defined?(ActiveJob)

    Searchkick.callbacks(false) do
      store_names ["Product A"]
    end
    reindex = Product.reindex(async: true)
    assert_search "product", [], conversions: false

    index = Searchkick::Index.new(reindex[:index_name])
    index.refresh
    assert_equal 1, index.total_docs

    Product.searchkick_index.promote(reindex[:index_name])
    assert_search "product", ["Product A"]
  end

  def test_refresh_interval
    reindex = Product.reindex(refresh_interval: "30s", async: true, import: false)
    index = Searchkick::Index.new(reindex[:index_name])
    assert_nil Product.search_index.refresh_interval
    assert_equal "30s", index.refresh_interval

    Product.search_index.promote(index.name, update_refresh_interval: true)
    assert_equal "1s", index.refresh_interval
    assert_equal "1s", Product.search_index.refresh_interval
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
searchkick-hooopo-2.3.3 test/reindex_test.rb
searchkick-hooopo-2.3.2 test/reindex_test.rb
searchkick-hooopo-2.3.1 test/reindex_test.rb
searchkick-hooopo-2.3.0 test/reindex_test.rb
searchkick-2.3.0 test/reindex_test.rb
searchkick-2.2.1 test/reindex_test.rb
searchkick-2.2.0 test/reindex_test.rb