From 09f71f79d13d7a52d98faccd67c36e4dbcfeb72f Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 11 Jun 2015 21:59:30 -0700 Subject: [PATCH] fix tests --- Gemfile | 2 +- .../functional/upload/twitter.yml | 297 ++++++++++++++++++ .../vcr_cassettes/upload-new-twitter.yml | 208 ++++++++++++ test/functional/uploads_controller_test.rb | 12 +- test/unit/forum_post_test.rb | 27 -- 5 files changed, 512 insertions(+), 34 deletions(-) create mode 100644 test/fixtures/vcr_cassettes/functional/upload/twitter.yml create mode 100644 test/fixtures/vcr_cassettes/upload-new-twitter.yml diff --git a/Gemfile b/Gemfile index e99522f18..01d739845 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,6 @@ gem 'rmagick' gem 'daemons' gem 'net-ssh' gem 'net-sftp' -gem 'newrelic_rpm' gem 'term-ansicolor', :require => "term/ansicolor" gem 'diff-lcs', :require => "diff/lcs/array" gem 'bcrypt-ruby', :require => "bcrypt" @@ -58,6 +57,7 @@ gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888 gem 'aws-s3', :require => "aws/s3", :git => "https://github.com/fnando/aws-s3.git" group :production do + gem 'newrelic_rpm' gem 'unicorn', :platforms => :ruby # gem 'unicorn-worker-killer' gem 'gctools', :platforms => :ruby 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..5b7dfdc92 --- /dev/null +++ b/test/fixtures/vcr_cassettes/functional/upload/twitter.yml @@ -0,0 +1,297 @@ +--- +http_interactions: +- request: + method: post + uri: https://SENSITIVE:SENSITIVE@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: + - Fri, 12 Jun 2015 04:57:34 GMT + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Fri, 12 Jun 2015 04:57:34 GMT + Ml: + - A + Pragma: + - no-cache + Server: + - tsa_b + Set-Cookie: + - guest_id=v1%3A143408505467055919; Domain=.twitter.com; Path=/; Expires=Sun, + 11-Jun-2017 04:57:34 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Connection-Hash: + - 93143bc0b586b17b5a859c69ca8f0998 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Response-Time: + - '8' + X-Transaction: + - 6d8adb7da07e9173 + X-Tsa-Request-Body-Time: + - '2' + 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":"AAAAAAAAAAAAAAAAAAAAAPV7eAAAAAAAN7q56yJ8wNHhsagDn06qiJ0Io00%3DfdvXQaVKHFS3q1hd3y8fVQdIbntIHN2iTsBTk0f6jQK7lxcDo5"}' + http_version: + recorded_at: Fri, 12 Jun 2015 04:57:34 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 AAAAAAAAAAAAAAAAAAAAAPV7eAAAAAAAN7q56yJ8wNHhsagDn06qiJ0Io00%3DfdvXQaVKHFS3q1hd3y8fVQdIbntIHN2iTsBTk0f6jQK7lxcDo5 + 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: + - '1312' + Content-Type: + - application/json;charset=utf-8 + Date: + - Fri, 12 Jun 2015 04:57:35 GMT + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Fri, 12 Jun 2015 04:57:35 GMT + Pragma: + - no-cache + Server: + - tsa_b + Set-Cookie: + - guest_id=v1%3A143408505504851045; Domain=.twitter.com; Path=/; Expires=Sun, + 11-Jun-2017 04:57:35 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Access-Level: + - read + X-Connection-Hash: + - ca28ace74b013f3f9df6d0649e16d568 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Rate-Limit-Limit: + - '180' + X-Rate-Limit-Remaining: + - '176' + X-Rate-Limit-Reset: + - '1434085564' + X-Response-Time: + - '19' + X-Transaction: + - bfbf726353356118 + 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","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":1047,"friends_count":814,"listed_count":47,"created_at":"Tue + Aug 25 13:28:39 +0000 2009","favourites_count":7690,"utc_offset":null,"time_zone":null,"geo_enabled":true,"verified":false,"statuses_count":59165,"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,"is_quote_status":false,"retweet_count":30,"favorite_count":23,"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,"possibly_sensitive_appealable":false,"lang":"en"}' + http_version: + recorded_at: Fri, 12 Jun 2015 04:57:35 GMT +- request: + method: post + uri: https://ocqPCKeWr01mvWzCIcveJYRTY:8GECMr2Ves7oK3bmAneHYMLSfDPoJvTizh5gSd4pLBNbJfYNz5@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: + - Fri, 12 Jun 2015 04:57:35 GMT + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Fri, 12 Jun 2015 04:57:35 GMT + Ml: + - A + Pragma: + - no-cache + Server: + - tsa_b + Set-Cookie: + - guest_id=v1%3A143408505550836729; Domain=.twitter.com; Path=/; Expires=Sun, + 11-Jun-2017 04:57:35 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Connection-Hash: + - eafe2c6429da14de24575e57c9fafe6e + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Response-Time: + - '9' + X-Transaction: + - 1d1a45728a60d6fd + X-Tsa-Request-Body-Time: + - '1' + 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":"AAAAAAAAAAAAAAAAAAAAAPV7eAAAAAAAN7q56yJ8wNHhsagDn06qiJ0Io00%3DfdvXQaVKHFS3q1hd3y8fVQdIbntIHN2iTsBTk0f6jQK7lxcDo5"}' + http_version: + recorded_at: Fri, 12 Jun 2015 04:57:35 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 AAAAAAAAAAAAAAAAAAAAAPV7eAAAAAAAN7q56yJ8wNHhsagDn06qiJ0Io00%3DfdvXQaVKHFS3q1hd3y8fVQdIbntIHN2iTsBTk0f6jQK7lxcDo5 + 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: + - '1312' + Content-Type: + - application/json;charset=utf-8 + Date: + - Fri, 12 Jun 2015 04:57:35 GMT + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Fri, 12 Jun 2015 04:57:35 GMT + Pragma: + - no-cache + Server: + - tsa_b + Set-Cookie: + - guest_id=v1%3A143408505587151668; Domain=.twitter.com; Path=/; Expires=Sun, + 11-Jun-2017 04:57:35 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Access-Level: + - read + X-Connection-Hash: + - 3a8fda9324f4fb2f6894385826ebc510 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Rate-Limit-Limit: + - '180' + X-Rate-Limit-Remaining: + - '175' + X-Rate-Limit-Reset: + - '1434085564' + X-Response-Time: + - '21' + X-Transaction: + - 846bd6c43d56fc48 + 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","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":1047,"friends_count":814,"listed_count":47,"created_at":"Tue + Aug 25 13:28:39 +0000 2009","favourites_count":7690,"utc_offset":null,"time_zone":null,"geo_enabled":true,"verified":false,"statuses_count":59165,"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,"is_quote_status":false,"retweet_count":30,"favorite_count":23,"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,"possibly_sensitive_appealable":false,"lang":"en"}' + http_version: + recorded_at: Fri, 12 Jun 2015 04:57:35 GMT +recorded_with: VCR 2.9.0 diff --git a/test/fixtures/vcr_cassettes/upload-new-twitter.yml b/test/fixtures/vcr_cassettes/upload-new-twitter.yml new file mode 100644 index 000000000..26f211d1b --- /dev/null +++ b/test/fixtures/vcr_cassettes/upload-new-twitter.yml @@ -0,0 +1,208 @@ +--- +http_interactions: +- request: + method: post + uri: https://ocqPCKeWr01mvWzCIcveJYRTY:8GECMr2Ves7oK3bmAneHYMLSfDPoJvTizh5gSd4pLBNbJfYNz5@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: + - Fri, 12 Jun 2015 04:51:04 GMT + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Fri, 12 Jun 2015 04:51:04 GMT + Ml: + - S + Pragma: + - no-cache + Server: + - tsa_b + Set-Cookie: + - guest_id=v1%3A143408466430438117; Domain=.twitter.com; Path=/; Expires=Sun, + 11-Jun-2017 04:51:04 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Connection-Hash: + - cec49fc98954d6be2b882737bf836056 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Response-Time: + - '106' + X-Transaction: + - 9b4a10e04933fdf2 + X-Tsa-Request-Body-Time: + - '2' + 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":"AAAAAAAAAAAAAAAAAAAAAPV7eAAAAAAAN7q56yJ8wNHhsagDn06qiJ0Io00%3DfdvXQaVKHFS3q1hd3y8fVQdIbntIHN2iTsBTk0f6jQK7lxcDo5"}' + http_version: + recorded_at: Fri, 12 Jun 2015 04:51:04 GMT +- request: + method: get + uri: https://api.twitter.com/1.1/statuses/show/566030116182949888.json + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - TwitterRubyGem/5.13.0 + Authorization: + - Bearer AAAAAAAAAAAAAAAAAAAAAPV7eAAAAAAAN7q56yJ8wNHhsagDn06qiJ0Io00%3DfdvXQaVKHFS3q1hd3y8fVQdIbntIHN2iTsBTk0f6jQK7lxcDo5 + 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: + - '1254' + Content-Type: + - application/json;charset=utf-8 + Date: + - Fri, 12 Jun 2015 04:51:04 GMT + Expires: + - Tue, 31 Mar 1981 05:00:00 GMT + Last-Modified: + - Fri, 12 Jun 2015 04:51:04 GMT + Pragma: + - no-cache + Server: + - tsa_b + Set-Cookie: + - guest_id=v1%3A143408466476813785; Domain=.twitter.com; Path=/; Expires=Sun, + 11-Jun-2017 04:51:04 UTC + Status: + - 200 OK + Strict-Transport-Security: + - max-age=631138519 + X-Access-Level: + - read + X-Connection-Hash: + - e2d4cf83697658035172a98c60ac1baf + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Rate-Limit-Limit: + - '180' + X-Rate-Limit-Remaining: + - '179' + X-Rate-Limit-Reset: + - '1434085564' + X-Response-Time: + - '20' + X-Transaction: + - 033e4b0bf5892168 + X-Twitter-Response-Tags: + - BouncerCompliant + X-Xss-Protection: + - 1; mode=block + body: + encoding: UTF-8 + string: '{"created_at":"Fri Feb 13 00:24:30 +0000 2015","id":566030116182949888,"id_str":"566030116182949888","text":"What + do you give the Caramel Frappuccino that already has everything? The gift + of mocha drizzle. http:\/\/t.co\/2MWtXbYhf0","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" + rel=\"nofollow\"\u003eTwitter for iPhone\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":127566622,"id_str":"127566622","name":"Frappuccino","screen_name":"frappuccino","location":"Seattle, + WA","description":"Le yum. #FanFlavors","url":"http:\/\/t.co\/0o8bfJcGJW","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/0o8bfJcGJW","expanded_url":"http:\/\/sbux.co\/FanFlavors","display_url":"sbux.co\/FanFlavors","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":183232,"friends_count":68060,"listed_count":719,"created_at":"Mon + Mar 29 16:30:39 +0000 2010","favourites_count":3731,"utc_offset":-25200,"time_zone":"Pacific + Time (US & Canada)","geo_enabled":true,"verified":true,"statuses_count":12141,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"9AE4E8","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/486908690591535104\/roRpLqRU.jpeg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/486908690591535104\/roRpLqRU.jpeg","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/593460960020402176\/B_NNVW9D_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/593460960020402176\/B_NNVW9D_normal.png","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/127566622\/1420826895","profile_link_color":"0084B4","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDFFCC","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,"is_quote_status":false,"retweet_count":632,"favorite_count":2379,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[],"media":[{"id":566030112210972672,"id_str":"566030112210972672","indices":[97,119],"media_url":"http:\/\/pbs.twimg.com\/media\/B9rxY1qCcAAbeo0.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B9rxY1qCcAAbeo0.jpg","url":"http:\/\/t.co\/2MWtXbYhf0","display_url":"pic.twitter.com\/2MWtXbYhf0","expanded_url":"http:\/\/twitter.com\/frappuccino\/status\/566030116182949888\/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":566030112210972672,"id_str":"566030112210972672","indices":[97,119],"media_url":"http:\/\/pbs.twimg.com\/media\/B9rxY1qCcAAbeo0.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B9rxY1qCcAAbeo0.jpg","url":"http:\/\/t.co\/2MWtXbYhf0","display_url":"pic.twitter.com\/2MWtXbYhf0","expanded_url":"http:\/\/twitter.com\/frappuccino\/status\/566030116182949888\/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,"possibly_sensitive_appealable":false,"lang":"en"}' + http_version: + recorded_at: Fri, 12 Jun 2015 04:51:04 GMT +- request: + method: head + uri: http://pbs.twimg.com/media/B9rxY1qCcAAbeo0.jpg:orig + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Danbooru/2.81.1 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=604800, must-revalidate + Content-Md5: + - owAkLGZeD7NZTChJ3z0/EA== + Content-Type: + - image/jpeg + Last-Modified: + - Fri, 13 Feb 2015 00:24:29 GMT + Server: + - tsa_a + X-Connection-Hash: + - 0ed4d1e87aacad7f1ed6ae7e719cf566 + X-Response-Time: + - '32' + Content-Length: + - '56808' + Accept-Ranges: + - bytes + Date: + - Fri, 12 Jun 2015 04:51:06 GMT + Via: + - 1.1 varnish + Age: + - '0' + Connection: + - keep-alive + X-Served-By: + - cache-tw-sjc1-cr1-12-TWSJC1 + X-Cache: + - MISS + X-Cache-Hits: + - '0' + Expires: + - Sat, 27 Jun 2015 04:51:06 GMT + X-Content-Type-Options: + - nosniff + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Fri, 12 Jun 2015 04:51:06 GMT +recorded_with: VCR 2.9.0 diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index 0c20d80b1..2ba5c8bba 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -1,6 +1,11 @@ require 'test_helper' class UploadsControllerTest < ActionController::TestCase + def setup + super + setup_vcr + end + context "The uploads controller" do setup do @user = FactoryGirl.create(:contributor_user) @@ -15,13 +20,8 @@ class UploadsControllerTest < ActionController::TestCase 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 + VCR.use_cassette("functional/upload/twitter", :record => :once) do get :batch, {:url => "https://twitter.com/lvlln/status/567054278486151168"}, {:user_id => @user.id} end assert_response :success diff --git a/test/unit/forum_post_test.rb b/test/unit/forum_post_test.rb index 8ae35543c..f81fe10b8 100644 --- a/test/unit/forum_post_test.rb +++ b/test/unit/forum_post_test.rb @@ -14,33 +14,6 @@ class ForumPostTest < ActiveSupport::TestCase CurrentUser.ip_addr = nil end - context "#receive_email_notifications" do - should "return true if a matching subscription exists" do - FactoryGirl.create(:forum_subscription, :forum_topic_id => @topic.id, :user_id => CurrentUser.user.id) - assert_equal(true, ForumPost.new(:topic_id => @topic.id).receive_email_notifications) - end - - should "return false if there is no matching subscription" do - assert_equal(false, ForumPost.new(:topic_id => @topic.id).receive_email_notifications) - end - end - - context "#update_email_notifications" do - should "create a forum subscription if one doesn't exist" do - assert_difference("ForumSubscription.count", 1) do - FactoryGirl.create(:forum_post, :topic_id => @topic.id, :receive_email_notifications => true) - end - end - - should "update the forum subscription if one already exists" do - FactoryGirl.create(:forum_subscription, :forum_topic_id => @topic.id, :user_id => CurrentUser.user.id) - assert_difference("ForumSubscription.count", 0) do - FactoryGirl.create(:forum_post, :topic_id => @topic.id, :receive_email_notifications => true) - end - assert_not_nil(ForumSubscription.last.last_read_at) - end - end - context "that belongs to a topic with several pages of posts" do setup do Danbooru.config.stubs(:posts_per_page).returns(3)