aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-16 10:14:09 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-16 10:14:09 -0800
commit5b833f53f61d65927ec60be8b165679d80b02da5 (patch)
tree45b1a7709f7f7b6a2e8f47d2fb4ccbbaecd98523 /activerecord/test/cases/migration_test.rb
parent06918661048395835588e659034577fed35c5594 (diff)
downloadrails-5b833f53f61d65927ec60be8b165679d80b02da5.tar.gz
rails-5b833f53f61d65927ec60be8b165679d80b02da5.tar.bz2
rails-5b833f53f61d65927ec60be8b165679d80b02da5.zip
test that migrations have connections, and method missing delegates
Diffstat (limited to 'activerecord/test/cases/migration_test.rb')
-rw-r--r--activerecord/test/cases/migration_test.rb23
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