twitter: fix parsing of the artist name from the url.
Fixes URLs like https://twitter.com/intent/user?user_id=123 being incorrectly normalized to http://twitter.com/intent/ in artist entries. Also fixes the artist name to be taken from the url when it can't be obtained from the api (when the tweet is deleted).
This commit is contained in:
@@ -152,6 +152,12 @@ class ArtistUrlTest < ActiveSupport::TestCase
|
||||
assert_equal("http://twitter.com/aoimanabu/", url.normalized_url)
|
||||
end
|
||||
|
||||
should "normalize https://twitter.com/intent/user?user_id=* urls" do
|
||||
url = FactoryBot.create(:artist_url, :url => "https://twitter.com/intent/user?user_id=2784590030")
|
||||
assert_equal("https://twitter.com/intent/user?user_id=2784590030", url.url)
|
||||
assert_equal("http://twitter.com/intent/user?user_id=2784590030/", url.normalized_url)
|
||||
end
|
||||
|
||||
should "normalize nijie urls" do
|
||||
url = FactoryBot.create(:artist_url, url: "https://pic03.nijie.info/nijie_picture/236014_20170620101426_0.png")
|
||||
assert_equal("http://nijie.info/members.php?id=161703/", url.normalized_url)
|
||||
|
||||
@@ -91,7 +91,6 @@ module Sources
|
||||
setup do
|
||||
skip "Twitter key is not set" unless Danbooru.config.twitter_api_key
|
||||
@site = Sources::Strategies.find("https://mobile.twitter.com/Strangestone/status/556440271961858051")
|
||||
|
||||
end
|
||||
|
||||
should "get the image url" do
|
||||
@@ -177,6 +176,17 @@ module Sources
|
||||
end
|
||||
end
|
||||
|
||||
context "A deleted tweet" do
|
||||
should "still find the artist name" do
|
||||
@site = Sources::Strategies.find("https://twitter.com/masayasuf/status/870734961778630656")
|
||||
@artist = FactoryBot.create(:artist, name: "masayasuf", url_string: @site.url)
|
||||
|
||||
assert_equal("masayasuf", @site.artist_name)
|
||||
assert_equal("https://twitter.com/masayasuf", @site.profile_url)
|
||||
assert_equal([@artist], @site.artists)
|
||||
end
|
||||
end
|
||||
|
||||
context "A tweet" do
|
||||
setup do
|
||||
skip "Twitter key is not set" unless Danbooru.config.twitter_api_key
|
||||
|
||||
Reference in New Issue
Block a user