justin808/fat-code-refactoring-techniques — pull request #7 by justin808 (2014-04-09 09:42:00+00:00)
Title: Single purpose controller

# Single Purpose Controller

This is a preferable alternative to pull request https://github.com/justin808/fat-code-refactoring-techniques/pull/6, which uses a Service Object pattern.

Objectives:
- Splitting the `MicropostController` into the `MicropostCreateController` to so
that a complicated controller method can be refactored to have many private
methods that relate to the only public method, on the "single purpose
controller". I.e. conform to the Sandi rules of small methods.
- Demonstrate changing the routing for a custom named controller.
- Demonstrate a controller spec that covers everything the service object spec
covered, but covers it more accurately because it actually verifies that the
controller is doing the right thing.
- Demonstrate following features of controller spec testing in rspec:
- testing flash.now
- checking instance variable
- checking rendered template

- Demonstrate using a model object, `ProfanityChecker` to handle logic for a
potentially complex validation.
- Demonstrates simple tests of this ProfanityChecker class.