GrailsInAction / graina2

Source code for the 2nd edition of Grails in Action
90 stars 91 forks source link

MEAP v9, p76, "Refactoring homepage and breaking tests" refers to unexisting User() constructor. #25

Open marcpa00 opened 11 years ago

marcpa00 commented 11 years ago

The "Refactoring homepage and breaking tests" on page 76 tells us to update User() constructors to change user.homepage with user.profile.homepage, but there is no constructor in User class (at that point) and what needs to be done to fix tests is more than just updating the references, as we have to stop trying to assert on homepage as it is now validated with Profile, not User (as per the comments in UserIntegrationSpec).

I think mentionning the effect of extracting homepage into another instance, with respect to validate() and thus asserts in spec tests, would be a good addition here.

pledbrook commented 11 years ago

I don't think that box means that you should change the constructors themselves (as they don't exist), but update any locations where a User is instantiated with a homepage value, e.g.

def user = new User(homepage: "http://www.google.com")

Admittedly the language isn't particularly clear. You're also right that the tests need updating once the refactoring is done and that should be made explicit here.