aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration_test.rb
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-11-11 02:47:27 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-11-11 02:47:27 +0530
commit6e112e42176c6842270f879fd15a0b7b7371ecef (patch)
tree14d6d75fb2fdd5c77b7d9d34f546d8bf502e355a /activerecord/test/cases/migration_test.rb
parent23101de283de13517e30c4c3d1ecc65525264886 (diff)
downloadrails-6e112e42176c6842270f879fd15a0b7b7371ecef.tar.gz
rails-6e112e42176c6842270f879fd15a0b7b7371ecef.tar.bz2
rails-6e112e42176c6842270f879fd15a0b7b7371ecef.zip
Modify change_table to remove the need for the block argument.
Diffstat (limited to 'activerecord/test/cases/migration_test.rb')
-rw-r--r--activerecord/test/cases/migration_test.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 50242a497c..e276993508 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -1757,6 +1757,58 @@ if ActiveRecord::Base.connection.supports_migrations?
end
end
end
+
+ def test_change_table_without_block_parameter_no_bulk
+ Person.connection.create_table :testings, :force => true do
+ string :foo
+ end
+ assert Person.connection.column_exists?(:testings, :foo, :string)
+
+ Person.connection.change_table :testings do
+ remove :foo
+ integer :bar
+ end
+
+ assert_equal %w(bar id), Person.connection.columns(:testings).map { |c| c.name }.sort
+ ensure
+ Person.connection.drop_table :testings rescue nil
+ end
+
+ def test_change_table_without_block_parameter_with_bulk
+ Person.connection.create_table :testings, :force => true do
+ string :foo
+ end
+ assert Person.connection.column_exists?(:testings, :foo, :string)
+
+ assert_queries(1) do
+ Person.connection.change_table(:testings, :bulk => true) do
+ integer :bar
+ string :foo_bar
+ end
+ end
+
+ assert_equal %w(bar foo foo_bar id), Person.connection.columns(:testings).map { |c| c.name }.sort
+ ensure
+ Person.connection.drop_table :testings rescue nil
+ end
+
+ def test_change_table_should_not_have_mixed_syntax
+ Person.connection.create_table :testings, :force => true do
+ string :foo
+ end
+ assert_raise(NoMethodError) do
+ Person.connection.change_table :testings do |t|
+ t.remove :foo
+ integer :bar
+ end
+ end
+ assert_raise(NameError) do
+ Person.connection.change_table :testings do
+ t.remove :foo
+ integer :bar
+ end
+ end
+ end
end # SexierMigrationsTest
class MigrationLoggerTest < ActiveRecord::TestCase