Skip to content

Commit

Permalink
Add failing test for odd transaction poisoning
Browse files Browse the repository at this point in the history
  • Loading branch information
tjefferson08 authored May 14, 2024
1 parent 5aa9cfd commit 5edd83d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/flipper/adapters/active_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@

it_should_behave_like 'a flipper adapter'

it "should not poision wrapping transactions" do
flipper = Flipper.new(subject)

actor = Struct.new(:flipper_id).new("flipper-id-123")
flipper.enable_actor(:foo, actor)

ActiveRecord::Base.transaction do
flipper.enable_actor(:foo, actor)

# we get here just fine!
puts "got here!"
expect(true).to be true

# whoa it's not until the next read that the transaction blows up
# with StatementInvalid
expect(Flipper::Adapters::ActiveRecord::Gate.count).to eq 1
puts "never got here!"
expect(true).to be false
end
end

it "should load actor ids fine" do
flipper.enable_percentage_of_time(:foo, 1)

Expand Down

0 comments on commit 5edd83d

Please sign in to comment.