Validate UserDetail#website_url only on update
What does this MR do and why?
- This attribute is derived/synced with the
User#website_url
, see this MR for implementation: !95107 (diffs) -
User#website_url
is only validated when it is changed, see this MR for implementation: !69624 (merged) - As a result, there are User records with an invalid website_url that are still valid records as long as the website_url isn't being updated.
- Because UserDetail was validating website_url in all contexts, not just when it was changed, this meant that any updates to a User were erroring because the data was being synced to a UserDetail record that was invalid.
- Issue reporting this issue: #382545 (closed)
Screenshots or screen recordings
Before:
Screen_Recording_2022-11-16_at_9.35.33_AM
After:
Screen_Recording_2022-11-16_at_9.35.59_AM
How to set up and validate locally
- Create a user with an invalid website_url
user.user_detail.update_attribute(:website_url, 'notAwebsite')
- Visit the user's profile and attempt to update any attribute other than website_url: http://localhost:3000/-/profile
- Update should work
- Visit the user's profile and attempt to update website_url to an invaid URL: http://localhost:3000/-/profile
- Update should fail with error
Website url is not a valid URL
-->
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Jessie Young