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