blob: 247704895468ffcdbd50f7ce04a8b9ae5a9c6c55 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
require "cases/helper"
module ActiveRecord
class InvertableMigrationTest < ActiveRecord::TestCase
class InvertableMigration < ActiveRecord::Migration
def change
create_table("horses") do |t|
t.column :content, :text
t.column :remind_at, :datetime
end
end
def write(text = '')
# sssshhhhh!!
end
end
def treardown
if ActiveRecord::Base.connection.table_exists?("horses")
ActiveRecord::Base.connection.drop_table("horses")
end
end
def test_invertable?
migration = InvertableMigration.new
assert migration.invertable?, 'should be invertable'
end
def test_up
migration = InvertableMigration.new
migration.migrate(:up)
assert migration.connection.table_exists?("horses"), "horses should exist"
end
def test_down
migration = InvertableMigration.new
migration.migrate :up
migration.migrate :down
assert !migration.connection.table_exists?("horses")
end
end
end
|