Skip to content

Commit 4884cb9

Browse files
committed
Implement .repos in Team
1 parent 9afb06d commit 4884cb9

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/bitbucket_rest_api/team.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,11 @@ def following(team_name)
3636
response["values"].each { |el| yield el }
3737
end
3838

39-
end # Users
39+
def repos(team_name)
40+
response = get_request("/2.0/teams/#{team_name.to_s}/repositories")
41+
return response unless block_given?
42+
response["values"].each { |el| yield el }
43+
end
44+
45+
end # Team
4046
end # BitBucket

spec/bitbucket_rest_api/team_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,27 @@
109109
end
110110
end
111111
end
112+
113+
describe '.repos' do
114+
before do
115+
expect(team).to receive(:request).with(
116+
:get,
117+
'/2.0/teams/team_name/repositories',
118+
{},
119+
{}
120+
).and_return({"values" => ['repo1', 'repo2', 'repo3']})
121+
end
122+
123+
context "without a block" do
124+
it 'sends a GET request for the repos for the team' do
125+
team.repos('team_name')
126+
end
127+
end
128+
129+
context "with a block" do
130+
it 'sends a GET request for the repos for the team' do
131+
team.repos('team_name') { |repo| repo }
132+
end
133+
end
134+
end
112135
end

0 commit comments

Comments
 (0)