Skip to content

Commit

Permalink
convert add_to_team to use new team membership API
Browse files Browse the repository at this point in the history
  • Loading branch information
afeld committed Oct 8, 2014
1 parent a6b9e77 commit 1367ee0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/teachers_pet/client_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 51,8 @@ def add_users_to_team(organization, team, usernames)
if team_members.include?(username)
puts " -> @#{username} is already on @#{organization}/#{team[:name]}"
else
self.add_team_member(team[:id], username)
# https://github.com/octokit/octokit.rb/pull/518
self.add_team_membership(team[:id], username, accept: 'application/vnd.github.the-wasp-preview json')
puts " -> @#{username} has been added to @#{organization}/#{team[:name]}"
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/add_to_team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,7 @@
])

users[1..-1].each do |instructor|
request_stubs << stub_request(:put, "https://testteacher:[email protected]/teams/101/members/#{instructor}")
request_stubs << stub_request(:put, "https://testteacher:[email protected]/teams/101/memberships/#{instructor}")
end

teachers_pet(:add_to_team,
Expand Down
4 changes: 2 additions & 2 deletions spec/commands/create_student_teams_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 32,7 @@ def stub_owners_only
request_stubs << stub_get_json("https://testteacher:[email protected]/teams/#{i}/members?per_page=100", [])

# Add student to their team
request_stubs << stub_request(:put, "https://testteacher:[email protected]/teams/#{i}/members/#{student}")
request_stubs << stub_request(:put, "https://testteacher:[email protected]/teams/#{i}/memberships/#{student}")
end

teachers_pet(:create_student_teams,
Expand Down Expand Up @@ -70,7 70,7 @@ def stub_owners_only

%w(teststudent1 teststudent2).each do |student|
# Add student to their team
request_stubs << stub_request(:put, "https://testteacher:[email protected]/teams/1/members/#{student}")
request_stubs << stub_request(:put, "https://testteacher:[email protected]/teams/1/memberships/#{student}")
end

teachers_pet(:create_student_teams,
Expand Down
4 changes: 3 additions & 1 deletion teachers_pet.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,9 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9.3'

s.add_dependency 'activesupport', '~> 4.0'
s.add_dependency 'octokit', '~> 3.1.0'
# for team membership API
# https://developer.github.com/changes/2014-08-05-team-memberships-api/
s.add_dependency 'octokit', '~> 3.3.0'
s.add_dependency 'require_all', '~> 1.3.2'
s.add_dependency 'thor', '~> 0.19.1'

Expand Down

0 comments on commit 1367ee0

Please sign in to comment.