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

Refactor supported permissions method #3087

Merged
merged 1 commit into from
Aug 13, 2024
Merged

Refactor supported permissions method #3087

merged 1 commit into from
Aug 13, 2024

Conversation

yndajas
Copy link
Member

@yndajas yndajas commented Aug 13, 2024

The sorted_supported_permissions_grantable_from_ui method was getting a little complex, with a lot of conditional logic. This separates out the sorting and filtering, with the former the responsibility of the SupportedPermission model, and the latter remaining the responsibility of the Doorkeeper::Application model based on the passed in arguments

In the Doorkeeper::Application tests, we're using Mocha's with with a block using Minitest's assert_same_elements to check that the array argument contains the same elements regardless of order

Mocha does have various ParameterMatchers, which can be used with with, but unfortunately not an equivalent of assert_same_elements or something like Jest's expect.arrayContaining


This application is owned by the publishing platform team. Please let us know in #govuk-publishing-platform when you raise any PRs.

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

Base automatically changed from 1184-redux to main August 13, 2024 14:34
The `sorted_supported_permissions_grantable_from_ui` method was getting
a little complex, with a lot of conditional logic. This separates out
the sorting and filtering, with the former the responsibility of the
`SupportedPermission` model, and the latter remaining the responsibility
of the `Doorkeeper::Application` model based on the passed in arguments

In the `Doorkeeper::Application` tests, we're using [Mocha's with][1]
with a block using [Minitest's assert_same_elements][2] to check that
the array argument contains the same elements regardless of order

Mocha does have various [ParameterMatchers][3], which can be used with
`with`, but unfortunately not an equivalent of `assert_same_elements` or
something like [Jest's expect.arrayContaining][4]

[1]: https://mocha.jamesmead.org/Mocha/Expectation.html#with-instance_method
[2]: https://www.rubydoc.info/gems/minitest-rails-shoulda/0.4.1/MiniTest%2FAssertions:assert_same_elements
[3]: https://mocha.jamesmead.org/Mocha/ParameterMatchers.html
[4]: https://jestjs.io/docs/expect#expectarraycontainingarray

Co-authored-by: Ynda Jas <[email protected]>
@yndajas yndajas merged commit 7ddee7d into main Aug 13, 2024
15 checks passed
@yndajas yndajas deleted the 1184-refactor branch August 13, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants