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

rework CollectionMembershipValidator to skip overwriting collections #5615

Merged
merged 4 commits into from May 14, 2022

Conversation

no-reply
Copy link
Member

the validator should limit itself to validating that the collections are
allowed.

whether or not validation is ever run, #sync should apply the form values to
the target resource. ensure this happens by moving the value population behavior
into a reform populator.

without this work, the Hyrax::CollectionMembershipValidator was erasing
existing collection membership. validators should never change the records being
validated.

@samvera/hyrax-code-reviewers

@no-reply
Copy link
Member Author

i think it would be a good idea to write further tests for the validator. without unit tests for its behavior i think it could become hard to understand its requirements.

@no-reply no-reply force-pushed the collection-validation branch 3 times, most recently from 903416e to 6314a77 Compare May 10, 2022 23:56
@no-reply no-reply requested a review from elrayle May 11, 2022 00:00
@no-reply no-reply force-pushed the collection-validation branch 2 times, most recently from 43eb185 to 360656d Compare May 11, 2022 00:31
@elrayle
Copy link
Contributor

elrayle commented May 11, 2022

Summary of Slack discussion. See PR #5448 which added the validator. There was a good bit of discussion around how to populate the collections.

@no-reply
Copy link
Member Author

@elrayle I tried to find the relevant discussion in #5448, but I think I'm missing it. would you mind linking directly to the comments you're hoping people will consider?

tamsin johnson added 4 commits May 11, 2022 10:40
the validator should limit itself to validating that the collections are
allowed.

whether or not validation is ever run, `#sync` should apply the form values to
the target resource. ensure this happens by moving the value population behavior
into a reform populator.

without this work, the `Hyrax::CollectionMembershipValidator` was erasing
existing collection membership. validators should never change the records being
validated.
i had missed in the previous commit that there was an existing set of specs just
slightly out of path. this merges the two and drops the expectations for the now
removed behavior.
check that the correct error is populated.
the prior implementation of this validator ignored and overwrote existing
collections. the forms don't expand existing `member_of_collection_ids` into
attributes for submission, so it's important that we validate membership based
both on the existing ids AND any new submitted attributes.

the newer implementation handles this case, so this adds a regression test for
the requirement.
@no-reply no-reply merged commit f2df82e into main May 14, 2022
@no-reply no-reply deleted the collection-validation branch May 14, 2022 00:23
@dlpierce dlpierce added the notes-valkyrie Release Notes: Valkyrie specific label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes-valkyrie Release Notes: Valkyrie specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants