rails/rails — pull request #16670 by chancancode (2014-08-24 12:09:04+00:00)
Title: Fixed find_by("sql fragment without bindings") on 4.2.0.beta1

This fixes a regression on 4.2.0.beta1 where calling `Post.find_by("1 = 1")` would cause an error (undefined method `value` on String).

Also...

* I duplicated the `find_by` tests from `relations_test.rb` to `finder_test.rb`. Now that we have a completely different implementation for `Base.find_by` vs `Relation#find_by`, it seems wise to have a different set of tests covering it.

* I removed the (failing) tests for the find_by delegation. Now that we have tests for the actual behavior, there's no point having another test that tests the implementation (that it delegates). Further, what the test was implying is no longer true with the current implementation, because `Base.find_by` is a real method now instead of always delegating to `all`.

* I noticed that `find_by!` doesn't seem to use the query cache at the moment, so I added that as well. It doesn't seem like we have ways to test that things are actually being cached, so I didn't add test that. But I duplicated the relation test cases for the class method on `Base` in `finder_test.rb`.

cc @tenderlove @matthewd