1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fix anonymous class issue

This commit is contained in:
David 2013-01-20 07:17:50 +08:00
parent 760b8d37d4
commit bc43763247
2 changed files with 15 additions and 0 deletions

View file

@ -517,6 +517,7 @@ module ActiveRecord
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 file

@ -327,6 +327,20 @@ module ActiveRecord
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