Skip to content
Browse files

make tests work better

  • Loading branch information...
1 parent 1ff9975 commit 344ce71001c0f297cdeb68a87aba81456a8a05ec @joshsusser committed Nov 28, 2012
View
4 activerecord/test/cases/migration/logger_test.rb
@@ -6,7 +6,7 @@ class LoggerTest < ActiveRecord::TestCase
# mysql can't roll back ddl changes
self.use_transactional_fixtures = false
- Migration = Struct.new(:name, :version) do
+ Migration = Struct.new(:name, :version, :filename) do
def migrate direction
# do nothing
end
@@ -26,7 +26,7 @@ def teardown
def test_migration_should_be_run_without_logger
previous_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
- migrations = [Migration.new('a', 1), Migration.new('b', 2), Migration.new('c', 3)]
+ migrations = [Migration.new('a', 1, 'anon.rb'), Migration.new('b', 2, 'anon.rb'), Migration.new('c', 3, 'anon.rb')]
ActiveRecord::Migrator.new(:up, migrations).migrate
ensure
ActiveRecord::Base.logger = previous_logger
View
2 activerecord/test/cases/migration_test.rb
@@ -67,7 +67,7 @@ def test_migrator_versions
rows = connection.select_all("SELECT * FROM #{connection.quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)}")
assert_equal "valid_people_have_last_names", rows[0]["name"]
rows.each do |row|
- assert_match /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, row["migrated_at"], "missing migrated_at"
+ assert_match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, row["migrated_at"], "missing migrated_at")
end
ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid")
View
7 activerecord/test/cases/migrator_test.rb
@@ -18,6 +18,7 @@ def initialize name = self.class.name, version = nil
def up; @went_up = true; end
def down; @went_down = true; end
+ def filename; "anon.rb"; end # also used in place of a MigrationProxy
end
def setup
@@ -102,7 +103,7 @@ def test_relative_migrations
end
def test_finds_pending_migrations
- ActiveRecord::SchemaMigration.create!(:version => '1')
+ ActiveRecord::SchemaMigration.create!(:version => '1', :name => "anon", :migrated_at => Time.now)
migration_list = [ Migration.new('foo', 1), Migration.new('bar', 3) ]
migrations = ActiveRecord::Migrator.new(:up, migration_list).pending_migrations
@@ -152,7 +153,7 @@ def test_down_calls_down
end
def test_current_version
- ActiveRecord::SchemaMigration.create!(:version => '1000')
+ ActiveRecord::SchemaMigration.create!(:version => '1000', :name => "anon", :migrated_at => Time.now)
assert_equal 1000, ActiveRecord::Migrator.current_version
end
@@ -320,7 +321,7 @@ def test_migrator_forward
def test_only_loads_pending_migrations
# migrate up to 1
- ActiveRecord::SchemaMigration.create!(:version => '1')
+ ActiveRecord::SchemaMigration.create!(:version => '1', :name => "anon", :migrated_at => Time.now)
calls, migrator = migrator_class(3)
migrator.migrate("valid", nil)
View
2 activerecord/test/cases/schema_dumper_test.rb
@@ -18,7 +18,7 @@ def standard_dump
def test_dump_schema_information_outputs_lexically_ordered_versions
versions = %w{ 20100101010101 20100201010101 20100301010101 }
versions.reverse.each do |v|
- ActiveRecord::SchemaMigration.create!(:version => v)
+ ActiveRecord::SchemaMigration.create!(:version => v, :name => "anon", :migrated_at => Time.now)
end
schema_info = ActiveRecord::Base.connection.dump_schema_information
View
2 activerecord/test/cases/schema_migration_test.rb
@@ -41,7 +41,7 @@ def test_add_name_and_migrated_at_to_exisiting_schema_migrations
rows = connection.select_all("SELECT * FROM #{connection.quote_table_name(sm_table_name)}")
assert rows[0].has_key?("name"), "missing column `name`"
assert rows[0].has_key?("migrated_at"), "missing column `migrated_at`"
- assert_match /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, rows[0]["migrated_at"]
+ assert_match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, rows[0]["migrated_at"])
end
def test_schema_migrations_columns

0 comments on commit 344ce71

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