Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Leased connections return false on second lease

  • Loading branch information...
commit 134cc8f9398a9a67b80f3cc26651dcc5c073416c 1 parent 9bf8bf8
@tenderlove tenderlove authored
View
6 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -73,8 +73,10 @@ def initialize(connection, logger = nil) #:nodoc:
def lease
synchronize do
- @in_use = true
- @last_use = Time.now
+ unless in_use
+ @in_use = true
+ @last_use = Time.now
+ end
end
end
View
13 activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
@@ -3,14 +3,23 @@
module ActiveRecord
module ConnectionAdapters
class AbstractAdapterTest < ActiveRecord::TestCase
- def test_in_use?
- adapter = AbstractAdapter.new nil, nil
+ attr_reader :adapter
+
+ def setup
+ @adapter = AbstractAdapter.new nil, nil
+ end
+ def test_in_use?
# FIXME: change to refute in Rails 4.0 / mt
assert !adapter.in_use?, 'adapter is not in use'
assert adapter.lease, 'lease adapter'
assert adapter.in_use?, 'adapter is in use'
end
+
+ def test_lease_twice
+ assert adapter.lease, 'should lease adapter'
+ assert !adapter.lease, 'should not lease adapter'
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.