提交 a85625da 编写于 作者: A Aaron Patterson

instantiate our own broken migration rather than relying on the filesystem

上级 452195af
......@@ -879,16 +879,20 @@ def test_migrator_one_up_with_exception_and_rollback
skip "not supported on #{ActiveRecord::Base.connection.class}"
end
assert !Person.column_methods_hash.include?(:last_name)
refute Person.column_methods_hash.include?(:last_name)
e = assert_raise(StandardError) do
ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/broken", 100)
end
migration = Struct.new(:name, :version) {
def migrate(x); raise 'Something broke'; end
}.new('zomg', 100)
migrator = ActiveRecord::Migrator.new(:up, [migration], 100)
e = assert_raise(StandardError) { migrator.migrate }
assert_equal "An error has occurred, this and all later migrations canceled:\n\nSomething broke", e.message
Person.reset_column_information
assert !Person.column_methods_hash.include?(:last_name)
refute Person.column_methods_hash.include?(:last_name)
end
def test_finds_migrations
......
class MigrationThatRaisesException < ActiveRecord::Migration
def self.up
add_column "people", "last_name", :string
raise 'Something broke'
end
def self.down
remove_column "people", "last_name"
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册