Skip to content

Commit e8cc878

Browse files
committed
Correctly return 'values' array from response of .list when block is given
1 parent 013d6e0 commit e8cc878

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/bitbucket_rest_api/team.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(options = { })
1111
def list(user_role)
1212
response = get_request("/2.0/teams/?role=#{user_role.to_s}")
1313
return response unless block_given?
14-
response.each { |el| yield el }
14+
response["values"].each { |el| yield el }
1515
end
1616

1717

spec/bitbucket_rest_api/team_spec.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@
1010
'/2.0/teams/?role=member',
1111
{},
1212
{}
13-
)
13+
).and_return({"values" => ['team1', 'team2', 'team3']})
1414
end
1515

16-
it 'should send a GET request for the teams of which the user is a member' do
17-
team.list(:member)
16+
context 'without a block' do
17+
it 'should send a GET request for the teams of which the user is a member' do
18+
team.list(:member)
19+
end
20+
end
21+
22+
context 'with a block' do
23+
it 'should send a GET request for the teams of which the user is a member' do
24+
team.list(:member) { |team| team }
25+
end
1826
end
1927
end
2028
end

0 commit comments

Comments
 (0)