Permalink
Browse files

fix anonymous class issue

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