aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-30 12:02:26 -0700
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-30 12:02:26 -0700
commit4d9be13a381948377678f12880a43341ea0571dc (patch)
treea6e1261da13928b4670b45959147b22e1d320a42 /activerecord/test/cases
parent6b9d1a0db2f7829509689d244d6a5eda5210401d (diff)
parent59e23e2ff22c0deb770af768c4cc04bd1b2c2ad7 (diff)
downloadrails-4d9be13a381948377678f12880a43341ea0571dc.tar.gz
rails-4d9be13a381948377678f12880a43341ea0571dc.tar.bz2
rails-4d9be13a381948377678f12880a43341ea0571dc.zip
Merge pull request #6913 from lexmag/column_exists_options
Add :default and :null options to column_exists? method Examples: column_exists?(:testings, :taggable_id, :integer, null: false) column_exists?(:testings, :taggable_type, :string, default: 'Photo')
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/migration/change_schema_test.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb
index ab61a4dcef..ce9be66069 100644
--- a/activerecord/test/cases/migration/change_schema_test.rb
+++ b/activerecord/test/cases/migration/change_schema_test.rb
@@ -291,14 +291,20 @@ module ActiveRecord
def test_column_exists_with_definition
connection.create_table :testings do |t|
- t.column :foo, :string, :limit => 100
- t.column :bar, :decimal, :precision => 8, :scale => 2
+ t.column :foo, :string, limit: 100
+ t.column :bar, :decimal, precision: 8, scale: 2
+ t.column :taggable_id, :integer, null: false
+ t.column :taggable_type, :string, default: 'Photo'
end
- assert connection.column_exists?(:testings, :foo, :string, :limit => 100)
- refute connection.column_exists?(:testings, :foo, :string, :limit => 50)
- assert connection.column_exists?(:testings, :bar, :decimal, :precision => 8, :scale => 2)
- refute connection.column_exists?(:testings, :bar, :decimal, :precision => 10, :scale => 2)
+ assert connection.column_exists?(:testings, :foo, :string, limit: 100)
+ refute connection.column_exists?(:testings, :foo, :string, limit: nil)
+ assert connection.column_exists?(:testings, :bar, :decimal, precision: 8, scale: 2)
+ refute connection.column_exists?(:testings, :bar, :decimal, precision: nil, scale: nil)
+ assert connection.column_exists?(:testings, :taggable_id, :integer, null: false)
+ refute connection.column_exists?(:testings, :taggable_id, :integer, null: true)
+ assert connection.column_exists?(:testings, :taggable_type, :string, default: 'Photo')
+ refute connection.column_exists?(:testings, :taggable_type, :string, default: nil)
end
def test_column_exists_on_table_with_no_options_parameter_supplied