Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/mongoid/clients/sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def transaction(options = {}, session_options: {})
begin
session.with_transaction(options) do
yield
end
run_commit_callbacks(session)
end.tap { run_commit_callbacks(session) }
rescue *transactions_not_supported_exceptions
raise Mongoid::Errors::TransactionsNotSupported
rescue Mongoid::Errors::Rollback
Expand Down
6 changes: 5 additions & 1 deletion spec/mongoid/clients/transactions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def capture_exception
require_transaction_support

context 'when no error raised' do
before do
let!(:person) do
Mongoid.transaction do
Person.create!
end
Expand All @@ -727,6 +727,10 @@ def capture_exception
expect(other_events.count { |e| e.command_name == 'commitTransaction'}).to be(1)
end

it 'returns the value from the block' do
expect(person).to be_a(Person)
end

it 'executes the commands inside the transaction' do
expect(Person.count).to be(1)
end
Expand Down