akshatpradhan/spoutlets — pull request #68 by priyaaank (2013-03-26 15:16:16+00:00)
Title: Fixing all failing specs.

Hi Akshat,

I have done a couple of things here. I have fixed the failing specs. Wherever needed I have put NOTES in detail explaining some of my rationale. I have also taken a liberty to remove some of the mocks/stubs and auto generated comments. Take a look. Some high level points from all the exercise:

* Try to use factories to create objects. If used well, they reduce a lot of boiler plate code from specs
* Avoid mocks and stubs. They represent a "fake" version of model. Even when model changes. In such scenario test may continue to pass since mock don't change with objects. Use them with caution
* Tests were primarily failing because object creation wasn't passing the mongoid validations of content and category being mandatory.
* Be careful what you allow to be updated in controller's "update" method. Usually entities should be allowed to be updated if they belong to current user, else I can post a request from curl and update a comment posted by other user on a forum. Do something like:
`current_user.entries.find(params[:id])` to look up the entries. This will auto scope the entry lookup.

Lot more comments in files. Use following rake task to look them up:

bundle exec rake notes:custom ANNOTATION=NOTE

Please note, that this looks only in source file. You have have to grep for NOTES in specs. Most of which should be in entries_controller_spec.rb