@@ -9,6 +9,14 @@ class Comment < ActiveRecord::Base; end
9
9
end
10
10
11
11
let ( :direction ) { :up }
12
+ let ( :pool ) { ActiveRecord ::Base . connection_pool }
13
+ let ( :spec_config ) do
14
+ if ActiveRecord ::VERSION ::STRING >= '6.1'
15
+ pool . connection . instance_variable_get ( :@config )
16
+ else
17
+ pool . spec . config
18
+ end
19
+ end
12
20
13
21
it 'has a version number' do
14
22
expect ( Departure ::VERSION ) . not_to be nil
@@ -51,8 +59,7 @@ class Comment < ActiveRecord::Base; end
51
59
52
60
it 'reconnects to the database using PerconaAdapter' do
53
61
ActiveRecord ::Migrator . new ( direction , migration_fixtures , ActiveRecord ::SchemaMigration , 1 ) . migrate
54
- expect ( ActiveRecord ::Base . connection_pool . spec . config [ :adapter ] )
55
- . to eq ( 'percona' )
62
+ expect ( spec_config [ :adapter ] ) . to eq ( 'percona' )
56
63
end
57
64
58
65
context 'when a username is provided' do
@@ -68,8 +75,7 @@ class Comment < ActiveRecord::Base; end
68
75
69
76
it 'uses the provided username' do
70
77
ActiveRecord ::Migrator . new ( direction , migration_fixtures , ActiveRecord ::SchemaMigration , 1 ) . migrate
71
- expect ( ActiveRecord ::Base . connection_pool . spec . config [ :username ] )
72
- . to eq ( 'root' )
78
+ expect ( spec_config [ :username ] ) . to eq ( 'root' )
73
79
end
74
80
end
75
81
@@ -85,8 +91,7 @@ class Comment < ActiveRecord::Base; end
85
91
86
92
it 'uses root' do
87
93
ActiveRecord ::Migrator . new ( direction , migration_fixtures , ActiveRecord ::SchemaMigration , 1 ) . migrate
88
- expect ( ActiveRecord ::Base . connection_pool . spec . config [ :username ] )
89
- . to eq ( 'root' )
94
+ expect ( spec_config [ :username ] ) . to eq ( 'root' )
90
95
end
91
96
end
92
97
0 commit comments