aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-09-09 21:58:37 -0700
committerSantiago Pastorino <santiago@wyeworks.com>2011-09-09 21:58:37 -0700
commit4d3a73e5ddcd0ddae8d466e55e1c7c8cdb280343 (patch)
tree669ff7364bb9af3685ebf33dce44664ba53f7114 /railties/test
parentbe24be62b60c9cf6ca79aa7d20cabe6f3691e0c3 (diff)
parentbc7eddea2051a7830cce0edba1d3aed1ea3e36ba (diff)
downloadrails-4d3a73e5ddcd0ddae8d466e55e1c7c8cdb280343.tar.gz
rails-4d3a73e5ddcd0ddae8d466e55e1c7c8cdb280343.tar.bz2
rails-4d3a73e5ddcd0ddae8d466e55e1c7c8cdb280343.zip
Merge pull request #2957 from waseem/migration_status_tests
Tests for rake db:migrate:status.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/rake_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index 3e0e3713aa..6724d939d9 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -126,6 +126,30 @@ module ApplicationTests
assert_match(/AddEmailToUsers: reverted/, output)
end
+ def test_migration_status_when_schema_migrations_table_is_not_present
+ output = Dir.chdir(app_path){ `rake db:migrate:status` }
+ assert_equal "Schema migrations table does not exist yet.\n", output
+ end
+
+ def test_migration_status
+ Dir.chdir(app_path) do
+ `rails generate model user username:string password:string`
+ `rails generate migration add_email_to_users email:string`
+ end
+
+ Dir.chdir(app_path) { `rake db:migrate`}
+ output = Dir.chdir(app_path) { `rake db:migrate:status` }
+
+ assert_match(/up\s+\d{14}\s+Create users/, output)
+ assert_match(/up\s+\d{14}\s+Add email to users/, output)
+
+ Dir.chdir(app_path) { `rake db:rollback STEP=1` }
+ output = Dir.chdir(app_path) { `rake db:migrate:status` }
+
+ assert_match(/up\s+\d{14}\s+Create users/, output)
+ assert_match(/down\s+\d{14}\s+Add email to users/, output)
+ end
+
def test_loading_specific_fixtures
Dir.chdir(app_path) do
`rails generate model user username:string password:string`