Sha256: afed83e4366eacbbd27ff0de0fa98912eb69be07d3c5252e70cee30de95bd151

Contents?: true

Size: 1.03 KB

Versions: 15

Compression:

Stored size: 1.03 KB

Contents

require_relative "test_helper"

class ModelTest < Minitest::Test
  def test_disable_callbacks_model
    store_names ["product a"]

    Product.disable_search_callbacks
    assert !Product.search_callbacks?

    store_names ["product b"]
    assert_search "product", ["product a"]

    Product.enable_search_callbacks
    Product.reindex

    assert_search "product", ["product a", "product b"]
  end

  def test_disable_callbacks_global
    # make sure callbacks default to on
    assert Searchkick.callbacks?

    store_names ["product a"]

    Searchkick.disable_callbacks
    assert !Searchkick.callbacks?

    store_names ["product b"]
    assert_search "product", ["product a"]

    Searchkick.enable_callbacks
    Product.reindex

    assert_search "product", ["product a", "product b"]
  end

  def test_multiple_models
    store_names ["Product A"]
    store_names ["Product B"], Speaker
    assert_equal Product.all.to_a + Speaker.all.to_a, Searchkick.search("product", index_name: [Product, Speaker], fields: [:name], order: "name").to_a
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
searchkick-2.5.0 test/model_test.rb
searchkick-hooopo-2.4.1 test/model_test.rb
searchkick-hooopo-2.4.0 test/model_test.rb
searchkick-2.4.0 test/model_test.rb
searchkick-hooopo-2.3.5 test/model_test.rb
searchkick-2.3.2 test/model_test.rb
searchkick-hooopo-2.3.4 test/model_test.rb
searchkick-2.3.1 test/model_test.rb
searchkick-hooopo-2.3.3 test/model_test.rb
searchkick-hooopo-2.3.2 test/model_test.rb
searchkick-hooopo-2.3.1 test/model_test.rb
searchkick-hooopo-2.3.0 test/model_test.rb
searchkick-2.3.0 test/model_test.rb
searchkick-2.2.1 test/model_test.rb
searchkick-2.2.0 test/model_test.rb