mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
adding invertable migration test
This commit is contained in:
parent
0d7410faab
commit
6dbbfae563
1 changed files with 42 additions and 0 deletions
42
activerecord/test/cases/invertable_migration_test.rb
Normal file
42
activerecord/test/cases/invertable_migration_test.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue