Skip to content

Loading…

issue #8934 sovled #9002

Merged
merged 1 commit into from

2 participants

@dahakawang

runtime exception will be thrown when a anoymous class is provided to establish_connection.
also updated the corresponding test cases.

@tenderlove tenderlove merged commit ea6c9de into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 19, 2013
  1. @dahakawang

    fix anonymous class issue

    dahakawang committed
View
1 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -517,6 +517,7 @@ def connection_pools
def establish_connection(owner, spec)
@class_to_pool.clear
+ raise RuntimeError, "Anonymous class is not allowed." unless owner.name
owner_to_pool[owner.name] = ConnectionAdapters::ConnectionPool.new(spec)
end
View
14 activerecord/test/cases/connection_pool_test.rb
@@ -327,6 +327,20 @@ def test_automatic_reconnect=
def test_pool_sets_connection_visitor
assert @pool.connection.visitor.is_a?(Arel::Visitors::ToSql)
end
+
+
+ #make sure exceptions are thrown when establish_connection
+ #is called with a anonymous class
+ def test_anonymous_class_exception
+ anonymous = Class.new(ActiveRecord::Base)
+ handler = ActiveRecord::Base.connection_handler
+
+ assert_raises(RuntimeError){
+ handler.establish_connection anonymous, nil
+ }
+ end
+
+
end
end
end
Something went wrong with that request. Please try again.