fixes #796
This commit is contained in:
@@ -10,7 +10,7 @@ module Danbooru
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_escaped_for_tsquery
|
def to_escaped_for_tsquery
|
||||||
"'#{gsub(/\\|'/, '\0\0\0\0')}'"
|
"'#{gsub(/'/, '\0\0').gsub(/\\/, '\0\0\0\0')}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_escaped_js
|
def to_escaped_js
|
||||||
|
|||||||
@@ -757,6 +757,34 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Searching:" do
|
context "Searching:" do
|
||||||
|
should "return posts for the ' tag" do
|
||||||
|
post1 = FactoryGirl.create(:post, :tag_string => "'")
|
||||||
|
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||||
|
count = Post.tag_match("'").count
|
||||||
|
assert_equal(1, count)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return posts for the \\ tag" do
|
||||||
|
post1 = FactoryGirl.create(:post, :tag_string => "\\")
|
||||||
|
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||||
|
count = Post.tag_match("\\").count
|
||||||
|
assert_equal(1, count)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return posts for the ( tag" do
|
||||||
|
post1 = FactoryGirl.create(:post, :tag_string => "(")
|
||||||
|
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||||
|
count = Post.tag_match("(").count
|
||||||
|
assert_equal(1, count)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return posts for the ? tag" do
|
||||||
|
post1 = FactoryGirl.create(:post, :tag_string => "?")
|
||||||
|
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||||
|
count = Post.tag_match("?").count
|
||||||
|
assert_equal(1, count)
|
||||||
|
end
|
||||||
|
|
||||||
should "return posts for 1 tag" do
|
should "return posts for 1 tag" do
|
||||||
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||||
|
|||||||
Reference in New Issue
Block a user