This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/refactor-to-user-model
Shouldn’t we be unit testing the new User model before writing it? If we’re doing TDD, it feels a bit wrong to use only the features to test this.
Is there a reason why we don’t create a
User model with
I mean, doing that would require more steps:
- Create a User migration with
- Create a Todo migration that removes
- For production, we would first run a task that creates users/associations based on emails currently stored in todos.
- We can still look for
session[:current_email], but we can change that to
session[:user_id], since we need to locate a User record on session create.
I guess using a Ruby class is the most minimal code required to get the tests to pass, and offering the minimal amount of changes. Could that be the reason then?