diff --git a/activerecord/test/cases/invertable_migration_test.rb b/activerecord/test/cases/invertable_migration_test.rb index ab08cf6fe2..b4c1dccb22 100644 --- a/activerecord/test/cases/invertable_migration_test.rb +++ b/activerecord/test/cases/invertable_migration_test.rb @@ -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)