Permalink
Browse files

example of params support for filtering and such

  • Loading branch information...
1 parent ef9761f commit f95d264177448048b6b274b9c9d3306ff948f17c @rauhryan rauhryan committed Jan 18, 2012
Showing with 20 additions and 4 deletions.
  1. +4 −3 lib/ghee/api/users.rb
  2. +1 −1 lib/ghee/resource_proxy.rb
  3. +15 −0 spec/ghee/api/users_spec.rb
View
@@ -37,9 +37,10 @@ def gists
#
# Returns json
#
- def repos(name=nil)
- prefix = name ? "/repos/#{self["login"]}/#{name}" : "#{path_prefix}/repos"
- Ghee::API::Repos::Proxy.new(connection,prefix)
+ def repos(name=nil, params={})
+ params = name if name.is_a?Hash
+ prefix = name.is_a?(String) ? "/repos/#{self["login"]}/#{name}" : "#{path_prefix}/repos"
+ Ghee::API::Repos::Proxy.new(connection,prefix, params)
end
# Returns list of the provided users organizations or
@@ -45,7 +45,7 @@ def subject
def paginate(options)
@current_page = options.fetch(:page) {raise ArgumentError, ":page parameter required"}
- per_page = options.delete(:per_page) || 25
+ per_page = options.delete(:per_page) || 30
request = connection.get do |req|
req.url path_prefix, :per_page => per_page, :page => current_page
req.params.merge! params
@@ -42,13 +42,28 @@
end
end
+ describe "#repos :type => 'public'" do
+ it "should only return public repos" do
+ VCR.use_cassette "user.repos.public" do
+ repos = subject.user.repos :type => "public"
+ repos.size.should > 0
+ repos.path_prefix.should == "/user/repos"
+ repos.should be_instance_of(Array)
+ repos.each do |r|
+ r["private"].should be_false
+ end
+ end
+ end
+ end
+
describe "#repos" do
it "should return list of repos" do
VCR.use_cassette "user.repos" do
repos = subject.user.repos
repos.size.should > 0
end
end
+
describe "#paginate" do
it "should limit the count to 10" do
VCR.use_cassette "user.repos.paginate" do

0 comments on commit f95d264

Please sign in to comment.