added :dependent => :destroy to is_impressionable

This commit is contained in:
mio 2011-12-13 13:51:23 +01:00
parent f396b056f5
commit 7a113edeb2
3 changed files with 12 additions and 9 deletions

View File

@ -11,7 +11,7 @@ module Impressionist
@cache_options = nil
def is_impressionable(options={})
has_many :impressions, :as=>:impressionable
has_many :impressions, :as => :impressionable, :dependent => :destroy
@cache_options = options[:counter_cache]
end

View File

@ -1,12 +1,11 @@
PATH
remote: /Users/coryschires/Desktop/work/applications/impressionist
remote: /home/mio/prog/projects/impressionist
specs:
impressionist (0.4.0)
impressionist (1.0.1)
GEM
remote: http://rubygems.org/
specs:
ZenTest (4.6.2)
actionmailer (3.1.0)
actionpack (= 3.1.0)
mail (~> 2.3.0)
@ -38,8 +37,6 @@ GEM
multi_json (~> 1.0)
addressable (2.2.6)
arel (2.2.1)
autotest (4.4.6)
ZenTest (>= 4.4.1)
autotest-notification (2.3.3)
autotest-standalone (~> 4.5)
autotest-standalone (4.5.8)
@ -158,8 +155,6 @@ PLATFORMS
ruby
DEPENDENCIES
ZenTest
autotest
autotest-notification
capybara
cucumber

View File

@ -49,7 +49,15 @@ describe Impression do
@article.impressionist_count(:filter=>:session_hash).should eq 7
end
# tests :dependent => :destroy
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
end
#OLD COUNT METHODS. DEPRECATE SOON
it "should return the impression count with no date range specified" do