Skip to content
Browse files

use one based indexes for the mock migrations

  • Loading branch information...
1 parent 867f504 commit b731593e1a01327a1ed7b19094eca3cf618a495d @tenderlove tenderlove committed
Showing with 16 additions and 16 deletions.
  1. +16 −16 activerecord/test/cases/migrator_test.rb
View
32 activerecord/test/cases/migrator_test.rb
@@ -160,11 +160,11 @@ def test_migrator_one_up
calls, migrations = sensors(3)
ActiveRecord::Migrator.new(:up, migrations, 1).migrate
- assert_equal [[:up, 1], [:up, 2]], calls
+ assert_equal [[:up, 1]], calls
calls.clear
ActiveRecord::Migrator.new(:up, migrations, 2).migrate
- assert_equal [[:up, 3]], calls
+ assert_equal [[:up, 2]], calls
end
def test_migrator_one_down
@@ -176,18 +176,18 @@ def test_migrator_one_down
ActiveRecord::Migrator.new(:down, migrations, 1).migrate
- assert_equal [[:down, 3]], calls
+ assert_equal [[:down, 3], [:down, 2]], calls
end
def test_migrator_one_up_one_down
calls, migrations = sensors(3)
ActiveRecord::Migrator.new(:up, migrations, 1).migrate
- assert_equal [[:up, 1], [:up, 2]], calls
+ assert_equal [[:up, 1]], calls
calls.clear
ActiveRecord::Migrator.new(:down, migrations, 0).migrate
- assert_equal [[:down, 2]], calls
+ assert_equal [[:down, 1]], calls
end
def test_migrator_double_up
@@ -195,7 +195,7 @@ def test_migrator_double_up
assert_equal(0, ActiveRecord::Migrator.current_version)
ActiveRecord::Migrator.new(:up, migrations, 1).migrate
- assert_equal [[:up, 1], [:up, 2]], calls
+ assert_equal [[:up, 1]], calls
calls.clear
ActiveRecord::Migrator.new(:up, migrations, 1).migrate
@@ -208,11 +208,11 @@ def test_migrator_double_down
assert_equal(0, ActiveRecord::Migrator.current_version)
ActiveRecord::Migrator.new(:up, migrations, 1).run
- assert_equal [[:up, 2]], calls
+ assert_equal [[:up, 1]], calls
calls.clear
ActiveRecord::Migrator.new(:down, migrations, 1).run
- assert_equal [[:down, 2]], calls
+ assert_equal [[:down, 1]], calls
calls.clear
ActiveRecord::Migrator.new(:down, migrations, 1).run
@@ -250,12 +250,12 @@ def test_target_version_zero_should_run_only_once
# migrate up to 1
ActiveRecord::Migrator.new(:up, migrations, 1).migrate
- assert_equal [[:up, 1], [:up, 2]], calls
+ assert_equal [[:up, 1]], calls
calls.clear
# migrate down to 0
ActiveRecord::Migrator.new(:down, migrations, 0).migrate
- assert_equal [[:down, 2]], calls
+ assert_equal [[:down, 1]], calls
calls.clear
# migrate down to 0 again
@@ -267,19 +267,19 @@ def test_migrator_going_down_due_to_version_target
calls, migrator = migrator_class(3)
migrator.up("valid", 1)
- assert_equal [[:up, 1], [:up, 2]], calls
+ assert_equal [[:up, 1]], calls
calls.clear
migrator.migrate("valid", 0)
- assert_equal [[:down, 2]], calls
+ assert_equal [[:down, 1]], calls
calls.clear
migrator.migrate("valid")
- assert_equal [[:up, 2], [:up, 3]], calls
+ assert_equal [[:up, 1], [:up, 2], [:up, 3]], calls
end
def test_migrator_rollback
- _, migrator = migrator_class(4)
+ _, migrator = migrator_class(3)
migrator.migrate("valid")
assert_equal(3, ActiveRecord::Migrator.current_version)
@@ -330,8 +330,8 @@ def m(name, version, &block)
def sensors(count)
calls = []
migrations = count.times.map { |i|
- m(nil, i) { |c,migration|
- calls << [c, migration.version + 1]
+ m(nil, i + 1) { |c,migration|
+ calls << [c, migration.version]
}
}
[calls, migrations]

0 comments on commit b731593

Please sign in to comment.
Something went wrong with that request. Please try again.