Sha256: d6048fde34db6c55cdaa771dca6a2c4e412de1d432aead8b66766642157adf3d

Contents?: true

Size: 781 Bytes

Versions: 11

Compression:

Stored size: 781 Bytes

Contents

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

class NotTest < SearchCop::TestCase
  def test_not_string
    expected = create(:product, :title => "Expected title")
    rejected = create(:product, :title => "Rejected title")

    results = Product.search("title: Title NOT title: Rejected")

    assert_includes results, expected
    refute_includes results, rejected

    assert_equal results, Product.search("title: Title -title: Rejected")
  end

  def test_not_hash
    expected = create(:product, :title => "Expected title")
    rejected = create(:product, :title => "Rejected title")

    results = Product.search(:and => [{:title => "Title"}, {:not => {:title => "Rejected"}}])

    assert_includes results, expected
    refute_includes results, rejected
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
search_cop-1.1.0 test/not_test.rb
search_cop-1.0.9 test/not_test.rb
search_cop-1.0.8 test/not_test.rb
search_cop-1.0.7 test/not_test.rb
search_cop-1.0.6 test/not_test.rb
search_cop-1.0.5 test/not_test.rb
search_cop-1.0.4 test/not_test.rb
search_cop-1.0.3 test/not_test.rb
search_cop-1.0.2 test/not_test.rb
search_cop-1.0.1 test/not_test.rb
search_cop-1.0.0 test/not_test.rb