-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(users): validation flashes for batch city and referrer (#318)
* feat(users): validate that referrer exists * feat(users): validate city can't change * feat(users): validate batch can't change * fix(users): rspec * fix(users): revert refactos * fix(users) disable Metrics/ClassLength for user model * fix(users): rename cant to cannot * fix(users): move referrer param inside params * feat(users): add explanation for params[:batch_id] = nil if form_params[:batch_number] * refactor(users): validations params * Spacing * Handle referral_code in a proper update_referrer method (we keep referrer_code unpermitted) and drop the flash message for the batch, it's not worth the effort (after a looooong thought and tests). Forbidding City update is important (and easy) because scoring depends on it. Displaying a proper error message when a user tries a wrong referral code is worth it. * Add back the batch validation * Rename update to assign referrer * Wording * Rename, again * Trigger batch/city validations on update * Rollback to the previous behaviour: referrer cannot be nil after it was set * Test pass, but behaviour is not as expected * fix(users): add #to_i to referrer_id to trigger change even if user has no referrer yet * Explicitly use -1 if referrer is not found --------- Co-authored-by: pil0u <8350914+pil0u@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
39 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters