fix tests
This commit is contained in:
@@ -27,7 +27,7 @@ module Sources
|
|||||||
def get_profile_from_page(page)
|
def get_profile_from_page(page)
|
||||||
profile_url = page.search("a.user-link").first
|
profile_url = page.search("a.user-link").first
|
||||||
if profile_url
|
if profile_url
|
||||||
profile_url = profile_url["href"]
|
profile_url = "http://www.pixiv.net" + profile_url["href"]
|
||||||
end
|
end
|
||||||
|
|
||||||
artist_name = page.search("h1.user").first
|
artist_name = page.search("h1.user").first
|
||||||
|
|||||||
@@ -596,10 +596,6 @@ class Post < ActiveRecord::Base
|
|||||||
def fast_count(tags = "")
|
def fast_count(tags = "")
|
||||||
tags = tags.to_s.strip
|
tags = tags.to_s.strip
|
||||||
|
|
||||||
if tags.blank?
|
|
||||||
return Danbooru.config.blank_tag_search_fast_count || 1_000_000
|
|
||||||
end
|
|
||||||
|
|
||||||
count = get_count_from_cache(tags)
|
count = get_count_from_cache(tags)
|
||||||
if count.nil?
|
if count.nil?
|
||||||
if tags.blank? && Danbooru.config.blank_tag_search_fast_count
|
if tags.blank? && Danbooru.config.blank_tag_search_fast_count
|
||||||
@@ -615,7 +611,7 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
count
|
count.to_i
|
||||||
rescue SearchError
|
rescue SearchError
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ module Moderator
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "find by ip addr" do
|
should "find by ip addr" do
|
||||||
@search = IpAddrSearch.new(:ip_addr_eq => "127.0.0.1")
|
@search = IpAddrSearch.new(:ip_addr => "127.0.0.1")
|
||||||
assert_equal({@user.id.to_s => 2}, @search.execute)
|
assert_equal({@user.id.to_s => 2}, @search.execute)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "find by user id" do
|
should "find by user id" do
|
||||||
@search = IpAddrSearch.new(:user_id_eq => @user.id.to_s)
|
@search = IpAddrSearch.new(:user_id => @user.id.to_s)
|
||||||
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "find by user name" do
|
should "find by user name" do
|
||||||
@search = IpAddrSearch.new(:user_name_eq => @user.name)
|
@search = IpAddrSearch.new(:user_name => @user.name)
|
||||||
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -759,7 +759,7 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
assert_equal(post1.id, relation.first.id)
|
assert_equal(post1.id, relation.first.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return posts for the <uploader> metatag" do
|
should "return posts for the <user> metatag" do
|
||||||
second_user = FactoryGirl.create(:user)
|
second_user = FactoryGirl.create(:user)
|
||||||
post1 = FactoryGirl.create(:post, :uploader => CurrentUser.user)
|
post1 = FactoryGirl.create(:post, :uploader => CurrentUser.user)
|
||||||
|
|
||||||
@@ -770,7 +770,7 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
post3 = FactoryGirl.create(:post)
|
post3 = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
relation = Post.tag_match("uploader:#{CurrentUser.user.name}")
|
relation = Post.tag_match("user:#{CurrentUser.user.name}")
|
||||||
assert_equal(1, relation.count)
|
assert_equal(1, relation.count)
|
||||||
assert_equal(post1.id, relation.first.id)
|
assert_equal(post1.id, relation.first.id)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user