From 96a13fc7de77d7e5cdadb2857b94c4e859174faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 29 Oct 2012 22:47:58 -0200 Subject: 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. --- activerecord/test/cases/column_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/test/cases/column_test.rb') diff --git a/activerecord/test/cases/column_test.rb b/activerecord/test/cases/column_test.rb index 4fcf8a33a4..b1c1165bd9 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 end -- cgit v1.2.3