File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ def paranoid_field
190
190
# @return [ Object ] Update result.
191
191
#
192
192
def _paranoia_update ( value )
193
- paranoid_collection . find ( atomic_selector ) . update_one ( value )
193
+ paranoid_collection . find ( atomic_selector ) . update_one ( value , session : _session )
194
194
end
195
195
end
196
196
end
Original file line number Diff line number Diff line change @@ -318,6 +318,27 @@ class ParanoidConfiguredReset
318
318
expect ( post ) . not_to be_destroyed
319
319
end
320
320
end
321
+
322
+ context "when multiple operations wrapped inside transaction" do
323
+
324
+ let ( :post ) do
325
+ ParanoidPost . create ( title : "test" )
326
+ end
327
+
328
+ before do
329
+ post . with_session do |session |
330
+ session . with_transaction ( write_concern : { w : :majority } ) do
331
+ post . set ( title : "test_new" )
332
+ post . destroy
333
+ end
334
+ end
335
+ end
336
+
337
+ it "should perform operations correct and commit result" do
338
+ expect ( post . title ) . to eq ( "test_new" )
339
+ expect ( post ) . to be_destroyed
340
+ end
341
+ end
321
342
end
322
343
323
344
describe "#destroyed?" do
You can’t perform that action at this time.
0 commit comments