aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-19 10:42:33 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-19 10:50:24 -0800
commit0cc6c46fe9711d2377ff1ae6c55a03b3d1267874 (patch)
tree96ce0b8106925ccd2c9ccbec4bd8f678d14467e7
parent47017bd1697d6b4d6780356a403f91536eacd689 (diff)
downloadrails-0cc6c46fe9711d2377ff1ae6c55a03b3d1267874.tar.gz
rails-0cc6c46fe9711d2377ff1ae6c55a03b3d1267874.tar.bz2
rails-0cc6c46fe9711d2377ff1ae6c55a03b3d1267874.zip
testing a non-invertible migration case
-rw-r--r--activerecord/test/cases/invertable_migration_test.rb26
1 files changed, 23 insertions, 3 deletions
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)