forked from hotsh/rstat.us
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds functionality to change your username.
This functionality affects the User controller and model and view. In the model, I have replaced the behavior of the edit_user_profile badness to just add freaking errors to self whenever something is invalid instead of reporting a string since those errors contain consistent error messages anyway. It does not return. I will reflect this in another commit by changing the name to something more appropriate. Which means in the model, I have added messages to validations that for some reason did not have one before. We should put those strings all in one place eventually for sanity. In the controller, I updated the, um, update action to look for errors like a normal controller action would and respond naturally. Some wonkiness occurs. This wonkiness is a result of trying to change the field that the current url is built from. Therefore, let's use the canonical user, current_user, whenever possible. When redirecting, we have changed the canonical user, therefore use @user to generate urls. That wonkiness is in the view. Here, @user is the current image of the user and current_user is the true user (or preimage, I guess.) So, using current_user where (honestly, you would expect current_user anyway) you want to use the stable values and @user when you want the changed fields is what I've done. Tests: Updates tests to reflect changes in error messages. Adds four acceptance tests to edit_profile_test: * it updates your username (check that a username can simply be changed) * it does not update your username if the chosen username exists (make sure that you cannot steal somebody else's name) * it redirects to your new name when you change your username (the redirect should take you to your profile, which has a different url now) * it does not allow you to change your username to something invalid (do not allow special characters in your name) Adds one unit test: * username can be changed (checks that the edit_user_profile method, which will become update_profile! actually updates the username with the given parameter)
- Loading branch information
1 parent
5753359
commit eb2f34d
Showing
5 changed files
with
87 additions
and
22 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
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