1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add test cases for model and migration generators which use change method.

This commit is contained in:
Prem Sichanugrist 2011-01-02 03:21:25 +07:00 committed by Aaron Patterson
parent ad343d7263
commit 4805ec1449

View file

@ -63,5 +63,24 @@ module ApplicationTests
RUBY
assert_match 'cart GET /cart(.:format)', Dir.chdir(app_path){ `rake routes` }
end
def test_model_and_migration_generator_with_change_syntax
Dir.chdir(app_path) do
`rails generate model user username:string password:string`
`rails generate migration add_email_to_users email:string`
end
output = Dir.chdir(app_path){ `rake db:migrate` }
assert_match /create_table\(:users\)/, output
assert_match /CreateUsers: migrated/, output
assert_match /add_column\(:users, :email, :string\)/, output
assert_match /AddEmailToUsers: migrated/, output
output = Dir.chdir(app_path){ `rake db:rollback STEP=2` }
assert_match /drop_table\("users"\)/, output
assert_match /CreateUsers: reverted/, output
assert_match /remove_column\("users", :email\)/, output
assert_match /AddEmailToUsers: reverted/, output
end
end
end