From b6e2e9452f38af11308fc65980892b8f9fcee0dc Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Tue, 30 Aug 2011 21:04:29 -0700 Subject: [PATCH] Fix YouTube titles on 1.9. (SIGH.) --- lib/youtube_titles.rb | 2 +- spec/lib/youtube_titles_spec.rb | 6 +++--- spec/models/comment_spec.rb | 2 +- spec/models/status_message_spec.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/youtube_titles.rb b/lib/youtube_titles.rb index 62fe2efd9..fcd177d50 100644 --- a/lib/youtube_titles.rb +++ b/lib/youtube_titles.rb @@ -10,7 +10,7 @@ module YoutubeTitles def youtube_title_for video_id http = Net::HTTP.new('gdata.youtube.com', 80) path = "/feeds/api/videos/#{video_id}?v=2" - resp, data = http.get(path, nil) + resp, data = http.get(path) title = data.match(/(.*)<\/title>/) unless title.nil? title = title.to_s[7..-9] diff --git a/spec/lib/youtube_titles_spec.rb b/spec/lib/youtube_titles_spec.rb index 7153d2324..20e527b31 100644 --- a/spec/lib/youtube_titles_spec.rb +++ b/spec/lib/youtube_titles_spec.rb @@ -18,13 +18,13 @@ describe YoutubeTitles do end it 'gets a youtube title corresponding to an id' do - @mock_http.should_receive(:get).with(@api_path, nil).and_return( + @mock_http.should_receive(:get).with(@api_path).and_return( [nil, "Foobar <title>#{@expected_title} hallo welt dsd"]) youtube_title_for(@video_id).should == @expected_title end it 'returns a fallback for videos with no title' do - @mock_http.should_receive(:get).with(@api_path, nil).and_return( + @mock_http.should_receive(:get).with(@api_path).and_return( [nil, "Foobar #{@expected_title} hallo welt dsd"]) youtube_title_for(@video_id).should == I18n.t('application.helper.video_title.unknown') end @@ -35,7 +35,7 @@ describe YoutubeTitles do @expected_title = '""Procrastination"" Tales Of Mere Existence' mock_http = mock("http") Net::HTTP.stub!(:new).with('gdata.youtube.com', 80).and_return(mock_http) - mock_http.should_receive(:get).with(@api_path, nil).and_return( + mock_http.should_receive(:get).with(@api_path).and_return( [nil, "Foobar #{@expected_title} hallo welt dsd"]) @post = Factory.create(:status_message, :text => @url) end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index f815a2c64..1d4ffccb0 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -101,7 +101,7 @@ describe Comment do mock_http = mock("http") Net::HTTP.stub!(:new).with('gdata.youtube.com', 80).twice.and_return(mock_http) - mock_http.should_receive(:get).with(/\/feeds\/api\/videos/, nil).twice.and_return( + mock_http.should_receive(:get).with(/\/feeds\/api\/videos/).twice.and_return( [nil, 'Foobar '+expected_title+' hallo welt dsd']) comment = alice.build_comment :text => url, :post => @message diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index b60cf6f9b..7c0d61109 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -236,7 +236,7 @@ STR mock_http = mock("http") Net::HTTP.stub!(:new).with('gdata.youtube.com', 80).and_return(mock_http) - mock_http.should_receive(:get).with('/feeds/api/videos/'+video_id+'?v=2', nil).and_return( + mock_http.should_receive(:get).with('/feeds/api/videos/'+video_id+'?v=2').and_return( [nil, 'Foobar '+expected_title+' hallo welt dsd']) post = @user.build_post :status_message, :text => url, :to => @aspect.id