Sha256: e839b7f6fa59553880136a75b6e93fd3b2f67d88828f12b096839c31d1e175d0

Contents?: true

Size: 792 Bytes

Versions: 7

Compression:

Stored size: 792 Bytes

Contents

require File.expand_path("../test_helper", __FILE__)

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("title:word1 OR (title:word2 -title: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("title:Expected title:Title stock > 0")

    assert_includes results, expected
    refute_includes results, rejected
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
search_cop-1.0.6 test/fulltext_test.rb
search_cop-1.0.5 test/fulltext_test.rb
search_cop-1.0.4 test/fulltext_test.rb
search_cop-1.0.3 test/fulltext_test.rb
search_cop-1.0.2 test/fulltext_test.rb
search_cop-1.0.1 test/fulltext_test.rb
search_cop-1.0.0 test/fulltext_test.rb