Sha256: e68a21dea2504656eee2bec8b055818b872af96c3e14e6be9a7be3a6dc68bf83

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

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

class OrTest < AttrSearchable::TestCase
  def test_or_string
    product1 = FactoryGirl.create(:product, :title => "Title1")
    product2 = FactoryGirl.create(:product, :title => "Title2")
    product3 = FactoryGirl.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 = FactoryGirl.create(:product, :title => "Title1")
    product2 = FactoryGirl.create(:product, :title => "Title2")
    product3 = FactoryGirl.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

1 entries across 1 versions & 1 rubygems

Version Path
attr_searchable-0.0.1 test/or_test.rb