Sha256: f6262f89c86b570229b5e9de2f7db01ad75a7dd749f2d4daa067ec82982e215c

Contents?: true

Size: 747 Bytes

Versions: 4

Compression:

Stored size: 747 Bytes

Contents

require File.expand_path("test_helper", __dir__)

class FulltextTest < SearchCop::TestCase
  def test_complex
    product1 = create(:product, title: "word1")
    product2 = create(:product, title: "word2 word3")
    product3 = create(:product, title: "word2")

    results = Product.search("word1 OR (title:word2 -word3)")

    assert_includes results, product1
    refute_includes results, product2
    assert_includes results, product3
  end

  def test_mixed
    expected = create(:product, title: "Expected title", stock: 1)
    rejected = create(:product, title: "Expected title", stock: 0)

    results = Product.search("Expected title:Title stock > 0")

    assert_includes results, expected
    refute_includes results, rejected
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
search_cop-1.2.3 test/fulltext_test.rb
search_cop-1.2.2 test/fulltext_test.rb
search_cop-1.2.1 test/fulltext_test.rb
search_cop-1.2.0 test/fulltext_test.rb