diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-29 22:47:58 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-29 22:57:31 -0200 |
commit | 3525a9b5ebc87bbc9dca4b613b6d3740899190bb (patch) | |
tree | ae4b7db94cefe6add402550059cf52ed0b22a0ce /activerecord/test | |
parent | a4ac2b4d0a56ae2221b90314df1f806cb9ef9192 (diff) | |
download | rails-3525a9b5ebc87bbc9dca4b613b6d3740899190bb.tar.gz rails-3525a9b5ebc87bbc9dca4b613b6d3740899190bb.tar.bz2 rails-3525a9b5ebc87bbc9dca4b613b6d3740899190bb.zip |
Fix bug when Column is trying to type cast boolean values to integer.
This can occur if the user is using :integer columns to store boolean
values. Now we are handling the boolean values but it still raises if
the value can't type cast to integer and is not a boolean. See #7509.
Fixes #8067.
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/column_test.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/test/cases/column_test.rb b/activerecord/test/cases/column_test.rb index a7b63d15c9..2124c256fa 100644 --- a/activerecord/test/cases/column_test.rb +++ b/activerecord/test/cases/column_test.rb @@ -33,6 +33,8 @@ module ActiveRecord assert_equal 0, column.type_cast('bad1') assert_equal 0, column.type_cast('bad') assert_equal 1, column.type_cast(1.7) + assert_equal 0, column.type_cast(false) + assert_equal 1, column.type_cast(true) assert_nil column.type_cast(nil) end @@ -41,11 +43,9 @@ module ActiveRecord assert_raises(NoMethodError) do column.type_cast([]) end + assert_raises(NoMethodError) do - column.type_cast(true) - end - assert_raises(NoMethodError) do - column.type_cast(false) + column.type_cast(Object.new) end end |