darrencauthon/freeboard-rails — pull request #7 by darrencauthon (2014-12-06 14:24:03+00:00)
Title: I think tests make refactoring easier

Here's a refactor where I move the lookup logic to the model.

As soon as I made the refactor, my tests broke. Oh no! But it's ok... I only had to change where the tests were pointing, as illustrated here: https://github.com/darrencauthon/freeboard-rails/commit/037dd07df7ebe48bc543e26fec6924418460c4ec#diff-5202620d7cc61d17eecdf314236d4ac5L44

Note: TESTS PASSING

Since these model tests were in the controller file, I moved them into the model: https://github.com/darrencauthon/freeboard-rails/commit/d1bf8bbe17cab2a83d851da80b17386b581b42d1

Note: TESTS PASSING

So with this refactor, I decided to drop this troublesome ```dashboard``` method on the controller: https://github.com/darrencauthon/freeboard-rails/commit/c94be6bfeb28815b4d8622b95ffa1c8cc5795ba9

Note: TESTS FAILING (but I committed here only to illustrate the point)

Tests are failing, and the tests tell me what is failing. So I fix those broken mocks with little code: https://github.com/darrencauthon/freeboard-rails/commit/2caacd05fe3268a12e0888b8750b67f3e360750f

Note: TESTS PASSING (Normally this is where I'd commit after the previous refactor)