Skip to content
Browse files

Tests for rake db:migrate:status.

  • Loading branch information...
1 parent b325a77 commit bc7eddea2051a7830cce0edba1d3aed1ea3e36ba @waseem waseem committed
Showing with 25 additions and 1 deletion.
  1. +25 −1 railties/test/application/rake_test.rb
View
26 railties/test/application/rake_test.rb
@@ -219,6 +219,30 @@ def test_model_and_migration_generator_with_change_syntax
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`
@@ -245,4 +269,4 @@ def test_scaffold_tests_pass_by_default
assert_match(/7 tests, 10 assertions, 0 failures, 0 errors/, content)
end
end
-end
+end

0 comments on commit bc7edde

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