diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-16 10:14:09 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-16 10:14:09 -0800 |
commit | 5b833f53f61d65927ec60be8b165679d80b02da5 (patch) | |
tree | 45b1a7709f7f7b6a2e8f47d2fb4ccbbaecd98523 /activerecord | |
parent | 06918661048395835588e659034577fed35c5594 (diff) | |
download | rails-5b833f53f61d65927ec60be8b165679d80b02da5.tar.gz rails-5b833f53f61d65927ec60be8b165679d80b02da5.tar.bz2 rails-5b833f53f61d65927ec60be8b165679d80b02da5.zip |
test that migrations have connections, and method missing delegates
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 2343e5610b..426eaebc8a 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -91,16 +91,25 @@ class MigrationTest < ActiveRecord::TestCase Person.connection.drop_table :testings2 rescue nil end - def test_add_table - assert !Reminder.table_exists? + def connection + ActiveRecord::Base.connection + end - WeNeedReminders.up + def test_migration_instance_has_connection + migration = Class.new(ActiveRecord::Migration).new + assert_equal connection, migration.connection + end - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content + def test_method_missing_delegates_to_connection + migration = Class.new(ActiveRecord::Migration) { + def connection + Class.new { + def create_table; "hi mom!"; end + }.new + end + }.new - WeNeedReminders.down - assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } + assert_equal "hi mom!", migration.method_missing(:create_table) end def test_add_table_with_decimals |