From fa305f121f5d6d3d4236eba1e8bbc3886e7fd80b Mon Sep 17 00:00:00 2001 From: Amit Gaur Date: Fri, 5 Apr 2024 16:44:53 +1100 Subject: [PATCH] Removes manual establish_connection in interceptor --- lib/gruf/interceptors/active_record/connection_reset.rb | 4 ---- spec/gruf/interceptors/active_record/connection_reset_spec.rb | 4 ---- 2 files changed, 8 deletions(-) diff --git a/lib/gruf/interceptors/active_record/connection_reset.rb b/lib/gruf/interceptors/active_record/connection_reset.rb index d8d7f30..e0565a2 100644 --- a/lib/gruf/interceptors/active_record/connection_reset.rb +++ b/lib/gruf/interceptors/active_record/connection_reset.rb @@ -27,10 +27,6 @@ class ConnectionReset < ::Gruf::Interceptors::ServerInterceptor # connection pool, we need to ensure that this is done to properly # def call - if enabled? - target_classes.each { |klass| klass.establish_connection unless klass.connection.active? } - end - yield ensure target_classes.each(&:clear_active_connections!) if enabled? diff --git a/spec/gruf/interceptors/active_record/connection_reset_spec.rb b/spec/gruf/interceptors/active_record/connection_reset_spec.rb index 51bacfe..e84d8f2 100644 --- a/spec/gruf/interceptors/active_record/connection_reset_spec.rb +++ b/spec/gruf/interceptors/active_record/connection_reset_spec.rb @@ -33,9 +33,7 @@ end it 'tries to clear any active connections' do - expect(animals_record).to receive(:establish_connection).and_call_original expect(animals_record).to receive(:clear_active_connections!).and_call_original - expect(::ActiveRecord::Base).to receive(:establish_connection) expect(::ActiveRecord::Base).to receive(:clear_active_connections!) subject end @@ -47,9 +45,7 @@ end it 'does not try to clear any active connections' do - expect(::ActiveRecord::Base).not_to receive(:establish_connection) expect(::ActiveRecord::Base).not_to receive(:clear_active_connections!) - expect(animals_record).not_to receive(:establish_connection) expect(animals_record).not_to receive(:clear_active_connections!) subject end