Sha256: 4ee64f28e5bdc5cb4b543b5dfd47b644267b7744c2a42aab3e0bc9074f0acf35

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 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 + Speaker.all, Searchkick.search("product", index_name: [Product, Speaker], fields: [:name], order: "name").to_a
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
searchkick-2.1.1 test/model_test.rb
searchkick-2.1.0 test/model_test.rb
searchkick-2.0.4 test/model_test.rb
searchkick-2.0.3 test/model_test.rb
searchkick-2.0.2 test/model_test.rb
searchkick-2.0.1 test/model_test.rb
searchkick-2.0.0 test/model_test.rb
searchkick-1.5.1 test/model_test.rb
searchkick-1.5.0 test/model_test.rb