Skip to content
Browse files

test for multiple named indexes

  • Loading branch information...
1 parent 372eb6f commit f61c14537cb03d1a26c38e84597fb79ea68cbf3e @flavorjones flavorjones committed Oct 14, 2010
Showing with 29 additions and 0 deletions.
  1. +29 −0 test/test_texticle.rb
View
29 test/test_texticle.rb
@@ -102,4 +102,33 @@ def test_dictionary_in_conditions
assert_equal 'spanish', ns[:conditions][1]
end
+ def test_multiple_named_indices
+ x = fake_model
+ x.class_eval do
+ extend Texticle
+ index('uno') do
+ greco
+ end
+ index('due') do
+ guapo
+ end
+ end
+
+ assert_equal :search_uno, x.named_scopes[0].first
+ assert_match(/greco/, x.named_scopes[0][1].call("foo")[:select].first)
+ assert_match(/greco/, x.named_scopes[0][1].call("foo")[:conditions].first)
+
+ assert_equal :tsearch_uno, x.named_scopes[1].first
+ assert_match(/greco/, x.named_scopes[1][1].call("foo")[:select].first)
+ assert_match(/greco/, x.named_scopes[1][1].call("foo")[:conditions].first)
+
+ assert_equal :search_due, x.named_scopes[2].first
+ assert_match(/guapo/, x.named_scopes[2][1].call("foo")[:select].first)
+ assert_match(/guapo/, x.named_scopes[2][1].call("foo")[:conditions].first)
+
+ assert_equal :tsearch_due, x.named_scopes[3].first
+ assert_match(/guapo/, x.named_scopes[3][1].call("foo")[:select].first)
+ assert_match(/guapo/, x.named_scopes[3][1].call("foo")[:conditions].first)
+ end
+
end

0 comments on commit f61c145

Please sign in to comment.
Something went wrong with that request. Please try again.