From c6f32d14694bfc9cbae302a356fda54ae68b1da6 Mon Sep 17 00:00:00 2001 From: Artur Antonnikau Date: Thu, 21 Mar 2024 15:41:36 +0300 Subject: [PATCH] Add Rspecs --- spec/mongoid/paranoia_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/mongoid/paranoia_spec.rb b/spec/mongoid/paranoia_spec.rb index 67fa2f4..c83499b 100644 --- a/spec/mongoid/paranoia_spec.rb +++ b/spec/mongoid/paranoia_spec.rb @@ -318,6 +318,27 @@ class ParanoidConfiguredReset expect(post).not_to be_destroyed end end + + context "when multiple operations wrapped inside transaction" do + + let(:post) do + ParanoidPost.create(title: "test") + end + + before do + post.with_session do |session| + session.with_transaction(write_concern: {w: :majority}) do + post.set(title: "test_new") + post.destroy + end + end + end + + it "should perform operations correct and commit result" do + expect(post.title).to eq("test_new") + expect(post).to be_destroyed + end + end end describe "#destroyed?" do