Skip to content

Validate UserDetail#website_url only on update

Jessie Young requested to merge jy-website-url-regression into master

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

  1. Create a user with an invalid website_url
    user.user_detail.update_attribute(:website_url, 'notAwebsite')
  2. Visit the user's profile and attempt to update any attribute other than website_url: http://localhost:3000/-/profile
  3. Update should work
  4. Visit the user's profile and attempt to update website_url to an invaid URL: http://localhost:3000/-/profile
  5. 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.

Edited by Jessie Young

Merge request reports

Loading