Sha256: cd9ebc383528d268189a758c36de919b6baeff18453d15d65c1cf5dfe778a7f4
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require File.expand_path("../test_helper", __FILE__) class AttrSearchableTest < AttrSearchable::TestCase def test_associations product = create(:product, :comments => [ create(:comment, :title => "Title1", :message => "Message1"), create(:comment, :title => "Title2", :message => "Message2") ]) assert_includes Product.search("comment: Title1 comment: Message1"), product assert_includes Product.search("comment: Title2 comment: Message2"), product end def test_multiple product = create(:product, :comments => [create(:comment, :title => "Title", :message => "Message")]) assert_includes Product.search("comment: Title"), product assert_includes Product.search("comment: Message"), product end def test_default product1 = create(:product, :title => "Expected") product2 = create(:product, :description => "Expected") results = Product.search("Expected") assert_includes results, product1 assert_includes results, product2 end def test_custom_default product1 = create(:product, :title => "Expected") product2 = create(:product, :description => "Expected") product3 = create(:product, :brand => "Expected") results = with_attr_searchable_options(Product, :primary, :default => true) { Product.search "Expected" } assert_includes results, product1 assert_includes results, product2 refute_includes results, product3 end def test_count create_list :product, 2, :title => "Expected" assert_equal 2, Product.search("Expected").count end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
attr_searchable-0.0.2 | test/attr_searchable_test.rb |