-
Notifications
You must be signed in to change notification settings - Fork 26
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
Project edit by admins #1757
Project edit by admins #1757
Conversation
JoeCohen
commented
Dec 29, 2023
- Lets admins edit Projects
- Turns tests of prior commit green, i.e., admin sees an edit_project link - But unexpectly breaks other tests
Uses a project fixture owned by mary or rolf and for which the other is not an admin. ControllerExtensions expects the request to pass with the first suppied user, and fail with the alternate user.
Commit ab4aaa9 broke some tests in unexpected ways. The current commit fixes those breakages as follows: - Adds a new Project fixture - Adds a NameDescription fixture associated with that Project (Needed in order to turn test_destroy_project_member green) - Updates QueryTest to conform to the new NameDescription fixture
- Gets tubaria_furfuracea_desc source_name directly instead of reflecting on project name. - Hopefully fixes [this CI test failure](https://github.com/MushroomObserver/mushroom-observer/actions/runs/7358762659/job/20032512727) - NOTE: That test passed locally. I wonder why it fails in CI, but don't want to go down that rabbit hole.
- Fixes Naming/PredicateName offense - Conforms to our other uses of `member?` Note: Only Project has `is_member?` method.
def can_edit?(user = User.current) | ||
admin?(user) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed like the simplest change to make Projects editable by admins.
- Adds clarifcation - Fixes typo
project = projects(:rolf_project) | ||
member = users(:katrina) | ||
assert( | ||
project.member?(member) && project.user != member && | ||
!project.admin?(member) && | ||
NameDescription.where(source_name: project.title).any?, | ||
"Bad fixtures: member must be project member, but not owner or admin " \ | ||
"and project must be the source of a NameDescription" | ||
) | ||
|
||
destroy_project_helper(project, katrina) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
destroy_project_helper
- Needs a Project with an associated NameDescription
- Should not destroy the Project, so it must be called with a user who cannot destroy.
@mo-nathan: |