diff options
author | Jamis Buck <jamis@37signals.com> | 2005-09-25 15:49:35 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-09-25 15:49:35 +0000 |
commit | ea654654226924f9b900e7981fdbdbd452ca15d8 (patch) | |
tree | 606aefd628d9e31eababdefc59b02c3b29d51867 /activerecord/test/migration_test.rb | |
parent | e7059fd28191a77d53e66389f8df5b22036699e8 (diff) | |
download | rails-ea654654226924f9b900e7981fdbdbd452ca15d8.tar.gz rails-ea654654226924f9b900e7981fdbdbd452ca15d8.tar.bz2 rails-ea654654226924f9b900e7981fdbdbd452ca15d8.zip |
Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2335 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/migration_test.rb')
-rw-r--r-- | activerecord/test/migration_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb index 502348877c..b24b7a7d44 100644 --- a/activerecord/test/migration_test.rb +++ b/activerecord/test/migration_test.rb @@ -68,6 +68,29 @@ if ActiveRecord::Base.connection.supports_migrations? ensure Person.connection.drop_table :testings rescue nil end + + def test_create_table_with_defaults + Person.connection.create_table :testings do |t| + t.column :one, :string, :default => "hello" + t.column :two, :boolean, :default => true + t.column :three, :boolean, :default => false + t.column :four, :integer, :default => 1 + end + + columns = Person.connection.columns(:testings) + one = columns.detect { |c| c.name == "one" } + two = columns.detect { |c| c.name == "two" } + three = columns.detect { |c| c.name == "three" } + four = columns.detect { |c| c.name == "four" } + + assert_equal "hello", one.default + assert_equal true, two.default + assert_equal false, three.default + assert_equal 1, four.default + + ensure + Person.connection.drop_table :testings rescue nil + end def test_add_column_not_null Person.connection.create_table :testings do |t| |