diff options
author | Peter Mitchell <petmit@gmail.com> | 2012-02-17 16:56:57 +0100 |
---|---|---|
committer | Peter Mitchell <petmit@gmail.com> | 2012-02-17 16:58:11 +0100 |
commit | 910c59fffe4cd4e61eef66202951ad19155cc34a (patch) | |
tree | e00b4c35b32c2b083dae18fcd4c98b7a630f4d2e /railties/test/application/rake | |
parent | b9ad097565968332acb6e91fc602459f035639a9 (diff) | |
download | rails-910c59fffe4cd4e61eef66202951ad19155cc34a.tar.gz rails-910c59fffe4cd4e61eef66202951ad19155cc34a.tar.bz2 rails-910c59fffe4cd4e61eef66202951ad19155cc34a.zip |
Correctly print names of non-timestamped migrations with db:migrate:status
Diffstat (limited to 'railties/test/application/rake')
-rw-r--r-- | railties/test/application/rake/migrations_test.rb | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 301e516192..c94334f189 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -67,7 +67,7 @@ module ApplicationTests `rails generate migration add_email_to_users email:string` end - Dir.chdir(app_path) { `rake db:migrate`} + 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) @@ -80,6 +80,27 @@ module ApplicationTests assert_match(/down\s+\d{14}\s+Add email to users/, output) end + test 'migration status without timestamps' do + add_to_config('config.active_record.timestamped_migrations = false') + + 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{3,}\s+Create users/, output) + assert_match(/up\s+\d{3,}\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{3,}\s+Create users/, output) + assert_match(/down\s+\d{3,}\s+Add email to users/, output) + end + test 'test migration status after rollback and redo' do Dir.chdir(app_path) do `rails generate model user username:string password:string` @@ -104,6 +125,33 @@ module ApplicationTests assert_match(/up\s+\d{14}\s+Create users/, output) assert_match(/up\s+\d{14}\s+Add email to users/, output) end + + test 'migration status after rollback and redo without timestamps' do + add_to_config('config.active_record.timestamped_migrations = false') + + 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{3,}\s+Create users/, output) + assert_match(/up\s+\d{3,}\s+Add email to users/, output) + + Dir.chdir(app_path) { `rake db:rollback STEP=2` } + output = Dir.chdir(app_path) { `rake db:migrate:status` } + + assert_match(/down\s+\d{3,}\s+Create users/, output) + assert_match(/down\s+\d{3,}\s+Add email to users/, output) + + Dir.chdir(app_path) { `rake db:migrate:redo` } + output = Dir.chdir(app_path) { `rake db:migrate:status` } + + assert_match(/up\s+\d{3,}\s+Create users/, output) + assert_match(/up\s+\d{3,}\s+Add email to users/, output) + end end end end |