Permalink
Browse files

Merge pull request #9002 from dahakawang/master

issue #8934 sovled
  • Loading branch information...
2 parents 760b8d3 + bc43763 commit ea6c9de1d31fb19bfdd19ab578ac943f49aa6d50 @tenderlove tenderlove committed Jan 20, 2013
@@ -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 ea6c9de

Please sign in to comment.