danbartlett/opensit — pull request #55 by JohnKellyFerguson (2014-01-27 00:08:08+00:00)
Title: Add more Rspec Specs

I'm opening a pull request so @danbartlett and @tombh can be aware of the changes I made. All of them deal with adding new tests or refactoring and do not impact the functionality of the app. The commits are quite granular so if there are changes you don't like they can easily be removed. On to the changes:

* I refactored many of the User model methods and added specs for all of them (except for `User#stream_range`). The impact of these changes reduced the `User` model from 236 lines of code to 195. The notable changes made include:
* Moving the methods for validating that a user's username has no spaces and that their username does not conflict with any routes into their own Validator classes within `config/initializers`. This makes it possible to reuse these validations in other models as needed.
* Replacing `get_favourites` with a `has_many :favourite_sits`. This pattern can be replicated for anything else in the future that a `user` might favorite.
* Cutting out unnecessary references to `self` within method bodies. `self` is implicit in Ruby and does not have to be declared within a method body (except when setting an attribute, ie `self.first_name = 'john'`, but is not necessary in a method like `display_name` that returns a `first_name`. In that case `first_name` is the same as saying `self.first_name`.
* I removed the unused tests directory.
* I updated the `.gitignore` and removed RubyMine's `.idea` directory as well as some other stuff.
* I added a bunch of more factories.
* I configured `annotate` to run after each migration and appended its info to the base of all the models, specs and factories.
* I added the gem `jazz_hands` and configured it so we can use `pry` for our `rails console`.
* I added a thor task to sync the heroku database to a developer's local machine. It's quite nice. However, @danbartlett has since added a shell script that accomplishes the same thing, so this may no longer be necessary.

That pretty much covers it. Everything is well tested and doesn't break anything so should be good to merge.