Skip to content

Commit 2075a7b

Browse files
committed
Remove active_record patch
[#46141013] Version 3.2.12 of activerecord contains the changes that the original patch made so the patch is no longer needed.
1 parent f1a4fd9 commit 2075a7b

File tree

3 files changed

+16
-150
lines changed

3 files changed

+16
-150
lines changed

lib/msf/core/db_manager.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ def initialize_database_support
9292

9393
initialize_metasploit_data_models
9494

95-
# Patches issues with ActiveRecord
96-
require "msf/core/patches/active_record"
97-
9895
@usable = true
9996

10097
rescue ::Exception => e

lib/msf/core/patches/active_record.rb

Lines changed: 0 additions & 88 deletions
This file was deleted.

spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb

Lines changed: 16 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
require 'spec_helper'
22

3-
# include patch under test
4-
require 'msf/core/patches/active_record'
53
# helps with environment configuration to use for connection to database
64
require 'metasploit/framework'
75

@@ -33,9 +31,9 @@ def database_configurations_pathname
3331
ActiveRecord::Base.clear_all_connections!
3432
end
3533

36-
context '#active_thread_connection?' do
37-
subject(:active_thread_connection?) do
38-
connection_pool.active_thread_connection?
34+
context '#active_connection?' do
35+
subject(:active_connection?) do
36+
connection_pool.active_connection?
3937
end
4038

4139
# Let! so that Thread is captured before creating and entering new Threads
@@ -47,50 +45,22 @@ def database_configurations_pathname
4745
ActiveRecord::Base.connection_pool.connection
4846
end
4947

50-
context 'with connection id' do
51-
subject(:active_thread_connection?) do
52-
connection_pool.active_thread_connection?(connection_id)
53-
end
54-
55-
context 'with connection id from other thread that has connection' do
56-
let(:connection_id) do
57-
main_thread.object_id
58-
end
59-
60-
it 'should be true' do
61-
thread = Thread.new do
62-
Thread.current.should_not == main_thread
63-
64-
expect(active_thread_connection?).to be_true
65-
end
66-
67-
thread.join
68-
end
69-
end
48+
context 'in thread with connection' do
49+
it { should be_true }
7050
end
7151

72-
context 'without connection id' do
73-
context 'in thread with connection' do
74-
it { should be_true }
75-
end
76-
77-
context 'in thread without connection' do
78-
it 'should be false' do
79-
thread = Thread.new do
80-
Thread.current.should_not == main_thread
81-
expect(active_thread_connection?).to be_false
82-
end
83-
84-
thread.join
52+
context 'in thread without connection' do
53+
it 'should be false' do
54+
thread = Thread.new do
55+
Thread.current.should_not == main_thread
56+
expect(active_connection?).to be_false
8557
end
58+
59+
thread.join
8660
end
8761
end
8862
end
8963

90-
context 'checkout' do
91-
92-
end
93-
9464
context '#with_connection' do
9565
def reserved_connection_count
9666
connection_pool.instance_variable_get(:@reserved_connections).length
@@ -110,19 +80,6 @@ def reserved_connection_count
11080
connection_pool.with_connection { }
11181
end
11282

113-
it 'should call #active_thread_connection? with #current_connection_id' do
114-
current_connection_id = mock('Connection ID')
115-
connection_pool.stub(:current_connection_id => current_connection_id)
116-
117-
connection_pool.should_receive(
118-
:active_thread_connection?
119-
).with(
120-
current_connection_id
121-
).and_call_original
122-
123-
connection_pool.with_connection { }
124-
end
125-
12683
it 'should yield #connection' do
12784
connection = mock('Connection')
12885
connection_pool.stub(:connection => connection)
@@ -141,8 +98,8 @@ def reserved_connection_count
14198
connection_pool.checkin connection
14299
end
143100

144-
it 'should return true from #active_thread_connection?' do
145-
expect(connection_pool.active_thread_connection?).to be_true
101+
it 'should return true from #active_connection?' do
102+
expect(connection_pool.active_connection?).to be_true
146103
end
147104

148105
context 'with error' do
@@ -173,8 +130,8 @@ def reserved_connection_count
173130
end
174131

175132
context 'without active thread connection' do
176-
it 'should return false from #active_thread_connection?' do
177-
expect(connection_pool.active_thread_connection?).to be_false
133+
it 'should return false from #active_connection?' do
134+
expect(connection_pool.active_connection?).to be_false
178135
end
179136

180137
context 'with error' do

0 commit comments

Comments
 (0)