diff --git a/test/functional/sources_controller_test.rb b/test/functional/sources_controller_test.rb index f78df071b..3012cad43 100644 --- a/test/functional/sources_controller_test.rb +++ b/test/functional/sources_controller_test.rb @@ -3,10 +3,20 @@ require 'test_helper' class SourcesControllerTest < ActionController::TestCase context "The sources controller" do context "show action" do - should "work" do + should "work for a pixiv URL" do get :show, { url: "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=14901720", format: "json" } assert_response :success end + + should "work for a direct twitter URL with referer" do + get :show, { + url: "https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:large", + ref: "https://twitter.com/nounproject/status/540944400767922176", + format: "json" + } + + assert_response :success + end end end end diff --git a/test/unit/sources/twitter_test.rb b/test/unit/sources/twitter_test.rb index 31114e1c8..38cb6b8a5 100644 --- a/test/unit/sources/twitter_test.rb +++ b/test/unit/sources/twitter_test.rb @@ -123,6 +123,21 @@ module Sources end end + context "The source site for a direct image and a referer" do + setup do + @site = Sources::Site.new("https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:large", referer_url: "https://twitter.com/nounproject/status/540944400767922176") + @site.get + end + + should "get the artist name" do + assert_equal("Noun Project", @site.artist_name) + end + + should "get the image url" do + assert_equal("https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:orig", @site.image_url) + end + end + context "A tweet" do setup do @site = Sources::Site.new("https://twitter.com/noizave/status/875768175136317440")