diff --git a/test/fixtures/vcr_cassettes/functional/upload/twitter.yml b/test/fixtures/vcr_cassettes/functional/upload/twitter.yml new file mode 100644 index 000000000..7a77115bd --- /dev/null +++ b/test/fixtures/vcr_cassettes/functional/upload/twitter.yml @@ -0,0 +1,181 @@ +--- +http_interactions: +- request: + method: post + uri: https://xxx:xxx@api.twitter.com/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials + headers: + Accept: + - "*/*" + User-Agent: + - TwitterRubyGem/5.13.0 + Content-Type: + - application/x-www-form-urlencoded; charset=UTF-8 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - no-cache, no-store, must-revalidate, pre-check=0, post-check=0 + Content-Disposition: + - attachment; filename=json.json + Content-Length: + - '151' + Content-Type: + - application/json;charset=utf-8 + Date: + - Sun, 15 Feb 2015 20:31:56 UTC + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Sun, 15 Feb 2015 20:31:56 GMT + Ml: + - S + Pragma: + - no-cache + Server: + - tsa_a + Set-Cookie: + - guest_id=v1%3A142403231671754791; Domain=.twitter.com; Path=/; Expires=Tue, + 14-Feb-2017 20:31:56 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Connection-Hash: + - e59c0730246808b49d25ec8d6c23809c + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Response-Time: + - '8' + X-Transaction: + - d432952fa285b77c + X-Twitter-Response-Tags: + - BouncerCompliant + X-Ua-Compatible: + - IE=edge,chrome=1 + X-Xss-Protection: + - 1; mode=block + body: + encoding: UTF-8 + string: '{"token_type":"bearer","access_token":"1234"}' + http_version: + recorded_at: Sun, 15 Feb 2015 20:31:56 GMT +- request: + method: post + uri: https://collector.newrelic.com/agent_listener/14//get_redirect_host?marshal_format=json + body: + encoding: UTF-8 + string: "[]" + headers: + Content-Encoding: + - identity + Host: + - collector.newrelic.com + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - NewRelic-RubyAgent/3.9.6.257 (ruby 2.1.5 x86_64-darwin13.0) zlib/1.2.5 + Content-Type: + - application/octet-stream + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/plain + Content-Length: + - '133' + body: + encoding: UTF-8 + string: '{"exception":{"message":"Invalid license key, please contact support@newrelic.com","error_type":"NewRelic::Agent::LicenseException"}}' + http_version: + recorded_at: Sun, 15 Feb 2015 20:31:56 GMT +- request: + method: get + uri: https://api.twitter.com/1.1/statuses/show/567054278486151168.json + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - TwitterRubyGem/5.13.0 + Authorization: + - Bearer 1234 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - no-cache, no-store, must-revalidate, pre-check=0, post-check=0 + Content-Disposition: + - attachment; filename=json.json + Content-Length: + - '1296' + Content-Type: + - application/json;charset=utf-8 + Date: + - Sun, 15 Feb 2015 20:31:56 UTC + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Sun, 15 Feb 2015 20:31:56 GMT + Pragma: + - no-cache + Server: + - tsa_a + Set-Cookie: + - guest_id=v1%3A142403231691602509; Domain=.twitter.com; Path=/; Expires=Tue, + 14-Feb-2017 20:31:56 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Access-Level: + - read + X-Connection-Hash: + - cff42fb8f6378031df40833921215bad + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Rate-Limit-Limit: + - '180' + X-Rate-Limit-Remaining: + - '179' + X-Rate-Limit-Reset: + - '1424033216' + X-Response-Time: + - '17' + X-Transaction: + - abfaa50980d03461 + X-Twitter-Response-Tags: + - BouncerCompliant + X-Xss-Protection: + - 1; mode=block + body: + encoding: UTF-8 + string: '{"created_at":"Sun Feb 15 20:14:10 +0000 2015","id":567054278486151168,"id_str":"567054278486151168","text":"Those + are the same person. #CrossAnge http:\/\/t.co\/zX5p4AOUoA","source":"\u003ca + href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":68692042,"id_str":"68692042","name":"lvlln","screen_name":"lvlln","location":"Arlington, + MA","profile_location":null,"description":"Just a quant who enjoys anime and + video games and ultimate. Blogs on Metanorn. I help to run http:\/\/t.co\/ilgVSv62tc","url":"http:\/\/t.co\/NXLDfpT1OT","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/NXLDfpT1OT","expanded_url":"http:\/\/metanorn.net","display_url":"metanorn.net","indices":[0,22]}]},"description":{"urls":[{"url":"http:\/\/t.co\/ilgVSv62tc","expanded_url":"http:\/\/mirroredanimescreenshots.tumblr.com","display_url":"mirroredanimescreenshots.tumblr.com","indices":[93,115]}]}},"protected":false,"followers_count":966,"friends_count":744,"listed_count":47,"created_at":"Tue + Aug 25 13:28:39 +0000 2009","favourites_count":5768,"utc_offset":null,"time_zone":null,"geo_enabled":true,"verified":false,"statuses_count":53500,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/537958726\/540597.jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/537958726\/540597.jpg","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/2631613491\/3b689e982e21419870a31c4cd4205a03_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/2631613491\/3b689e982e21419870a31c4cd4205a03_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/68692042\/1399737095","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":11,"favorite_count":5,"entities":{"hashtags":[{"text":"CrossAnge","indices":[27,37]}],"symbols":[],"user_mentions":[],"urls":[],"media":[{"id":567054271943016448,"id_str":"567054271943016448","indices":[38,60],"media_url":"http:\/\/pbs.twimg.com\/media\/B96U2x-IAAAR-ih.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B96U2x-IAAAR-ih.jpg","url":"http:\/\/t.co\/zX5p4AOUoA","display_url":"pic.twitter.com\/zX5p4AOUoA","expanded_url":"http:\/\/twitter.com\/lvlln\/status\/567054278486151168\/photo\/1","type":"photo","sizes":{"thumb":{"w":150,"h":150,"resize":"crop"},"small":{"w":340,"h":191,"resize":"fit"},"medium":{"w":600,"h":337,"resize":"fit"},"large":{"w":1024,"h":576,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":567054271943016448,"id_str":"567054271943016448","indices":[38,60],"media_url":"http:\/\/pbs.twimg.com\/media\/B96U2x-IAAAR-ih.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B96U2x-IAAAR-ih.jpg","url":"http:\/\/t.co\/zX5p4AOUoA","display_url":"pic.twitter.com\/zX5p4AOUoA","expanded_url":"http:\/\/twitter.com\/lvlln\/status\/567054278486151168\/photo\/1","type":"photo","sizes":{"thumb":{"w":150,"h":150,"resize":"crop"},"small":{"w":340,"h":191,"resize":"fit"},"medium":{"w":600,"h":337,"resize":"fit"},"large":{"w":1024,"h":576,"resize":"fit"}}},{"id":567054271989182465,"id_str":"567054271989182465","indices":[38,60],"media_url":"http:\/\/pbs.twimg.com\/media\/B96U2yJIcAEKsHw.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B96U2yJIcAEKsHw.jpg","url":"http:\/\/t.co\/zX5p4AOUoA","display_url":"pic.twitter.com\/zX5p4AOUoA","expanded_url":"http:\/\/twitter.com\/lvlln\/status\/567054278486151168\/photo\/1","type":"photo","sizes":{"thumb":{"w":150,"h":150,"resize":"crop"},"small":{"w":340,"h":191,"resize":"fit"},"medium":{"w":600,"h":337,"resize":"fit"},"large":{"w":1024,"h":576,"resize":"fit"}}}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"}' + http_version: + recorded_at: Sun, 15 Feb 2015 20:31:56 GMT +recorded_with: VCR 2.9.0 diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index 4472ff6fe..40abe02ec 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -13,6 +13,22 @@ class UploadsControllerTest < ActionController::TestCase CurrentUser.ip_addr = nil end + context "batch action" do + context "for twitter galleries" do + setup do + Danbooru.config.stubs(:twitter_api_key).returns("xxx") + Danbooru.config.stubs(:twitter_api_secret).returns("xxx") + end + + should "render" do + VCR.use_cassette("functional/upload/twitter", :record => :none) do + get :batch, {:url => "https://twitter.com/lvlln/status/567054278486151168"}, {:user_id => @user.id} + end + assert_response :success + end + end + end + context "new action" do should "render" do get :new, {}, {:user_id => @user.id}