-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cbp support for the groups endpoints
- Loading branch information
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
def expect_cbp_response_for(collection) | ||
context collection.path.to_s, :vcr do | ||
before do | ||
@resource_klass = collection.instance_variable_get(:@resource_class) | ||
VCR.use_cassette("cbp_#{@resource_class}_#{collection.path}") do | ||
@result = collection.fetch | ||
@response_body = collection.response.body | ||
end | ||
end | ||
it 'expects an array with the correct element types' do | ||
expect(@result).to all(be_a(@resource_klass)) | ||
end | ||
|
||
it 'expects a CBP response with all the correct keys' do | ||
expect(@response_body).to have_key('meta') | ||
expect(@response_body).to have_key('links') | ||
expect(@response_body['meta'].keys).to match_array(%w[has_more after_cursor before_cursor]) | ||
expect(@response_body['links'].keys).to match_array(%w[prev next]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'core/spec_helper' | ||
require 'core/cbp_helper' | ||
describe 'Endpoints that support CBP' do | ||
describe ZendeskAPI::Group do | ||
describe '/groups' do | ||
expect_cbp_response_for(client.groups) | ||
expect_cbp_response_for(client.groups.assignable) | ||
end | ||
end | ||
|
||
describe ZendeskAPI::GroupMembership do | ||
describe '/groups/{id}/memberships' do | ||
before do | ||
VCR.use_cassette("cbp_group_memberships_all_groups") do | ||
@groups = client.groups.fetch | ||
end | ||
|
||
VCR.use_cassette("cbp_group_memberships_for_a_group") do | ||
@memberships_collection = @groups.last.memberships | ||
@all_memberships = @memberships_collection.fetch | ||
@response_body = @memberships_collection.response.body | ||
end | ||
end | ||
|
||
it 'expects an array with the correct element types' do | ||
expect(@all_memberships).to all(be_a(ZendeskAPI::GroupMembership)) | ||
end | ||
|
||
it 'expects a CBP response with all the correct keys' do | ||
expect(@response_body).to have_key('meta') | ||
expect(@response_body).to have_key('links') | ||
expect(@response_body['meta'].keys).to match_array(%w[has_more after_cursor before_cursor]) | ||
expect(@response_body['links'].keys).to match_array(%w[prev next]) | ||
end | ||
end | ||
end | ||
end |