diff options
author | Andrew White <andrew.white@unboxed.co> | 2017-03-04 13:20:13 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2017-03-04 13:20:13 +0000 |
commit | b1459fce6e5b64e9b70351b472816b219af5d6fd (patch) | |
tree | 009a9d0aa530a5c2a57a72fa54034a85397571f4 /activerecord/test/cases/migrator_test.rb | |
parent | 0d73f9116ccd3ded23e69d70ff5ed23dd339df5b (diff) | |
parent | 7b49c5e2f5ca7879d18f6fa00d8f2a25c43b422e (diff) | |
download | rails-b1459fce6e5b64e9b70351b472816b219af5d6fd.tar.gz rails-b1459fce6e5b64e9b70351b472816b219af5d6fd.tar.bz2 rails-b1459fce6e5b64e9b70351b472816b219af5d6fd.zip |
Merge pull request #25174 from kamipo-fix_db_migrate_status
Fix `rake db:migrate:status` with subdirectories.
Diffstat (limited to 'activerecord/test/cases/migrator_test.rb')
-rw-r--r-- | activerecord/test/cases/migrator_test.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/activerecord/test/cases/migrator_test.rb b/activerecord/test/cases/migrator_test.rb index 20d70b75ac..81f9749063 100644 --- a/activerecord/test/cases/migrator_test.rb +++ b/activerecord/test/cases/migrator_test.rb @@ -124,6 +124,50 @@ class MigratorTest < ActiveRecord::TestCase assert_equal migration_list.last, migrations.first end + def test_migrations_status + path = MIGRATIONS_ROOT + "/valid" + + ActiveRecord::SchemaMigration.create(version: 2) + ActiveRecord::SchemaMigration.create(version: 10) + + assert_equal [ + ["down", "001", "Valid people have last names"], + ["up", "002", "We need reminders"], + ["down", "003", "Innocent jointable"], + ["up", "010", "********** NO FILE **********"], + ], ActiveRecord::Migrator.migrations_status(path) + end + + def test_migrations_status_in_subdirectories + path = MIGRATIONS_ROOT + "/valid_with_subdirectories" + + ActiveRecord::SchemaMigration.create(version: 2) + ActiveRecord::SchemaMigration.create(version: 10) + + assert_equal [ + ["down", "001", "Valid people have last names"], + ["up", "002", "We need reminders"], + ["down", "003", "Innocent jointable"], + ["up", "010", "********** NO FILE **********"], + ], ActiveRecord::Migrator.migrations_status(path) + end + + def test_migrations_status_from_two_directories + paths = [MIGRATIONS_ROOT + "/valid_with_timestamps", MIGRATIONS_ROOT + "/to_copy_with_timestamps"] + + ActiveRecord::SchemaMigration.create(version: "20100101010101") + ActiveRecord::SchemaMigration.create(version: "20160528010101") + + assert_equal [ + ["down", "20090101010101", "People have hobbies"], + ["down", "20090101010202", "People have descriptions"], + ["up", "20100101010101", "Valid with timestamps people have last names"], + ["down", "20100201010101", "Valid with timestamps we need reminders"], + ["down", "20100301010101", "Valid with timestamps innocent jointable"], + ["up", "20160528010101", "********** NO FILE **********"], + ], ActiveRecord::Migrator.migrations_status(paths) + end + def test_migrator_interleaved_migrations pass_one = [Sensor.new("One", 1)] |