refactored post search

This commit is contained in:
albert
2012-01-27 13:05:41 -05:00
parent 8b241138cd
commit 75d977ae80
6 changed files with 29 additions and 20 deletions

View File

@@ -830,6 +830,20 @@ class PostTest < ActiveSupport::TestCase
relation = Post.tag_match("order:landscape")
assert_equal(post3.id, relation.first.id)
end
should "fail for exclusive tag searches with no other tag" do
post1 = Factory.create(:post, :rating => "s", :tag_string => "aaa")
assert_raise(::Post::SearchError) do
relation = Post.tag_match("-aaa")
end
end
should "succeed for exclusive tag searches combined with a metatag" do
post1 = Factory.create(:post, :rating => "s", :tag_string => "aaa")
assert_nothing_raised do
relation = Post.tag_match("-aaa id:>0")
end
end
end
context "Voting:" do

View File

@@ -31,6 +31,8 @@ class TagAliasTest < ActiveSupport::TestCase
tag1 = Factory.create(:tag, :name => "aaa")
tag2 = Factory.create(:tag, :name => "bbb")
ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
assert_nil(MEMCACHE.get("ta:aaa"))
ta.update_cache
assert_equal("bbb", MEMCACHE.get("ta:aaa"))
ta.destroy
assert_nil(MEMCACHE.get("ta:aaa"))