Commit 2ec3031c by Kurtis Rainbolt-Greene

Merge pull request #291 from rainforestapp/fix_null_transaction

Don't try to add to null transactions
parents 9e0ec38e f04b13ac
...@@ -93,7 +93,7 @@ module Paranoia ...@@ -93,7 +93,7 @@ module Paranoia
if persisted? if persisted?
# if a transaction exists, add the record so that after_commit # if a transaction exists, add the record so that after_commit
# callbacks can be run # callbacks can be run
add_to_transaction add_to_transaction unless self.class.connection.current_transaction.closed?
update_columns(paranoia_destroy_attributes) update_columns(paranoia_destroy_attributes)
elsif !frozen? elsif !frozen?
assign_attributes(paranoia_destroy_attributes) assign_attributes(paranoia_destroy_attributes)
......
...@@ -96,6 +96,14 @@ class ParanoiaTest < test_framework ...@@ -96,6 +96,14 @@ class ParanoiaTest < test_framework
assert_equal to_param, model.to_param assert_equal to_param, model.to_param
end end
def test_paranoid_model_delete_outside_transaction
model = ParanoidModel.new
model.save!
model.delete
assert model.to_param
end
def test_destroy_behavior_for_plain_models def test_destroy_behavior_for_plain_models
model = PlainModel.new model = PlainModel.new
assert_equal 0, model.class.count assert_equal 0, model.class.count
......
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