This is the repository for the rails conf workshop
It contains an example of fairly innocent code at first sight in the invitations_controller.
Its a basic example of what we face most of the time when code is shipped quickly. Even though it works and its tested, most of the logic is actually hidden in callbacks (who would expect a payment to be made just by reading the controller's code?). And as I've seen very often:
- models are crying to get context (most of the time relying on additionnal instance variables).
- and only happy path is taken into account which means data would be in a bad state if error happens somewhere
The refactoring we'll do is expected to fix this.
The app simpy uses sqlite3 as a db. I tried to keep minimum dependencies. Just install required gems
bundle
and then ensure everything is ok by running the specs:
rake
- read together invitations_controller_spec, particularly the commented one
- implement user/signup
- implement invitation/create
- notice invitation accept is actually a relevant piece of logic and move code from controller to invitation/accept
- split code to relevant services: user/create_from_invitation, user/credit
- change user/create_from_invitation, user/credit to boolean services so we can call them from invitation/accept
- change to waterfall implementation