diff --git a/lib/acts_as_followable.rb b/lib/acts_as_followable.rb index 474c2b5..c893046 100644 --- a/lib/acts_as_followable.rb +++ b/lib/acts_as_followable.rb @@ -8,7 +8,7 @@ module ActiveRecord #:nodoc: module ClassMethods def acts_as_followable - has_many :follows, :as => :followable, :dependent => :nullify + has_many :follows, :as => :followable, :dependent => :destroy include ActiveRecord::Acts::Followable::InstanceMethods end end diff --git a/test/acts_as_followable_test.rb b/test/acts_as_followable_test.rb index 47dfefc..f742b69 100644 --- a/test/acts_as_followable_test.rb +++ b/test/acts_as_followable_test.rb @@ -24,4 +24,10 @@ class ActsAsFollowableTest < Test::Unit::TestCase assert_equal false, users(:sam).followed_by?(users(:jon)) end + def test_destroyed_followable_should_destroy_related_follows_records + assert_difference "Follow.count && users(:sam).all_following.size", -1 do + users(:jon).destroy + end + end + end diff --git a/test/acts_as_follower_test.rb b/test/acts_as_follower_test.rb index 82c408c..c9a6451 100644 --- a/test/acts_as_follower_test.rb +++ b/test/acts_as_follower_test.rb @@ -75,4 +75,10 @@ class ActsAsFollowerTest < Test::Unit::TestCase assert_raises (NoMethodError){ users(:sam).foobar } end + def test_destroyed_follower_should_nullifys_related_follows_records + assert_difference "Follow.count && users(:sam).following_users.size", -1 do + users(:jon).destroy + end + end + end -- libgit2 0.21.0