Fix YouTube titles on 1.9. (SIGH.)
This commit is contained in:
parent
624e7277e8
commit
b6e2e9452f
4 changed files with 6 additions and 6 deletions
|
|
@ -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>(.*)<\/title>/)
|
||||
unless title.nil?
|
||||
title = title.to_s[7..-9]
|
||||
|
|
|
|||
|
|
@ -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}</title> hallo welt <asd><dasdd><a>dsd</a>"])
|
||||
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}</title> hallo welt <asd><dasdd><a>dsd</a>"])
|
||||
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 <title>#{@expected_title}</title> hallo welt <asd><dasdd><a>dsd</a>"])
|
||||
@post = Factory.create(:status_message, :text => @url)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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 <title>'+expected_title+'</title> hallo welt <asd><dasdd><a>dsd</a>'])
|
||||
|
||||
comment = alice.build_comment :text => url, :post => @message
|
||||
|
|
|
|||
|
|
@ -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 <title>'+expected_title+'</title> hallo welt <asd><dasdd><a>dsd</a>'])
|
||||
|
||||
post = @user.build_post :status_message, :text => url, :to => @aspect.id
|
||||
|
|
|
|||
Loading…
Reference in a new issue