diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/migration_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb index 4fec71d39f..f4d6a2b7ef 100644 --- a/activerecord/test/migration_test.rb +++ b/activerecord/test/migration_test.rb @@ -6,10 +6,22 @@ require File.dirname(__FILE__) + '/fixtures/migrations/2_we_need_reminders' if ActiveRecord::Base.connection.supports_migrations? class Reminder < ActiveRecord::Base; end + class ActiveRecord::Migration + class <<self + attr_accessor :message_count + def puts(text="") + self.message_count ||= 0 + self.message_count += 1 + end + end + end + class MigrationTest < Test::Unit::TestCase self.use_transactional_fixtures = false def setup + ActiveRecord::Migration.verbose = true + PeopleHaveLastNames.message_count = 0 end def teardown @@ -345,6 +357,24 @@ if ActiveRecord::Base.connection.supports_migrations? assert !Reminder.table_exists? end + def test_migrator_verbosity + ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 1) + assert PeopleHaveLastNames.message_count > 0 + PeopleHaveLastNames.message_count = 0 + + ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/', 0) + assert PeopleHaveLastNames.message_count > 0 + PeopleHaveLastNames.message_count = 0 + end + + def test_migrator_verbosity_off + PeopleHaveLastNames.verbose = false + ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 1) + assert PeopleHaveLastNames.message_count.zero? + ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/', 0) + assert PeopleHaveLastNames.message_count.zero? + end + def test_migrator_going_down_due_to_version_target ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 1) ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/fixtures/migrations/', 0) |