diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-06-04 15:03:47 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-06-16 06:25:37 +0900 |
commit | 1cf467b7a31749ccb3fc2a8ac89c5218c95e7d70 (patch) | |
tree | 55bd2830a231d521b806e76806aabb292b373928 /activerecord/test | |
parent | aa062318c451512035c10898a1af95943b1a3803 (diff) | |
download | rails-1cf467b7a31749ccb3fc2a8ac89c5218c95e7d70.tar.gz rails-1cf467b7a31749ccb3fc2a8ac89c5218c95e7d70.tar.bz2 rails-1cf467b7a31749ccb3fc2a8ac89c5218c95e7d70.zip |
Prevent `RangeError` for `FinderMethods#exists?`
`FinderMethods#exists?` should return a boolean rather than raising an
exception.
`UniquenessValidator#build_relation` catches a `RangeError` because it
includes type casting due to a string value truncation. But a string
value truncation was removed at #23523 then type casting in
`build_relation` is no longer necessary. aa06231 removes type casting in
`build_relation` then a `RangeError` moves to `relation.exists?`.
This change will remove the catching a `RangeError`.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 374a8ba199..6eaaa30cd0 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -173,11 +173,9 @@ class FinderTest < ActiveRecord::TestCase end end - def test_exists_fails_when_parameter_has_invalid_type - assert_raises(ActiveModel::RangeError) do - assert_equal false, Topic.exists?(("9"*53).to_i) # number that's bigger than int - end + def test_exists_returns_false_when_parameter_has_invalid_type assert_equal false, Topic.exists?("foo") + assert_equal false, Topic.exists?(("9"*53).to_i) # number that's bigger than int end def test_exists_does_not_select_columns_without_alias |