From e0a5b748d9eeedc45733010c89566ca0e3772250 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 4 Apr 2013 18:24:06 -0400 Subject: [PATCH] fixes #1149 --- app/logical/post_query_builder.rb | 2 ++ app/models/artist.rb | 2 +- test/unit/post_test.rb | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index b66769884..f7f3e6124 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -157,6 +157,8 @@ class PostQueryBuilder if q[:source] if q[:source] == "none%" relation = relation.where("(posts.source = '' OR posts.source IS NULL)") + elsif q[:source] == "http%" + relation = relation.where("(posts.source like ?)", "http%") elsif q[:source] =~ /^%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/|(?=%$))(.+)$/ relation = relation.where("SourcePattern(posts.source) LIKE ? ESCAPE E'\\\\'", "pixiv/" + $1) has_constraints! diff --git a/app/models/artist.rb b/app/models/artist.rb index 7b9643b6e..8ebf07d8b 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -114,7 +114,7 @@ class Artist < ActiveRecord::Base Artist.new.tap do |artist| if params[:name] artist.name = params[:name] - post = Post.tag_match("source:http* #{artist.name}").first + post = Post.tag_match("source:http #{artist.name}").first unless post.nil? || post.source.blank? artist.url_string = post.source end diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 3fd8ca38b..4b81a3619 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -935,10 +935,10 @@ class PostTest < ActiveSupport::TestCase should "return posts for a pixiv source search" do url = "http://i1.pixiv.net/img123/img/artist-name/789.png" post = FactoryGirl.create(:post, :source => url) - assert_equal(1, Post.tag_match("source:pixiv/artist-name/*").count) - assert_equal(0, Post.tag_match("source:pixiv/artist-fake/*").count) assert_equal(1, Post.tag_match("source:*.pixiv.net/img*/artist-name/*").count) assert_equal(0, Post.tag_match("source:*.pixiv.net/img*/artist-fake/*").count) + assert_equal(1, Post.tag_match("source:pixiv/artist-name/*").count) + assert_equal(0, Post.tag_match("source:pixiv/artist-fake/*").count) end should "return posts for a pixiv id search (type 1)" do