Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more idiomatic calling form #139

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Features:

* Override which core schema are returned in the `/Schemas` endpoint via new call `Scimitar::Engine::set_default_resources` (see [this code diff](https://github.com/RIPAGlobal/scimitar/pull/133/files#diff-b8ad01f8ed8a88f41a13938505a2050d3d3ff86af93a78a7690b273ece6b80bdR80)) - implements [#118](https://github.com/RIPAGlobal/scimitar/issues/118) requested by `@gsar` via [#133](https://github.com/RIPAGlobal/scimitar/pull/133)
* Override which core schema are returned in the `/Schemas` endpoint via new call `Scimitar::Engine.set_default_resources` (see [this code diff](https://github.com/RIPAGlobal/scimitar/pull/133/files#diff-b8ad01f8ed8a88f41a13938505a2050d3d3ff86af93a78a7690b273ece6b80bdR80)) - implements [#118](https://github.com/RIPAGlobal/scimitar/issues/118) requested by `@gsar` via [#133](https://github.com/RIPAGlobal/scimitar/pull/133)
* Opt-in feature to make the `/Schemas` endpoint walk resource attribute maps to determine _actual_ supported attributes and attribute mutability, rather than just reporting the literal schema definition; see the description of the `schema_list_from_attribute_mappings` configuration setting inside the template `config/initializers/scimitar.rb` file for details (or read it via the [code diff here](https://github.com/RIPAGlobal/scimitar/pull/135/files#diff-830211b739a7c7398083b7127d648b356f43d298713a2b3f0c13f2271b9d3c82R110)) - implements [#119](https://github.com/RIPAGlobal/scimitar/issues/119) requested by `@gsar` via [#135](https://github.com/RIPAGlobal/scimitar/pull/135)

Fixes:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ By default, Scimitar advertises (via things like [the `/Schemas` endpoint](https

```ruby
Rails.application.config.to_prepare do
Scimitar::Engine::set_default_resources([Scimitar::Resources::User])
Scimitar::Engine.set_default_resources([Scimitar::Resources::User])
# ...other Scimitar configuration / initialisation code...
end
```
Expand Down
4 changes: 2 additions & 2 deletions lib/scimitar/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def self.set_default_resources(resource_array)
unrecognised_resources = resource_array - @standard_default_resources

if unrecognised_resources.any?
raise "Scimitar::Engine::set_default_resources: Only #{@standard_default_resources.map(&:name).join(', ')} are supported"
raise "Scimitar::Engine.set_default_resources: Only #{@standard_default_resources.map(&:name).join(', ')} are supported"
elsif resource_array.empty?
raise 'Scimitar::Engine::set_default_resources: At least one resource must be given'
raise 'Scimitar::Engine.set_default_resources: At least one resource must be given'
end

@default_resources = resource_array
Expand Down
12 changes: 6 additions & 6 deletions spec/requests/engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ def self.endpoint; '/License'; end
end

it 'notes changes to defaults' do
Scimitar::Engine::set_default_resources([Scimitar::Resources::User])
Scimitar::Engine.set_default_resources([Scimitar::Resources::User])
expect(Scimitar::Engine.resources()).to match_array([Scimitar::Resources::User])
end

it 'notes changes to defaults with custom resources added' do
Scimitar::Engine::set_default_resources([Scimitar::Resources::User])
Scimitar::Engine.set_default_resources([Scimitar::Resources::User])
Scimitar::Engine.add_custom_resource(@license_resource)
expect(Scimitar::Engine.resources()).to match_array([Scimitar::Resources::User, @license_resource])
end

it 'rejects bad defaults' do
expect {
Scimitar::Engine::set_default_resources([@license_resource])
}.to raise_error('Scimitar::Engine::set_default_resources: Only Scimitar::Resources::User, Scimitar::Resources::Group are supported')
Scimitar::Engine.set_default_resources([@license_resource])
}.to raise_error('Scimitar::Engine.set_default_resources: Only Scimitar::Resources::User, Scimitar::Resources::Group are supported')
end

it 'rejects empty defaults' do
expect {
Scimitar::Engine::set_default_resources([])
}.to raise_error('Scimitar::Engine::set_default_resources: At least one resource must be given')
Scimitar::Engine.set_default_resources([])
}.to raise_error('Scimitar::Engine.set_default_resources: At least one resource must be given')
end
end # "context '::resources, :add_custom_resource, ::set_default_resources' do"

Expand Down
Loading