aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2012-12-28 01:46:36 +0100
committerYves Senn <yves.senn@gmail.com>2012-12-28 22:32:28 +0100
commitd1f21552939c07cf7f12b9674793bb14c81eb912 (patch)
tree3d1c33da0560df707deec859f7cf2adc351d0c3b /activerecord/test/cases
parenta79300a0d80940b457a5065803486526d6bf89a1 (diff)
downloadrails-d1f21552939c07cf7f12b9674793bb14c81eb912.tar.gz
rails-d1f21552939c07cf7f12b9674793bb14c81eb912.tar.bz2
rails-d1f21552939c07cf7f12b9674793bb14c81eb912.zip
work off FIXME comments in AR rename_column_test.rb
There were a couple of tests, which had FIXME comments in palce of assertions. I replaced these FIXME comments with actual assertions to get more feedback from our test suite.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/migration/rename_column_test.rb31
1 files changed, 22 insertions, 9 deletions
diff --git a/activerecord/test/cases/migration/rename_column_test.rb b/activerecord/test/cases/migration/rename_column_test.rb
index 318d61263a..866b2e334c 100644
--- a/activerecord/test/cases/migration/rename_column_test.rb
+++ b/activerecord/test/cases/migration/rename_column_test.rb
@@ -84,16 +84,19 @@ module ActiveRecord
add_column "test_models", :hat_name, :string
add_index :test_models, :hat_name
- # FIXME: we should test that the index goes away
+ assert_equal 1, connection.indexes('test_models').size
rename_column "test_models", "hat_name", "name"
+ # FIXME: should we rename the index if it's name was autogenerated by rails?
+ assert_equal ['index_test_models_on_hat_name'], connection.indexes('test_models').map(&:name)
end
def test_remove_column_with_index
add_column "test_models", :hat_name, :string
add_index :test_models, :hat_name
- # FIXME: we should test that the index goes away
+ assert_equal 1, connection.indexes('test_models').size
remove_column("test_models", "hat_name")
+ assert_equal 0, connection.indexes('test_models').size
end
def test_remove_column_with_multi_column_index
@@ -101,14 +104,24 @@ module ActiveRecord
add_column "test_models", :hat_style, :string, :limit => 100
add_index "test_models", ["hat_style", "hat_size"], :unique => true
- # FIXME: we should test that the index goes away
+ assert_equal 1, connection.indexes('test_models').size
remove_column("test_models", "hat_size")
+
+ # FIXME: should all adapters behave the same?
+ if current_adapter?(:PostgreSQLAdapter)
+ assert_equal [], connection.indexes('test_models').map(&:name)
+ else
+ assert_equal ['index_test_models_on_hat_style_and_hat_size'], connection.indexes('test_models').map(&:name)
+ end
end
- # FIXME: we need to test that these calls do something
def test_change_type_of_not_null_column
change_column "test_models", "updated_at", :datetime, :null => false
change_column "test_models", "updated_at", :datetime, :null => false
+
+ TestModel.reset_column_information
+ assert_equal false, TestModel.columns_hash['updated_at'].null
+ ensure
change_column "test_models", "updated_at", :datetime, :null => true
end
@@ -119,7 +132,7 @@ module ActiveRecord
change_column "test_models", "funny", :boolean, :null => false, :default => true
TestModel.reset_column_information
- refute TestModel.columns_hash["funny"].null, "Column 'funny' must *not* allow nulls at this point"
+ assert_not TestModel.columns_hash["funny"].null, "Column 'funny' must *not* allow nulls at this point"
change_column "test_models", "funny", :boolean, :null => true
TestModel.reset_column_information
@@ -138,7 +151,7 @@ module ActiveRecord
new_columns = connection.columns(TestModel.table_name)
- refute new_columns.find { |c| c.name == 'age' and c.type == :integer }
+ assert_not new_columns.find { |c| c.name == 'age' and c.type == :integer }
assert new_columns.find { |c| c.name == 'age' and c.type == :string }
old_columns = connection.columns(TestModel.table_name)
@@ -149,7 +162,7 @@ module ActiveRecord
change_column :test_models, :approved, :boolean, :default => false
new_columns = connection.columns(TestModel.table_name)
- refute new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true }
+ assert_not new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true }
assert new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == false }
change_column :test_models, :approved, :boolean, :default => true
end
@@ -160,7 +173,7 @@ module ActiveRecord
change_column "test_models", "contributor", :boolean, :default => nil
TestModel.reset_column_information
- refute TestModel.new.contributor?
+ assert_not TestModel.new.contributor?
assert_nil TestModel.new.contributor
end
@@ -170,7 +183,7 @@ module ActiveRecord
change_column "test_models", "administrator", :boolean, :default => false
TestModel.reset_column_information
- refute TestModel.new.administrator?
+ assert_not TestModel.new.administrator?
end
def test_change_column_with_custom_index_name