aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-01-11 23:13:54 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-01-11 23:20:13 -0200
commit16c4cb04d4c3757f29be50a9cfb49472ac90f9ce (patch)
treeba322835a207c73b6e2b5dc222ed1a2f340ecf91 /activerecord/test
parent54117b69615b5b1ba05bd9fcaec5cc66347828de (diff)
downloadrails-16c4cb04d4c3757f29be50a9cfb49472ac90f9ce.tar.gz
rails-16c4cb04d4c3757f29be50a9cfb49472ac90f9ce.tar.bz2
rails-16c4cb04d4c3757f29be50a9cfb49472ac90f9ce.zip
on and ON are type casted to a true boolean column
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/column_test.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/activerecord/test/cases/column_test.rb b/activerecord/test/cases/column_test.rb
new file mode 100644
index 0000000000..ccc57cb876
--- /dev/null
+++ b/activerecord/test/cases/column_test.rb
@@ -0,0 +1,29 @@
+require "cases/helper"
+
+module ActiveRecord
+ module ConnectionAdapters
+ class ColumnTest < ActiveRecord::TestCase
+ def test_type_cast_boolean
+ column = Column.new("field", nil, "boolean")
+ assert column.type_cast(true)
+ assert column.type_cast(1)
+ assert column.type_cast('1')
+ assert column.type_cast('t')
+ assert column.type_cast('T')
+ assert column.type_cast('true')
+ assert column.type_cast('TRUE')
+ assert column.type_cast('on')
+ assert column.type_cast('ON')
+ assert !column.type_cast(false)
+ assert !column.type_cast(0)
+ assert !column.type_cast('0')
+ assert !column.type_cast('f')
+ assert !column.type_cast('F')
+ assert !column.type_cast('false')
+ assert !column.type_cast('FALSE')
+ assert !column.type_cast('off')
+ assert !column.type_cast('OFF')
+ end
+ end
+ end
+end