Skip to content

Commit

Permalink
Update Orgs::teams methods to v3
Browse files Browse the repository at this point in the history
- organization_teams
- create_team
- team
- update_team
- delete_team

Removed duplicate `delete_team` test
  • Loading branch information
catsby committed Dec 21, 2011
1 parent 9579638 commit 1e6f5c2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
10 changes: 5 additions & 5 deletions lib/octokit/client/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ def organization_members(org, options={})
alias :org_members :organization_members

def organization_teams(org, options={})
get("/api/v2/json/organizations/#{org}/teams", options)['teams']
get("orgs/#{org}/teams", options, 3)
end
alias :org_teams :organization_teams

def create_team(org, values, options={})
post("/api/v2/json/organizations/#{org}/teams", options.merge({:team => values}))['team']
post("orgs/#{org}/teams", options.merge({:team => values}), 3)
end

def team(team_id, options={})
get("/api/v2/json/teams/#{team_id}", options)['team']
get("teams/#{team_id}", options, 3)
end

def update_team(team_id, values, options={})
put("/api/v2/json/teams/#{team_id}", options.merge({:team => values}))['team']
patch("teams/#{team_id}", options.merge({:team => values}), 3)
end

def delete_team(team_id, options={})
delete("/api/v2/json/teams/#{team_id}", options)['team']
delete("teams/#{team_id}", options, 3, true, true)
end

def team_members(team_id, options={})
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/v2/team.json

This file was deleted.

1 change: 0 additions & 1 deletion spec/fixtures/v2/teams.json

This file was deleted.

34 changes: 12 additions & 22 deletions spec/octokit/client/organizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
describe ".organization_teams" do

it "should return all teams for an organization" do
stub_get("https://github.com/api/v2/json/organizations/codeforamerica/teams").
to_return(:body => fixture("v2/teams.json"))
stub_get("https://api.github.com/orgs/codeforamerica/teams").
to_return(:body => fixture("v3/teams.json"))
teams = @client.organization_teams("codeforamerica")
teams.first.name.should == "Fellows"
end
Expand All @@ -107,9 +107,9 @@
describe ".create_team" do

it "should create a team" do
stub_post("https://github.com/api/v2/json/organizations/codeforamerica/teams").
stub_post("https://api.github.com/orgs/codeforamerica/teams").
with(:name => "Fellows").
to_return(:body => fixture("v2/team.json"))
to_return(:body => fixture("v3/team.json"))
team = @client.create_team("codeforamerica", {:name => "Fellows"})
team.name.should == "Fellows"
end
Expand All @@ -119,8 +119,8 @@
describe ".team" do

it "should return a team" do
stub_get("https://github.com/api/v2/json/teams/32598").
to_return(:body => fixture("v2/team.json"))
stub_get("https://api.github.com/teams/32598").
to_return(:body => fixture("v3/team.json"))
team = @client.team(32598)
team.name.should == "Fellows"
end
Expand All @@ -130,9 +130,9 @@
describe ".update_team" do

it "should update a team" do
stub_put("https://github.com/api/v2/json/teams/32598").
stub_patch("https://api.github.com/teams/32598").
with(:name => "Fellows").
to_return(:body => fixture("v2/team.json"))
to_return(:body => fixture("v3/team.json"))
team = @client.update_team(32598, :name => "Fellows")
team.name.should == "Fellows"
end
Expand All @@ -142,24 +142,14 @@
describe ".delete_team" do

it "should delete a team" do
stub_delete("https://github.com/api/v2/json/teams/32598").
to_return(:body => fixture("v2/team.json"))
team = @client.delete_team(32598)
team.name.should == "Fellows"
stub_delete("https://api.github.com/teams/32598").
to_return(:status => 204)
result = @client.delete_team(32598)
result.status.should == 204
end

end

describe ".delete_team" do

it "should delete a team" do
stub_delete("https://github.com/api/v2/json/teams/32598").
to_return(:body => fixture("v2/team.json"))
team = @client.delete_team(32598)
team.name.should == "Fellows"
end

end

describe ".team_members" do

Expand Down

0 comments on commit 1e6f5c2

Please sign in to comment.