spec/mongoid/clients_spec.rb in mongoid-8.1.7 vs spec/mongoid/clients_spec.rb in mongoid-9.0.0
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+# rubocop:todo all
require "spec_helper"
describe Mongoid::Clients do
@@ -1161,19 +1162,19 @@
let(:second_band) do
Band.create!(name: 'Led Zeppelin')
end
- it 'does not create extra symbols symbols' do
+ it 'does not create extra symbols' do
first_band.with(write: { w: 0, j: false }) do |band|
band.set(active: false)
end
initial_symbols_count = Symbol.all_symbols.size
second_band.with(write: { w: 0, j: false }) do |band|
band.set(active: false)
end
- expect(Symbol.all_symbols.size).to eq(initial_symbols_count)
+ expect(Symbol.all_symbols.size).to be <= initial_symbols_count
end
end
end
@@ -1211,8 +1212,52 @@
end
it 'uses that database for the model mongo_client' do
expect(Band.mongo_client.database.name).to eq('mongoid_optional')
end
+ end
+ end
+
+ context "#disconnect" do
+
+ let(:clients) do
+ Mongoid::Clients.clients.values
+ end
+
+ before do
+ Band.all.entries
+ end
+
+ it "disconnects from all active clients" do
+ clients.each do |client|
+ expect(client).to receive(:close).and_call_original
+ end
+ Mongoid::Clients.disconnect
+ end
+
+ it "returns true" do
+ expect(Mongoid::Clients.disconnect).to eq(true)
+ end
+ end
+
+ context "#reconnect" do
+
+ let(:clients) do
+ Mongoid::Clients.clients.values
+ end
+
+ before do
+ Band.all.entries
+ end
+
+ it "reconnects all active clients" do
+ clients.each do |client|
+ expect(client).to receive(:reconnect).and_call_original
+ end
+ Mongoid::Clients.reconnect
+ end
+
+ it "returns true" do
+ expect(Mongoid::Clients.reconnect).to eq(true)
end
end
end