aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-08-02 20:31:22 +0930
committerGitHub <noreply@github.com>2017-08-02 20:31:22 +0930
commit75436a49843c4a5f27b11bcb6ce4ccbdbb7a5f7a (patch)
treeb8765ff0e7cba8790c806b095535882964d0a13f /activerecord/test/cases
parent73f887af620371e1229dc10d809e45335b6f7bba (diff)
parent0d56480c4b547915f99f3581065e52a48bd98ca1 (diff)
downloadrails-75436a49843c4a5f27b11bcb6ce4ccbdbb7a5f7a.tar.gz
rails-75436a49843c4a5f27b11bcb6ce4ccbdbb7a5f7a.tar.bz2
rails-75436a49843c4a5f27b11bcb6ce4ccbdbb7a5f7a.zip
Merge pull request #29842 from kamipo/fix_find_by_with_range
Fix `find_by` with range conditions
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/finder_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 0b4dce37cc..a0d87dfb90 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -1179,6 +1179,10 @@ class FinderTest < ActiveRecord::TestCase
assert_equal posts(:eager_other), Post.find_by("id = ?", posts(:eager_other).id)
end
+ test "find_by with range conditions returns the first matching record" do
+ assert_equal posts(:eager_other), Post.find_by(id: posts(:eager_other).id...posts(:misc_by_bob).id)
+ end
+
test "find_by returns nil if the record is missing" do
assert_nil Post.find_by("1 = 0")
end