Add permissions to Role#382
Merged
nholden merged 1 commit intoworkos:mainfrom Jul 3, 2025
Merged
Conversation
The API response for Roles now includes the permissions associated with that role. However, this has not been exposed in the ruby API. This commit fixes that problem.
Contributor
There was a problem hiding this comment.
PR Summary
Adds permissions attribute to the Role class to expose permissions data from the WorkOS API response.
- Added
permissionstolib/workos/role.rbwith empty array fallback for backward compatibility - Updated
lib/workos/organizations.rbdocumentation forlist_organization_rolesto reflect new permissions field - Added comprehensive test coverage in
spec/lib/workos/role_spec.rbfor permissions handling - Updated VCR cassettes in
spec/support/fixtures/vcr_cassettes/organization/list_organization_roles.ymlto include permissions data - Added test cases in
spec/lib/workos/organizations_spec.rbfor proper serialization and initialization
5 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile
| roles = described_class.list_organization_roles(organization_id: 'org_01JEXP6Z3X7HE4CB6WQSH9ZAFE') | ||
|
|
||
| billing_role = roles.data.find { |role| role.slug == 'billing' } | ||
| serialized = billing_role.to_json |
Contributor
There was a problem hiding this comment.
logic: .to_json returns a JSON string, but test expects a hash. Should be testing against billing_role.as_json or parsing the JSON string first
Suggested change
| serialized = billing_role.to_json | |
| serialized = billing_role.as_json |
Contributor
There was a problem hiding this comment.
to_json returns a hash. We do things a little different around here. 🤠
hakusaro
approved these changes
Jul 2, 2025
nholden
approved these changes
Jul 3, 2025
Contributor
nholden
left a comment
There was a problem hiding this comment.
This is great, thank you! Appreciate the thorough tests.
| roles = described_class.list_organization_roles(organization_id: 'org_01JEXP6Z3X7HE4CB6WQSH9ZAFE') | ||
|
|
||
| billing_role = roles.data.find { |role| role.slug == 'billing' } | ||
| serialized = billing_role.to_json |
Contributor
There was a problem hiding this comment.
to_json returns a hash. We do things a little different around here. 🤠
Merged
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The API response for Roles now includes the permissions associated with that role. However, this has not been exposed in the ruby API. This commit fixes that problem.
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.