Commit 7e1698b8 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

adding tests for CommunityResource#collections method

parent 972ecfce
......@@ -6,6 +6,7 @@ require_relative "dspace/resources/community_resource"
require_relative "dspace/builders/hash_builder"
require_relative "dspace/builders/model_builder"
require_relative "dspace/community"
require_relative "dspace/collection"
module Dspace
end
......@@ -2,13 +2,11 @@ module Dspace
module Resources
class CommunityResource < ResourceKit::Resource
# :all GET /communities - Return an array of all communities in DSpace.
# :top_communities GET /communities/ top-communities - Returns an array of all top-leve communities in DSpace.
# :find GET /communities/{communityId} - Returns a community with the specified ID.
# :collections GET /communities/{communityId}/collections - Returns an array of collections of the specified community.
# :subcommunities GET /communities/{communityId}/communities - Returns an array of subcommunities of the specified community.
resources do
action :all, 'GET /rest/communities' do
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_communities(JSON.parse(response.body))
......@@ -26,6 +24,12 @@ module Dspace
Dspace::Community.new(JSON.parse(response.body))
end
end
action :collections, 'GET /rest/communities/:id/collections' do
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_collections(JSON.parse(response.body))
end
end
end
end
......
......@@ -17,7 +17,7 @@ RSpec.describe Dspace::Resources::CommunityResource, resource_kit: true do
context "with community scope" do
it "get collections" do
expect(Dspace::Resources::CommunityResource).to have_action(:collection).that_handles(200).at_path('/rest/communities/:id/collections')
expect(Dspace::Resources::CommunityResource).to have_action(:collections).that_handles(200).at_path('/rest/communities/:id/collections')
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment