Skip to content

Commit

Permalink
Merge pull request #147 from pbouda/modify_resource_types_response
Browse files Browse the repository at this point in the history
Modify response of ResourceTypes endpoint
  • Loading branch information
pond authored Oct 22, 2024
2 parents 096e5e0 + 74be430 commit cf6a159
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 7 additions & 1 deletion app/controllers/scimitar/resource_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ def index
resource.resource_type(scim_resource_type_url(name: resource.resource_type_id))
end

render json: resource_types
render json: {
schemas: [
'urn:ietf:params:scim:api:messages:2.0:ListResponse'
],
totalResults: resource_types.size,
Resources: resource_types
}
end

def show
Expand Down
12 changes: 8 additions & 4 deletions spec/controllers/scimitar/resource_types_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
it 'renders the resource type for user' do
get :index, format: :scim
response_hash = JSON.parse(response.body)
expected_response = [ Scimitar::Resources::User.resource_type(scim_resource_type_url(name: 'User', test: 1)),
Scimitar::Resources::Group.resource_type(scim_resource_type_url(name: 'Group', test: 1))
].to_json
expected_response = {
schemas: ['urn:ietf:params:scim:api:messages:2.0:ListResponse'],
totalResults: 2,
Resources: [
Scimitar::Resources::User.resource_type(scim_resource_type_url(name: 'User', test: 1)),
Scimitar::Resources::Group.resource_type(scim_resource_type_url(name: 'Group', test: 1))
]
}.to_json

response_hash = JSON.parse(response.body)
expect(response_hash).to eql(JSON.parse(expected_response))
end

Expand Down

0 comments on commit cf6a159

Please sign in to comment.