Use delete_all to remove impressions on a model
This commit is contained in:
parent
800c24ec64
commit
e94e8cf413
|
@ -15,7 +15,7 @@ module Impressionist
|
||||||
def define_association
|
def define_association
|
||||||
has_many(:impressions,
|
has_many(:impressions,
|
||||||
:as => :impressionable,
|
:as => :impressionable,
|
||||||
:dependent => :destroy)
|
:dependent => :delete_all)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Impressionist
|
||||||
def is_impressionable(options={})
|
def is_impressionable(options={})
|
||||||
many(:impressions,
|
many(:impressions,
|
||||||
:as => :impressionable,
|
:as => :impressionable,
|
||||||
:dependent => :destroy)
|
:dependent => :delete_all)
|
||||||
|
|
||||||
@impressionist_cache_options = options
|
@impressionist_cache_options = options
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,14 +57,14 @@ describe Impression do
|
||||||
@article.impressionist_count(:filter=>:session_hash).should eq 7
|
@article.impressionist_count(:filter=>:session_hash).should eq 7
|
||||||
end
|
end
|
||||||
|
|
||||||
# tests :dependent => :destroy
|
# tests :dependent => :delete_all
|
||||||
it "should delete impressions on deletion of impressionable" do
|
it "should delete impressions on deletion of impressionable" do
|
||||||
#impressions_count = Impression.all.size
|
#impressions_count = Impression.all.size
|
||||||
a = Article.create
|
a = Article.create
|
||||||
i = a.impressions.create
|
i = a.impressions.create
|
||||||
a.destroy
|
a.destroy
|
||||||
a.destroyed?.should be_true
|
a.destroyed?.should be_true
|
||||||
i.destroyed?.should be_true
|
Impression.exists?(i.id).should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue