aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2018-01-18 13:06:08 -0500
committereileencodes <eileencodes@gmail.com>2018-01-18 13:09:15 -0500
commite0ad907ade3bca1c57a32c1987c4080305019845 (patch)
treeab57a99955f5c90e039d88c0c97eee992c8f8be4
parent4d4db4c86163c9b3fd242db543007bc3adf2d115 (diff)
downloadrails-e0ad907ade3bca1c57a32c1987c4080305019845.tar.gz
rails-e0ad907ade3bca1c57a32c1987c4080305019845.tar.bz2
rails-e0ad907ade3bca1c57a32c1987c4080305019845.zip
Add test to properly test down with a block
down is only called with a block from the rake tasks where it passes a `SCOPE`. Technically this was tested but since we don't run all the migrations we're not actually testing the down works with a `SCOPE`. To ensure we're testing both we can run `db:migrate` again to migrate users and then run `down` with a scope to test that only the bukkits migration is reverted. Updates test to prevent having to fix regressions like we did in 4d4db4c.
-rw-r--r--railties/test/application/rake/migrations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb
index 1b45e0645c..bf5b07afbd 100644
--- a/railties/test/application/rake/migrations_test.rb
+++ b/railties/test/application/rake/migrations_test.rb
@@ -29,12 +29,20 @@ module ApplicationTests
assert_match(/AMigration: migrated/, output)
+ # run all the migrations to test scope for down
+ output = rails("db:migrate")
+ assert_match(/CreateUsers: migrated/, output)
+
output = rails("db:migrate", "SCOPE=bukkits", "VERSION=0")
assert_no_match(/drop_table\(:users\)/, output)
assert_no_match(/CreateUsers/, output)
assert_no_match(/remove_column\(:users, :email\)/, output)
assert_match(/AMigration: reverted/, output)
+
+ output = rails("db:migrate", "VERSION=0")
+
+ assert_match(/CreateUsers: reverted/, output)
end
test "version outputs current version" do