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.
Context
Potassium-generated applications with Pundit use that gem to allow access to certain resources. Sometimes we add roles to filter which pages can a user see on active admin, and if they don't have permission to see anything (not even the dashboard) the app enters on a redirect loop, leading into an exception.
Also, every Potassium-generated policy files come un-tested.
What has been done
Summary:
PagePolicy has been edited, now when de page is the Dashboard, is always shown to the user. Also, policy tests are now generated with Potassium.
Commits:
PagePolicy
Extra info
EDIT: what I describe below is now fixed, I added a
force: true
to the factory file copy, and now it works perfectly.All the new generated tests fails on a new app, but this is because de AdminUser factory is created with empty attributes. If the
email
andpassword
are added, every test pass.My doubt is: is it okay to leave it like that, with failing tests? I tried to modify the AdminUser factory file, but when the pundit recipe is ran, that file is not created yet. Also I tried to copy the AdminUser factory file (like the policies files are copied), but that generates a situation where user input is needed. This is because when the AdminUser factory file is trying to be created, it raises a warning that already exists, and user input is needed in order to decide to skip, abort, overwrite, etc.