pawoo: don't return bogus artists when artist finder doesn't find a match.

This commit is contained in:
evazion
2017-06-13 01:13:13 -05:00
parent 655e53fe65
commit 3560bbbd47
2 changed files with 20 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ class Artist < ApplicationRecord
break if url =~ /(?:data|media)\.tumblr\.com\/[a-z0-9]+\/$/i
break if url =~ /deviantart\.net\//i
break if url =~ %r!\Ahttps?://(?:mobile\.)?twitter\.com/\Z!i
break if url =~ %r!pawoo\.net/(?:web/)?$!i
end
artists.inject({}) {|h, x| h[x.name] = x; h}.values.slice(0, 20)

View File

@@ -291,6 +291,25 @@ class ArtistTest < ActiveSupport::TestCase
end
end
context "when finding pawoo artists" do
setup do
FactoryGirl.create(:artist, :name => "evazion", :url_string => "https://pawoo.net/@evazion")
FactoryGirl.create(:artist, :name => "yasumo01", :url_string => "https://pawoo.net/web/accounts/28816")
end
should "find the artist" do
assert_artist_found("evazion", "https://pawoo.net/@evazion/19451018")
assert_artist_found("evazion", "https://pawoo.net/web/statuses/19451018")
assert_artist_found("yasumo01", "https://pawoo.net/@yasumo01/222337")
assert_artist_found("yasumo01", "https://pawoo.net/web/statuses/222337")
end
should "return nothing for unknown pawoo sources" do
assert_artist_not_found("https://pawoo.net/@9ed00e924818/1202176")
assert_artist_not_found("https://pawoo.net/web/statuses/1202176")
end
end
should "normalize its other names" do
artist = FactoryGirl.create(:artist, :name => "a1", :other_names_comma => "aaa, bbb, ccc ddd")
assert_equal("aaa, bbb, ccc_ddd", artist.other_names_comma)