hotsh / rstat.us

Simple microblogging network based on the ostatus protocol.
http://rstat.us/
Other
722 stars 215 forks source link

Feature/change username #719

Closed wilkie closed 11 years ago

wilkie commented 11 years ago

People change their names. They do so for a very diverse set of reasons that we cannot even immediately foresee. We should respect that diversity and allow users to change their usernames.

This functionality affects the User controller and model and view.

User Model

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 have changed the name to update_profile! to reflect its mutative behavior.

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.

User Controller

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.

User View

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:

Adds one unit test:

No need for other unit tests for checking that update_profile! does not succeed when the username is not valid. Those are behaviors of the validaters, and are already tested.

LindseyB commented 11 years ago

:+1:

carols10cents commented 11 years ago

@wilkie I added on to your commits and resubmitted them all as #730-- closing this and continuing discussion over there :)