This commit is contained in:
albert
2013-03-08 15:56:24 -05:00
parent c3ac9832f9
commit 1a03f49adc
6 changed files with 37 additions and 12 deletions

View File

@@ -909,6 +909,13 @@ class PostTest < ActiveSupport::TestCase
assert_equal(post2.id, relation.first.id)
end
should "return posts for a case sensitive source search" do
post1 = FactoryGirl.create(:post, :source => "ABCD")
post2 = FactoryGirl.create(:post, :source => "1234")
relation = Post.tag_match("source:ABCD")
assert_equal(1, relation.count)
end
should "return posts for a pixiv source search" do
post = FactoryGirl.create(:post, :source => "http://i1.pixiv.net/img123/img/artist-name/789.png")
assert_equal(1, Post.tag_match("source:pixiv/artist-name/*").count)

View File

@@ -101,12 +101,12 @@ class TagTest < ActiveSupport::TestCase
context "A tag parser" do
should "scan a query" do
assert_equal(%w(aaa bbb), Tag.scan_query("aaa bbb"))
assert_equal(%w(~aaa -bbb*), Tag.scan_query("~AAa -BBB* -bbb*"))
assert_equal(%w(~AAa -BBB* -bbb*), Tag.scan_query("~AAa -BBB* -bbb*"))
end
should "strip out invalid characters when scanning" do
assert_equal(%w(aaa bbb), Tag.scan_tags("aaa bbb"))
assert_equal(%w(-bb;b* -b_b_b_), Tag.scan_tags("-B,B;B* -b_b_b_"))
assert_equal(%w(-BB;B* -b_b_b_), Tag.scan_tags("-B,B;B* -b_b_b_"))
end
should "cast values" do