discourse/discourse — pull request #2316 by louismrose (2014-05-06 15:11:44+00:00)
Title: Refactor `where(...).first` to `find_by(...)`

As @SamSaffron described on Ruby Rogues Parley, here's a patch that refactors all instances of `SomeType.where(...).first` to `SomeType.find_by(...)`. It also updates any specs that mock or stub `where(...).first` to appropriately mock or stub `find_by(...)`.

The middle commit (1574485) contains the changes, but I've also left in the commits that add (f1369e4) and then remove (caf9076) the [metamorpher](https://github.com/mutiny/metamorpher) scripts that I used to automate the refactoring. If this pull request needs to be rebased, it might be easier to re-execute the refactoring scripts than to do a manual merge.