Sha256: 8844a90dc9522cd0349b3635f3e275e31b3d7f64d0328d49227943000cc5a665

Contents?: true

Size: 837 Bytes

Versions: 11

Compression:

Stored size: 837 Bytes

Contents

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

class OrTest < SearchCop::TestCase
  def test_or_string
    product1 = create(:product, :title => "Title1")
    product2 = create(:product, :title => "Title2")
    product3 = create(:product, :title => "Title3")

    results = Product.search("title: Title1 OR title: Title2")

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

  def test_or_hash
    product1 = create(:product, :title => "Title1")
    product2 = create(:product, :title => "Title2")
    product3 = create(:product, :title => "Title3")

    results = Product.search(:or => [{:title => "Title1"}, {:title => "Title2"}])

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

Version data entries

11 entries across 11 versions & 1 rubygems

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