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

Project edit by admins #1757

Merged
merged 12 commits into from
Jan 13, 2024
Merged

Project edit by admins #1757

merged 12 commits into from
Jan 13, 2024

Conversation

JoeCohen
Copy link
Member

  • 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.
@coveralls
Copy link
Collaborator

coveralls commented Dec 29, 2023

Coverage Status

coverage: 94.601% (+0.001%) from 94.6%
when pulling 59714a6 on jdc-admin-edit-project-186737545
into d3cefb8 on main.

Comment on lines +112 to +115
def can_edit?(user = User.current)
admin?(user)
end

Copy link
Member Author

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
Comment on lines +453 to +463
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)
Copy link
Member Author

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.

@JoeCohen JoeCohen marked this pull request as ready for review December 29, 2023 20:57
@JoeCohen
Copy link
Member Author

@mo-nathan:
The PR currently allows an admin to modify a Project, including destroying it.
That should be easy to change, so please let me know if you want to change it.

@JoeCohen JoeCohen merged commit 4c36e14 into main Jan 13, 2024
5 checks passed
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.

None yet

2 participants