diff --git a/lib/twitter/base.rb b/lib/twitter/base.rb index b00366148..0d3832ef5 100644 --- a/lib/twitter/base.rb +++ b/lib/twitter/base.rb @@ -228,8 +228,10 @@ def list(list_owner_username, slug) perform_get("/#{list_owner_username}/lists/#{slug}.json") end - def list_timeline(list_owner_username, slug) - perform_get("/#{list_owner_username}/lists/#{slug}/statuses.json") + # :per_page = max number of statues to get at once + # :page = which page of tweets you wish to get + def list_timeline(list_owner_username, slug, query = {}) + perform_get("/#{list_owner_username}/lists/#{slug}/statuses.json", :query => query) end def memberships(list_owner_username) diff --git a/test/fixtures/list_statuses_1_1.json b/test/fixtures/list_statuses_1_1.json new file mode 100644 index 000000000..4eb1dcf6e --- /dev/null +++ b/test/fixtures/list_statuses_1_1.json @@ -0,0 +1 @@ +[{"geo":null,"truncated":false,"source":"Tweetie","created_at":"Thu Oct 29 23:27:15 +0000 2009","favorited":false,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"user":{"notifications":false,"favourites_count":115,"profile_link_color":"2FC2EF","description":"I make things simple.","following":false,"profile_background_tile":false,"geo_enabled":false,"profile_background_color":"1A1B1F","profile_image_url":"http://a3.twimg.com/profile_images/61024905/black250_normal.jpg","verified":false,"profile_sidebar_fill_color":"252429","url":"http://railstips.org/about","screen_name":"jnunemaker","created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_sidebar_border_color":"181A1E","followers_count":1659,"protected":false,"statuses_count":6122,"time_zone":"Indiana (East)","location":"South Bend, IN","name":"John Nunemaker","friends_count":138,"profile_text_color":"666666","id":4243,"profile_background_image_url":"http://s.twimg.com/a/1256778767/images/themes/theme9/bg.gif","utc_offset":-18000},"in_reply_to_screen_name":null,"id":5272535583,"text":"Whoa. Webkit Nightly has some new inspector features: event listeners, cookies, css hex colors... http://rubyurl.com/hh5p"}] \ No newline at end of file diff --git a/test/fixtures/list_statuses_2_1.json b/test/fixtures/list_statuses_2_1.json new file mode 100644 index 000000000..b4aa16bb3 --- /dev/null +++ b/test/fixtures/list_statuses_2_1.json @@ -0,0 +1 @@ +[{"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"favorited":false,"source":"Tweetie","created_at":"Thu Oct 29 17:35:07 +0000 2009","in_reply_to_screen_name":null,"user":{"profile_text_color":"666666","profile_image_url":"http://a3.twimg.com/profile_images/61024905/black250_normal.jpg","description":"I make things simple.","following":true,"statuses_count":6121,"profile_background_image_url":"http://s.twimg.com/a/1256597179/images/themes/theme9/bg.gif","profile_link_color":"2FC2EF","screen_name":"jnunemaker","geo_enabled":false,"profile_background_tile":false,"profile_background_color":"1A1B1F","url":"http://railstips.org/about","verified":false,"created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_sidebar_fill_color":"252429","followers_count":1660,"protected":false,"friends_count":138,"profile_sidebar_border_color":"181A1E","location":"South Bend, IN","name":"John Nunemaker","id":4243,"notifications":false,"time_zone":"Indiana (East)","utc_offset":-18000,"favourites_count":115},"id":5264324712,"text":"I need some http://www.handerpants.com/ for night blogging. Haha."}] \ No newline at end of file diff --git a/test/twitter/base_test.rb b/test/twitter/base_test.rb index 38efe7595..0efb3e4d6 100644 --- a/test/twitter/base_test.rb +++ b/test/twitter/base_test.rb @@ -240,6 +240,27 @@ class BaseTest < Test::Unit::TestCase tweets.first.id.should == 5272535583 tweets.first.user.name.should == 'John Nunemaker' end + + should "be able to limit number of tweets in list timeline" do + stub_get('/pengwynn/lists/rubyists/statuses.json?per_page=1', 'list_statuses_1_1.json') + tweets = @twitter.list_timeline('pengwynn', 'rubyists', :per_page => 1) + tweets.size.should == 1 + tweets.first.id.should == 5272535583 + tweets.first.user.name.should == 'John Nunemaker' + end + + should "be able to paginate through the timeline" do + stub_get('/pengwynn/lists/rubyists/statuses.json?page=1&per_page=1', 'list_statuses_1_1.json') + stub_get('/pengwynn/lists/rubyists/statuses.json?page=2&per_page=1', 'list_statuses_2_1.json') + tweets = @twitter.list_timeline('pengwynn', 'rubyists', { :page => 1, :per_page => 1 }) + tweets.size.should == 1 + tweets.first.id.should == 5272535583 + tweets.first.user.name.should == 'John Nunemaker' + tweets = @twitter.list_timeline('pengwynn', 'rubyists', { :page => 2, :per_page => 1 }) + tweets.size.should == 1 + tweets.first.id.should == 5264324712 + tweets.first.user.name.should == 'John Nunemaker' + end should "be able to view list members" do stub_get('/pengwynn/rubyists/members.json', 'list_users.json')