From 0f513d1a1bf4935a435f4b92a5226ac252e7e66b Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 27 Dec 2018 15:03:11 -0600 Subject: [PATCH] twitter: include intent url in new artist entries (#4028). --- app/logical/sources/strategies/twitter.rb | 13 ++++++++++++- test/unit/sources/twitter_test.rb | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/logical/sources/strategies/twitter.rb b/app/logical/sources/strategies/twitter.rb index 2f9d714fe..63dfd489a 100644 --- a/app/logical/sources/strategies/twitter.rb +++ b/app/logical/sources/strategies/twitter.rb @@ -62,10 +62,21 @@ module Sources::Strategies end def profile_url - return "" if artist_name.blank? + return nil if artist_name.blank? "https://twitter.com/#{artist_name}" end + def intent_url + return nil if api_response.blank? + + user_id = api_response.attrs[:user][:id_str] + "https://twitter.com/intent/user?user_id=#{user_id}" + end + + def profile_urls + [profile_url, intent_url].compact + end + def artist_name if artist_name_from_url.present? artist_name_from_url diff --git a/test/unit/sources/twitter_test.rb b/test/unit/sources/twitter_test.rb index 6ba806042..633d1dfc1 100644 --- a/test/unit/sources/twitter_test.rb +++ b/test/unit/sources/twitter_test.rb @@ -111,10 +111,15 @@ module Sources @site = Sources::Strategies.find("https://mobile.twitter.com/nounproject/status/540944400767922176") end - should "get the profile" do + should "get the main profile url" do assert_equal("https://twitter.com/nounproject", @site.profile_url) end + should "get the profile urls" do + assert_includes(@site.profile_urls, "https://twitter.com/nounproject") + assert_includes(@site.profile_urls, "https://twitter.com/intent/user?user_id=88996186") + end + should "get the artist name" do assert_equal("nounproject", @site.artist_name) end