Skip to content
Browse files

fix anonymous class issue

  • Loading branch information...
1 parent 760b8d3 commit bc43763247e25058ca1ab50637a649f0b5b186eb @dahakawang dahakawang committed Jan 20, 2013
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

0 comments on commit bc43763

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