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