Skip to content

Commit

Permalink
fixed the problem where finding a user's favorites would fall back to…
Browse files Browse the repository at this point in the history
… finding the user's uploads

Signed-off-by: Aman Gupta <aman@tmm1.net>
  • Loading branch information
pius authored and tmm1 committed Dec 16, 2008
1 parent e474a2d commit cef7a09
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/youtube_g/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def videos_by(params, options={})
if params.respond_to?(:to_hash) and not params[:user]
request = YouTubeG::Request::VideoSearch.new(request_params)
elsif (params.respond_to?(:to_hash) && params[:user]) || (params == :favorites)
request = YouTubeG::Request::UserSearch.new(request_params, options)
request = YouTubeG::Request::UserSearch.new(params, request_params)
else
request = YouTubeG::Request::StandardSearch.new(params, request_params)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/youtube_g/request/user_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def initialize(params, options={})
if params == :favorites
@url << "#{options[:user]}/favorites"
set_instance_variables(options)
elsif params[:user] && options[:favorites]
@url << "#{params[:user]}/favorites"
set_instance_variables(params)
break
elsif params[:user]
@url << "#{params[:user]}/uploads"
set_instance_variables(params)
Expand Down
6 changes: 6 additions & 0 deletions test/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ def test_should_get_videos_by_user_with_pagination_and_ordering
# response.videos.each { |v| assert_valid_video v }
# end

def test_should_get_favorite_videos_by_user
response = @client.videos_by(:favorites, :user => 'drnicwilliams')
assert_equal "http://gdata.youtube.com/feeds/api/users/drnicwilliams/favorites", response.feed_id
response.videos.each { |v| assert_valid_video v }
end

def test_should_get_videos_for_query_search_with_categories_excluded
video = @client.video_by("EkF4JD2rO3Q")
assert_equal "<object width=\"425\" height=\"350\">\n <param name=\"movie\" value=\"http://www.youtube.com/v/EkF4JD2rO3Q\"></param>\n <param name=\"wmode\" value=\"transparent\"></param>\n <embed src=\"http://www.youtube.com/v/EkF4JD2rO3Q\" type=\"application/x-shockwave-flash\" \n wmode=\"transparent\" width=\"425\" height=\"350\"></embed>\n</object>\n", video.embed_html
Expand Down

0 comments on commit cef7a09

Please sign in to comment.