diff options
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 9 | ||||
-rwxr-xr-x | activerecord/test/cases/validations_test.rb | 18 |
2 files changed, 17 insertions, 10 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 885d89b6da..c270230d67 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -813,6 +813,13 @@ if ActiveRecord::Base.connection.supports_migrations? end end + def test_migrator_db_has_no_schema_migrations_table + ActiveRecord::Base.connection.execute("DROP TABLE schema_migrations;") + assert_nothing_raised do + ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 1) + end + end + def test_migrator_verbosity ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) assert PeopleHaveLastNames.message_count > 0 @@ -1010,7 +1017,7 @@ if ActiveRecord::Base.connection.supports_migrations? end end - + uses_mocha 'Sexy migration tests' do class SexyMigrationsTest < ActiveRecord::TestCase def test_references_column_type_adds_id diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 97ac22eaf3..ca36ad3581 100755 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -58,9 +58,9 @@ class ValidationsTest < ActiveRecord::TestCase fixtures :topics, :developers, 'warehouse-things' def setup - Topic.write_inheritable_attribute(:validate, nil) - Topic.write_inheritable_attribute(:validate_on_create, nil) - Topic.write_inheritable_attribute(:validate_on_update, nil) + Topic.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new) + Topic.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new) + Topic.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new) end def test_single_field_validation @@ -839,16 +839,16 @@ class ValidationsTest < ActiveRecord::TestCase reply = t.replies.build('title' => 'areply', 'content' => 'whateveragain') assert t.valid? end - + def test_validates_size_of_association_using_within assert_nothing_raised { Topic.validates_size_of :replies, :within => 1..2 } t = Topic.new('title' => 'noreplies', 'content' => 'whatever') assert !t.save assert t.errors.on(:replies) - + reply = t.replies.build('title' => 'areply', 'content' => 'whateveragain') assert t.valid? - + 2.times { t.replies.build('title' => 'areply', 'content' => 'whateveragain') } assert !t.save assert t.errors.on(:replies) @@ -1351,9 +1351,9 @@ class ValidatesNumericalityTest < ActiveRecord::TestCase JUNK = ["not a number", "42 not a number", "0xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"] def setup - Topic.write_inheritable_attribute(:validate, nil) - Topic.write_inheritable_attribute(:validate_on_create, nil) - Topic.write_inheritable_attribute(:validate_on_update, nil) + Topic.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new) + Topic.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new) + Topic.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new) end def test_default_validates_numericality_of |