spec/mongo/collection_spec.rb in mongo-2.5.1 vs spec/mongo/collection_spec.rb in mongo-2.5.2
- old
+ new
@@ -1111,23 +1111,36 @@
it_behaves_like 'an operation using a session'
it_behaves_like 'a failed operation using a session'
end
- context 'when unacknowledged writes is used' do
+ context 'when unacknowledged writes is used with an explicit session' do
let(:collection_with_unacknowledged_write_concern) do
authorized_collection.with(write: { w: 0 })
end
let(:operation) do
collection_with_unacknowledged_write_concern.insert_many([{ name: 'test1' }, { name: 'test2' }], session: session)
end
- it_behaves_like 'a causally consistent client session with an unacknowledged write'
+ it_behaves_like 'an explicit session with an unacknowledged write'
end
+ context 'when unacknowledged writes is used with an implicit session' do
+
+ let(:collection_with_unacknowledged_write_concern) do
+ subscribed_client.with(write: { w: 0 })[TEST_COLL]
+ end
+
+ let(:operation) do
+ collection_with_unacknowledged_write_concern.insert_many([{ name: 'test1' }, { name: 'test2' }])
+ end
+
+ it_behaves_like 'an implicit session with an unacknowledged write'
+ end
+
context 'when a document contains invalid keys' do
let(:docs) do
[ { 'first.name' => 'test1' }, { name: 'test2' } ]
end
@@ -1343,23 +1356,36 @@
it_behaves_like 'an operation using a session'
it_behaves_like 'a failed operation using a session'
end
- context 'when unacknowledged writes is used' do
+ context 'when unacknowledged writes is used with an explicit session' do
let(:collection_with_unacknowledged_write_concern) do
authorized_collection.with(write: { w: 0 })
end
let(:operation) do
collection_with_unacknowledged_write_concern.insert_one({ name: 'testing' }, session: session)
end
- it_behaves_like 'a causally consistent client session with an unacknowledged write'
+ it_behaves_like 'an explicit session with an unacknowledged write'
end
+ context 'when unacknowledged writes is used with an implicit session' do
+
+ let(:collection_with_unacknowledged_write_concern) do
+ subscribed_client.with(write: { w: 0 })[TEST_COLL]
+ end
+
+ let(:operation) do
+ collection_with_unacknowledged_write_concern.insert_one({ name: 'testing' })
+ end
+
+ it_behaves_like 'an implicit session with an unacknowledged write'
+ end
+
context 'when the document contains invalid keys' do
let(:doc) do
{ 'testing.test' => 'value' }
end
@@ -1991,13 +2017,26 @@
let(:operation) do
collection_with_unacknowledged_write_concern.delete_one({}, session: session)
end
- it_behaves_like 'a causally consistent client session with an unacknowledged write'
+ it_behaves_like 'an explicit session with an unacknowledged write'
end
+ context 'when unacknowledged writes is used with an implicit session' do
+
+ let(:collection_with_unacknowledged_write_concern) do
+ subscribed_client.with(write: { w: 0 })[TEST_COLL]
+ end
+
+ let(:operation) do
+ collection_with_unacknowledged_write_concern.delete_one
+ end
+
+ it_behaves_like 'an implicit session with an unacknowledged write'
+ end
+
context 'when a collation is provided' do
let(:selector) do
{ name: 'BANG' }
end
@@ -2153,23 +2192,36 @@
it_behaves_like 'an operation using a session'
it_behaves_like 'a failed operation using a session'
end
- context 'when unacknowledged writes is used' do
+ context 'when unacknowledged writes is used with an explicit session' do
let(:collection_with_unacknowledged_write_concern) do
authorized_collection.with(write: { w: 0 })
end
let(:operation) do
collection_with_unacknowledged_write_concern.delete_many({ '$._id' => 1}, session: session)
end
- it_behaves_like 'a causally consistent client session with an unacknowledged write'
+ it_behaves_like 'an explicit session with an unacknowledged write'
end
+ context 'when unacknowledged writes is used with an implicit session' do
+
+ let(:collection_with_unacknowledged_write_concern) do
+ subscribed_client.with(write: { w: 0 })[TEST_COLL]
+ end
+
+ let(:operation) do
+ collection_with_unacknowledged_write_concern.delete_many({ '$._id' => 1 })
+ end
+
+ it_behaves_like 'an implicit session with an unacknowledged write'
+ end
+
context 'when a collation is specified' do
let(:selector) do
{ name: 'BANG' }
end
@@ -2712,22 +2764,35 @@
it_behaves_like 'an operation using a session'
it_behaves_like 'a failed operation using a session'
end
- context 'when unacknowledged writes is used' do
+ context 'when unacknowledged writes is used with an explicit session' do
let(:collection_with_unacknowledged_write_concern) do
authorized_collection.with(write: { w: 0 })
end
let(:operation) do
collection_with_unacknowledged_write_concern.replace_one({ a: 1 }, { x: 5 }, session: session)
end
- it_behaves_like 'a causally consistent client session with an unacknowledged write'
+ it_behaves_like 'an explicit session with an unacknowledged write'
end
+
+ context 'when unacknowledged writes is used with an implicit session' do
+
+ let(:collection_with_unacknowledged_write_concern) do
+ subscribed_client.with(write: { w: 0 })[TEST_COLL]
+ end
+
+ let(:operation) do
+ collection_with_unacknowledged_write_concern.replace_one({ a: 1 }, { x: 5 })
+ end
+
+ it_behaves_like 'an implicit session with an unacknowledged write'
+ end
end
describe '#update_many' do
let(:selector) do
@@ -3116,22 +3181,35 @@
it_behaves_like 'an operation using a session'
it_behaves_like 'a failed operation using a session'
end
- context 'when unacknowledged writes is used' do
+ context 'when unacknowledged writes is used with an explicit session' do
let(:collection_with_unacknowledged_write_concern) do
authorized_collection.with(write: { w: 0 })
end
let(:operation) do
collection_with_unacknowledged_write_concern.update_many({a: 1}, { '$set' => {x: 1} }, session: session)
end
- it_behaves_like 'a causally consistent client session with an unacknowledged write'
+ it_behaves_like 'an explicit session with an unacknowledged write'
end
+
+ context 'when unacknowledged writes is used with an implicit session' do
+
+ let(:collection_with_unacknowledged_write_concern) do
+ subscribed_client.with(write: { w: 0 })[TEST_COLL]
+ end
+
+ let(:operation) do
+ collection_with_unacknowledged_write_concern.update_many({a: 1}, {'$set' => {x: 1}})
+ end
+
+ it_behaves_like 'an implicit session with an unacknowledged write'
+ end
end
describe '#update_one' do
let(:selector) do
@@ -3523,20 +3601,33 @@
it_behaves_like 'an operation using a session'
it_behaves_like 'a failed operation using a session'
end
- context 'when unacknowledged writes is used' do
+ context 'when unacknowledged writes is used with an explicit session' do
let(:collection_with_unacknowledged_write_concern) do
authorized_collection.with(write: { w: 0 })
end
let(:operation) do
- collection_with_unacknowledged_write_concern.update_one({a: 1}, { '$set' => {x: 1} }, session: session)
+ collection_with_unacknowledged_write_concern.update_one({ a: 1 }, { '$set' => { x: 1 } }, session: session)
end
- it_behaves_like 'a causally consistent client session with an unacknowledged write'
+ it_behaves_like 'an explicit session with an unacknowledged write'
+ end
+
+ context 'when unacknowledged writes is used with an implicit session' do
+
+ let(:collection_with_unacknowledged_write_concern) do
+ subscribed_client.with(write: { w: 0 })[TEST_COLL]
+ end
+
+ let(:operation) do
+ collection_with_unacknowledged_write_concern.update_one({ a: 1 }, { '$set' => { x: 1 }})
+ end
+
+ it_behaves_like 'an implicit session with an unacknowledged write'
end
end
describe '#find_one_and_delete' do