diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-18 15:52:13 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-19 10:24:16 -0800 |
commit | 6dbbfae5638a6c847fd63d52a72247e2bb15a320 (patch) | |
tree | 80035a62aae7b1b5ff2ebc69b29ac5b01a4decad /activerecord/test | |
parent | 0d7410faabaafc6cd64f636b22a450faedc732ca (diff) | |
download | rails-6dbbfae5638a6c847fd63d52a72247e2bb15a320.tar.gz rails-6dbbfae5638a6c847fd63d52a72247e2bb15a320.tar.bz2 rails-6dbbfae5638a6c847fd63d52a72247e2bb15a320.zip |
adding invertable migration test
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/invertable_migration_test.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/activerecord/test/cases/invertable_migration_test.rb b/activerecord/test/cases/invertable_migration_test.rb new file mode 100644 index 0000000000..2477048954 --- /dev/null +++ b/activerecord/test/cases/invertable_migration_test.rb @@ -0,0 +1,42 @@ +require "cases/helper" + +module ActiveRecord + class InvertableMigrationTest < ActiveRecord::TestCase + class InvertableMigration < ActiveRecord::Migration + def change + create_table("horses") do |t| + t.column :content, :text + t.column :remind_at, :datetime + end + end + + def write(text = '') + # sssshhhhh!! + end + end + + def treardown + if ActiveRecord::Base.connection.table_exists?("horses") + ActiveRecord::Base.connection.drop_table("horses") + end + end + + def test_invertable? + migration = InvertableMigration.new + assert migration.invertable?, 'should be invertable' + end + + def test_up + migration = InvertableMigration.new + migration.migrate(:up) + assert migration.connection.table_exists?("horses"), "horses should exist" + end + + def test_down + migration = InvertableMigration.new + migration.migrate :up + migration.migrate :down + assert !migration.connection.table_exists?("horses") + end + end +end |