File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -210,7 +210,9 @@ def get(object)
210
210
# context that was set before this context was used.
211
211
def clear ( object , cluster = nil , original_context = nil )
212
212
if context = get ( object )
213
- context . client . close unless ( context . cluster . equal? ( cluster ) || cluster . nil? )
213
+ unless cluster . nil? || context . cluster . equal? ( cluster )
214
+ context . client . close
215
+ end
214
216
end
215
217
ensure
216
218
Thread . current [ "[mongoid][#{ object . object_id } ]:context" ] = original_context
Original file line number Diff line number Diff line change 82
82
83
83
let! ( :connections_and_cluster_during ) do
84
84
connections = nil
85
- cluster = Minim . with ( options ) do |klass |
85
+ cluster = nil
86
+ Minim . with ( options ) do |klass |
86
87
klass . where ( name : 'emily' ) . to_a
87
88
connections = Minim . mongo_client . database . command ( serverStatus : 1 ) . first [ 'connections' ] [ 'current' ]
89
+ cluster = Minim . collection . cluster
88
90
end
89
91
[ connections , cluster ]
90
92
end
123
125
end
124
126
125
127
it 'disconnects the new cluster when the block exits' do
126
- skip 'https://jira.mongodb.org/browse/MONGOID-5130'
128
+ expect ( cluster_after ) . not_to be ( cluster_during )
127
129
128
- expect ( connections_before ) . to eq ( connections_after )
130
+ cluster_during . connected? . should be false
131
+ cluster_before . connected? . should be true
129
132
end
130
133
end
131
134
139
142
140
143
it 'does not create a new cluster' do
141
144
expect ( connections_during ) . to eq ( connections_before )
145
+
146
+ cluster_during . should be cluster_before
142
147
end
143
148
144
149
it 'does not disconnect the original cluster' do
145
- skip 'https://jira.mongodb.org/browse/MONGOID-5130'
146
-
147
- expect ( connections_after ) . to eq ( connections_before )
148
150
expect ( cluster_before ) . to be ( cluster_after )
151
+
152
+ cluster_before . connected? . should be true
149
153
end
150
154
end
151
155
You can’t perform that action at this time.
0 commit comments