<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -24,7 +24,7 @@ class YouTubeG
         # pair for which the value is non-nil
         u = '?'
         item_count = 0
-        params.keys.each do |key|
+        params.keys.sort.each do |key|
           value = params[key]
           next if value.nil?
 </diff>
      <filename>lib/youtube_g/request/base_search.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,16 +6,17 @@ class YouTubeG
       attr_reader :offset                          # start-index
 
       def initialize(params, options={})
+        @max_results, @order_by, @offset = nil
         @url = base_url
 
         if params == :favorites
           @url &lt;&lt; &quot;#{options[:user]}/favorites&quot; 
+          set_instance_variables(options)
         elsif params[:user]
           @url &lt;&lt; &quot;#{params[:user]}/uploads&quot;
+          set_instance_variables(params)
         end
         
-        set_instance_variables(params)
-
         @url &lt;&lt; build_query_params(to_youtube_params)
       end
 </diff>
      <filename>lib/youtube_g/request/user_search.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,6 @@ class TestClient &lt; Test::Unit::TestCase
     assert_equal 51, response2.offset
   end
   
-  
   def test_should_get_videos_for_multiword_metasearch_query
     response = @client.videos_by(:query =&gt; 'christina ricci')
   
@@ -132,6 +131,13 @@ class TestClient &lt; Test::Unit::TestCase
     response = @client.videos_by(:user =&gt; 'liz')
     response.videos.each { |v| assert_valid_video v }
   end
+  
+  def test_should_get_videos_by_user_with_pagination_and_ordering
+    response = @client.videos_by(:user =&gt; 'liz', :page =&gt; 2, :per_page =&gt; '2', :order_by =&gt; 'published')
+    response.videos.each { |v| assert_valid_video v }
+    assert_equal 3, response.offset
+    assert_equal 2, response.max_result_count
+  end
 
   # HTTP 403 Error
   # def test_should_get_favorite_videos_by_user</diff>
      <filename>test/test_client.rb</filename>
    </modified>
    <modified>
      <diff>@@ -74,7 +74,7 @@ class TestVideoSearch &lt; Test::Unit::TestCase
   
   def test_should_build_url_for_most_viewed_offset_and_max_results_with_time
     request = YouTubeG::Request::StandardSearch.new(:top_rated, :offset =&gt; 5, :max_results =&gt; 10, :time =&gt; :today)
-    assert_equal &quot;http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today&amp;max-results=10&amp;start-index=5&quot;, request.url   
+    assert_equal &quot;http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?max-results=10&amp;start-index=5&amp;time=today&quot;, request.url   
   end
 
   def test_should_raise_exception_for_invalid_type
@@ -111,7 +111,7 @@ class TestVideoSearch &lt; Test::Unit::TestCase
     request = YouTubeG::Request::VideoSearch.new(:query =&gt; 'bench press', 
                                                  :categories =&gt; { :exclude =&gt; [:comedy, :entertainment] },
                                                  :max_results =&gt; 10)
-    assert_equal &quot;http://gdata.youtube.com/feeds/api/videos/-/-Comedy/-Entertainment/?vq=bench+press&amp;max-results=10&quot;, request.url
+    assert_equal &quot;http://gdata.youtube.com/feeds/api/videos/-/-Comedy/-Entertainment/?max-results=10&amp;vq=bench+press&quot;, request.url
   end
   
   # -- User Queries ---------------------------------------------------------------------------------
@@ -121,8 +121,18 @@ class TestVideoSearch &lt; Test::Unit::TestCase
     assert_equal &quot;http://gdata.youtube.com/feeds/api/users/liz/uploads&quot;, request.url
   end
   
+  def test_should_build_url_for_videos_by_user_paginate_and_order
+    request = YouTubeG::Request::UserSearch.new(:user =&gt; 'liz', :offset =&gt; 20, :max_results =&gt; 10, :order_by =&gt; 'published')
+    assert_equal &quot;http://gdata.youtube.com/feeds/api/users/liz/uploads?max-results=10&amp;orderby=published&amp;start-index=20&quot;, request.url
+  end
+
   def test_should_build_url_for_favorite_videos_by_user
     request = YouTubeG::Request::UserSearch.new(:favorites, :user =&gt; 'liz')
     assert_equal &quot;http://gdata.youtube.com/feeds/api/users/liz/favorites&quot;, request.url
   end
+
+  def test_should_build_url_for_favorite_videos_by_user_paginate
+    request = YouTubeG::Request::UserSearch.new(:favorites, :user =&gt; 'liz', :offset =&gt; 20, :max_results =&gt; 10)
+    assert_equal &quot;http://gdata.youtube.com/feeds/api/users/liz/favorites?max-results=10&amp;start-index=20&quot;, request.url
+  end
 end</diff>
      <filename>test/test_video_search.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d7c871c0f720d1bc8604f8a4545ea5353d142ed1</id>
    </parent>
  </parents>
  <author>
    <name>Layton Wedgeworth</name>
    <email>laytonw@layton.local</email>
  </author>
  <url>http://github.com/tmm1/youtube-g/commit/7257f254d731443b85c0ccb119febdba978352de</url>
  <id>7257f254d731443b85c0ccb119febdba978352de</id>
  <committed-date>2008-08-16T12:58:15-07:00</committed-date>
  <authored-date>2008-08-16T12:58:15-07:00</authored-date>
  <message>Added test for UserSearch pagination, Made URL param building determenistic by sorting param keys</message>
  <tree>252516b4d6993a9508bf1ec31e9e1b90000596bb</tree>
  <committer>
    <name>Layton Wedgeworth</name>
    <email>laytonw@layton.local</email>
  </committer>
</commit>
