diff --git a/lib/impressionist/is_impressionable.rb b/lib/impressionist/is_impressionable.rb index 9fdf550..9a4205a 100644 --- a/lib/impressionist/is_impressionable.rb +++ b/lib/impressionist/is_impressionable.rb @@ -15,9 +15,9 @@ module Impressionist def define_association has_many(:impressions, :as => :impressionable, - :dependent => :destroy) + :dependent => :delete_all) end end - + end end diff --git a/lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb b/lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb index 1b2ca58..cc1c403 100644 --- a/lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb +++ b/lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb @@ -9,7 +9,7 @@ module Impressionist def is_impressionable(options={}) many(:impressions, :as => :impressionable, - :dependent => :destroy) + :dependent => :delete_all) @impressionist_cache_options = options end diff --git a/tests/test_app/spec/models/model_spec.rb b/tests/test_app/spec/models/model_spec.rb index 2ed4156..f666edd 100644 --- a/tests/test_app/spec/models/model_spec.rb +++ b/tests/test_app/spec/models/model_spec.rb @@ -57,14 +57,14 @@ describe Impression do @article.impressionist_count(:filter=>:session_hash).should eq 7 end - # tests :dependent => :destroy + # tests :dependent => :delete_all it "should delete impressions on deletion of impressionable" do #impressions_count = Impression.all.size a = Article.create i = a.impressions.create a.destroy a.destroyed?.should be_true - i.destroyed?.should be_true + Impression.exists?(i.id).should be_false end end