Commit fa5043de authored by Igor Drozdov's avatar Igor Drozdov

Stub transaction_open? via allow instead of expect

In Rails 6.1 transaction_open? is called multiple times, so
we should either expect a particular number of calls or just
use allow and stub the return value.

According to the context of this spec, it's sufficient to
use allow in this case
parent 2f3d6c6a
......@@ -100,7 +100,8 @@ RSpec.describe InternalId do
context 'when executed outside of transaction' do
it 'increments counter with in_transaction: "false"' do
expect(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
allow(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment)
.with(operation: :generate, usage: 'issues', in_transaction: 'false').and_call_original
......@@ -158,7 +159,8 @@ RSpec.describe InternalId do
let(:value) { 2 }
it 'increments counter with in_transaction: "false"' do
expect(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
allow(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment)
.with(operation: :reset, usage: 'issues', in_transaction: 'false').and_call_original
......@@ -228,7 +230,8 @@ RSpec.describe InternalId do
context 'when executed outside of transaction' do
it 'increments counter with in_transaction: "false"' do
expect(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
allow(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment)
.with(operation: :track_greatest, usage: 'issues', in_transaction: 'false').and_call_original
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment