Skip to content

Commit

Permalink
Patch Paranoia#delete to resolve ActiveRecord::ConnectionAdapters::Nu…
Browse files Browse the repository at this point in the history
…llTransaction errors

Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274

Example error:
```
Failure/Error: order.line_items.first.variant.tap(&:delete)
NoMethodError:
       undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18>
```
  • Loading branch information
Matt-Yorkley committed Nov 9, 2020
1 parent 8adb4a8 commit 4970e9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion config/initializers/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def paranoia_delete
if persisted?
# if a transaction exists, add the record so that after_commit
# callbacks can be run
add_to_transaction
add_to_transaction unless self.class.connection.current_transaction.closed?
update_columns(paranoia_destroy_attributes)
elsif !frozen?
assign_attributes(paranoia_destroy_attributes)
Expand Down

0 comments on commit 4970e9b

Please sign in to comment.