File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33module Multidb
44 class Candidate
5- USE_RAILS_61 = Gem ::Version . new ( ::ActiveRecord ::VERSION ::STRING ) >= Gem ::Version . new ( '6.1' )
6- SPEC_NAME = if USE_RAILS_61
7- 'ActiveRecord::Base'
8- else
9- 'primary'
10- end
5+ SPEC_NAME = 'ActiveRecord::Base'
116
127 def initialize ( name , target )
138 @name = name
149
1510 case target
1611 when Hash
17- target = target . merge ( name : 'primary' ) unless USE_RAILS_61
12+ target = target . merge ( name : 'primary' )
1813
1914 @connection_handler = ActiveRecord ::ConnectionAdapters ::ConnectionHandler . new
2015 @connection_handler . establish_connection ( target )
Original file line number Diff line number Diff line change 1717 handler = subject . instance_variable_get ( :@connection_handler )
1818 expect ( handler ) . to an_instance_of ( ActiveRecord ::ConnectionAdapters ::ConnectionHandler )
1919 end
20-
21- it 'merges the name: primary into the hash' , rails : '< 6.1' do
22- handler = instance_double ( 'ActiveRecord::ConnectionAdapters::ConnectionHandler' )
23- allow ( ActiveRecord ::ConnectionAdapters ::ConnectionHandler ) . to receive ( :new ) . and_return ( handler )
24- allow ( handler ) . to receive ( :establish_connection )
25-
26- subject
27-
28- expect ( handler ) . to have_received ( :establish_connection ) . with ( hash_including ( name : 'primary' ) )
29- end
3020 end
3121
3222 context 'when target is a connection handler' do
You can’t perform that action at this time.
0 commit comments