Permalink
Browse files

Update some organization methods to v3

Methods updated:
- organization
- update_organization
- organizations
  • Loading branch information...
1 parent 17e64c8 commit 88da7fb81135f5be8a67d4b6a4a3ee226bbbc2dd @catsby catsby committed Dec 21, 2011
Showing with 17 additions and 17 deletions.
  1. +5 −5 lib/octokit/client/organizations.rb
  2. +12 −12 spec/octokit/client/organizations_spec.rb
View
10 lib/octokit/client/organizations.rb
@@ -2,21 +2,21 @@ module Octokit
class Client
module Organizations
def organization(org, options={})
- get("/api/v2/json/organizations/#{org}", options)['organization']
+ get("orgs/#{org}", options, 3)
end
alias :org :organization
def update_organization(org, values, options={})
- put("/api/v2/json/organizations/#{org}", options.merge({:organization => values}))['organization']
+ patch("orgs/#{org}", options.merge({:organization => values}), 3)
end
alias :update_org :update_organization
def organizations(user=nil, options={})
if user
- get("/api/v2/json/user/show/#{user}/organizations", options)
+ get("users/#{user}/orgs", options, 3)
else
- get("/api/v2/json/organizations", options)
- end['organizations']
+ get("user/orgs", options, 3)
+ end
end
alias :list_organizations :organizations
alias :list_orgs :organizations
View
24 spec/octokit/client/organizations_spec.rb
@@ -10,8 +10,8 @@
describe ".organization" do
it "should return an organization" do
- stub_get("https://github.com/api/v2/json/organizations/codeforamerica").
- to_return(:body => fixture("v2/organization.json"))
+ stub_get("https://api.github.com/orgs/codeforamerica").
+ to_return(:body => fixture("v3/organization.json"))
organization = @client.organization("codeforamerica")
organization.name.should == "Code For America"
end
@@ -21,9 +21,9 @@
describe ".update_organization" do
it "should update an organization" do
- stub_put("https://github.com/api/v2/json/organizations/codeforamerica").
+ stub_patch("https://api.github.com/orgs/codeforamerica").
with(:name => "Code For America").
- to_return(:body => fixture("v2/organization.json"))
+ to_return(:body => fixture("v3/organization.json"))
organization = @client.update_organization("codeforamerica", {:name => "Code For America"})
organization.name.should == "Code For America"
end
@@ -32,24 +32,24 @@
describe ".organizations" do
- context "with an org passed" do
+ context "with a user passed" do
it "should return all organizations for a user" do
- stub_get("https://github.com/api/v2/json/user/show/sferik/organizations").
- to_return(:body => fixture("v2/organizations.json"))
+ stub_get("https://api.github.com/users/sferik/orgs").
+ to_return(:body => fixture("v3/organizations.json"))
organizations = @client.organizations("sferik")
- organizations.first.name.should == "Hubcap"
+ organizations.first.login.should == "Hubcap"
end
end
- context "without an org passed" do
+ context "without user passed" do
it "should return all organizations for a user" do
- stub_get("https://github.com/api/v2/json/organizations").
- to_return(:body => fixture("v2/organizations.json"))
+ stub_get("https://api.github.com/user/orgs").
+ to_return(:body => fixture("v3/organizations.json"))
organizations = @client.organizations
- organizations.first.name.should == "Hubcap"
+ organizations.first.login.should == "Hubcap"
end
end

0 comments on commit 88da7fb

Please sign in to comment.