forked from QueueClassic/queue_classic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt to backport PR QueueClassic#318 to v3.1.0
- Loading branch information
Showing
7 changed files
with
136 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require File.expand_path("../helper.rb", __FILE__) | ||
require 'active_record' | ||
|
||
class QueueClassicActiverecorgdIntegrationTest < QCTest | ||
def setup | ||
super | ||
reset_globals | ||
ActiveRecord::Base.establish_connection "#{ENV["DATABASE_URL"]}?pool=1" | ||
end | ||
|
||
def teardown | ||
super | ||
end | ||
|
||
def test_connection_not_returned_to_pool | ||
take_connection_until_checked = Mutex.new | ||
conn_adapter_ready = Queue.new | ||
connection_from_adapter = nil | ||
take_connection_until_checked.synchronize do | ||
Thread.new do | ||
with_env 'QC_RAILS_DATABASE' => 'true' do | ||
conn_adapter_ready.push QC.default_conn_adapter.connection | ||
end | ||
take_connection_until_checked.synchronize {} | ||
ActiveRecord::Base.clear_active_connections! | ||
end | ||
|
||
connection_from_adapter = conn_adapter_ready.pop | ||
|
||
ActiveRecord::Base.connection_pool.reap | ||
|
||
# Pool now has no free connections available | ||
assert_raises(ActiveRecord::ConnectionTimeoutError) do | ||
ActiveRecord::Base.connection_pool.checkout 0.1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters