1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

testing a non-invertible migration case

This commit is contained in:
Aaron Patterson 2010-11-19 10:42:33 -08:00
parent 47017bd169
commit 0cc6c46fe9

View file

@ -2,16 +2,28 @@ require "cases/helper"
module ActiveRecord
class InvertableMigrationTest < ActiveRecord::TestCase
class InvertableMigration < ActiveRecord::Migration
class SilentMigration < ActiveRecord::Migration
def write(text = '')
# sssshhhhh!!
end
end
class InvertableMigration < SilentMigration
def change
create_table("horses") do |t|
t.column :content, :text
t.column :remind_at, :datetime
end
end
end
def write(text = '')
# sssshhhhh!!
class NonInvertableMigration < SilentMigration
def change
create_table("horses") do |t|
t.column :content, :text
t.column :remind_at, :datetime
end
remove_column "horses", :content
end
end
@ -21,6 +33,14 @@ module ActiveRecord
end
end
def test_no_reverse
migration = NonInvertableMigration.new
migration.migrate(:up)
assert_raises(IrreversibleMigration) do
migration.migrate(:down)
end
end
def test_up
migration = InvertableMigration.new
migration.migrate(:up)