Commit b1a4a6f2 by Alexey Pokhozhaev

Clear association cache after restore with recursive

parent fe706284
...@@ -143,6 +143,8 @@ module Paranoia ...@@ -143,6 +143,8 @@ module Paranoia
end end
end end
end end
clear_association_cache if destroyed_associations.present?
end end
end end
......
...@@ -537,6 +537,21 @@ class ParanoiaTest < test_framework ...@@ -537,6 +537,21 @@ class ParanoiaTest < test_framework
connect! # Reconnect the main connection connect! # Reconnect the main connection
end end
def test_restore_clear_association_cache_if_associations_present
parent = ParentModel.create
3.times { parent.very_related_models.create }
parent.destroy
assert_equal 0, parent.very_related_models.count
assert_equal 0, parent.very_related_models.size
parent.restore(recursive: true)
assert_equal 3, parent.very_related_models.count
assert_equal 3, parent.very_related_models.size
end
private private
def get_featureful_model def get_featureful_model
FeaturefulModel.new(:name => "not empty") FeaturefulModel.new(:name => "not empty")
......
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