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:
parent
47017bd169
commit
0cc6c46fe9
1 changed files with 23 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue