diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-11-02 13:53:54 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-11-02 13:54:16 -0700 |
commit | 76d6d8828007083faa6ccca3ad0feb7ba126ef79 (patch) | |
tree | 586bd5e3bc69feb4808b8c8327cf0cfba763fee0 /activerecord/test/cases | |
parent | d5902c9e7eaba4db4e79c464d623a7d7e6e2d0e3 (diff) | |
download | rails-76d6d8828007083faa6ccca3ad0feb7ba126ef79.tar.gz rails-76d6d8828007083faa6ccca3ad0feb7ba126ef79.tar.bz2 rails-76d6d8828007083faa6ccca3ad0feb7ba126ef79.zip |
Handle `RangeError` from casting in `find_by` and `find_by!` on Relation
We should not behave differently just because a class has a default
scope.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index d1ff8516e8..dc73faa5be 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -210,6 +210,16 @@ class FinderTest < ActiveRecord::TestCase assert_nil Topic.find_by_id('9999999999999999999999999999999') end + def test_find_on_relation_with_large_number + assert_nil Topic.where('1=1').find_by(id: 9999999999999999999999999999999) + end + + def test_find_by_bang_on_relation_with_large_number + assert_raises(ActiveRecord::RecordNotFound) do + Topic.where('1=1').find_by!(id: 9999999999999999999999999999999) + end + end + def test_find_an_empty_array assert_equal [], Topic.find([]) end |