Skip to content
This repository
Browse code

Merge pull request #2957 from waseem/migration_status_tests

Tests for rake db:migrate:status.
  • Loading branch information...
commit 4d3a73e5ddcd0ddae8d466e55e1c7c8cdb280343 2 parents be24be6 + bc7edde
Santiago Pastorino spastorino authored

Showing 1 changed file with 24 additions and 0 deletions. Show diff stats Hide diff stats

  1. +24 0 railties/test/application/rake_test.rb
24 railties/test/application/rake_test.rb
@@ -126,6 +126,30 @@ def test_model_and_migration_generator_with_change_syntax
126 126 assert_match(/AddEmailToUsers: reverted/, output)
127 127 end
128 128
  129 + def test_migration_status_when_schema_migrations_table_is_not_present
  130 + output = Dir.chdir(app_path){ `rake db:migrate:status` }
  131 + assert_equal "Schema migrations table does not exist yet.\n", output
  132 + end
  133 +
  134 + def test_migration_status
  135 + Dir.chdir(app_path) do
  136 + `rails generate model user username:string password:string`
  137 + `rails generate migration add_email_to_users email:string`
  138 + end
  139 +
  140 + Dir.chdir(app_path) { `rake db:migrate`}
  141 + output = Dir.chdir(app_path) { `rake db:migrate:status` }
  142 +
  143 + assert_match(/up\s+\d{14}\s+Create users/, output)
  144 + assert_match(/up\s+\d{14}\s+Add email to users/, output)
  145 +
  146 + Dir.chdir(app_path) { `rake db:rollback STEP=1` }
  147 + output = Dir.chdir(app_path) { `rake db:migrate:status` }
  148 +
  149 + assert_match(/up\s+\d{14}\s+Create users/, output)
  150 + assert_match(/down\s+\d{14}\s+Add email to users/, output)
  151 + end
  152 +
129 153 def test_loading_specific_fixtures
130 154 Dir.chdir(app_path) do
131 155 `rails generate model user username:string password:string`

0 comments on commit 4d3a73e

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