Commit d2dc1474dcbb2c18a2456c35cd0912c7f67eabf9
1 parent
772c27b5
Exists in
master
and in
28 other branches
Change vote plugin to remove votes when a voteable is removed
Showing
3 changed files
with
14 additions
and
1 deletions
Show diff stats
test/unit/article_test.rb
... | ... | @@ -1751,4 +1751,10 @@ class ArticleTest < ActiveSupport::TestCase |
1751 | 1751 | assert_equal 5, article.votes_total |
1752 | 1752 | end |
1753 | 1753 | |
1754 | + should 'be able to remove a voted article' do | |
1755 | + article = Article.create!(:name => 'Test', :profile => profile, :last_changed_by => nil) | |
1756 | + profile.vote(article, 5) | |
1757 | + article.destroy | |
1758 | + end | |
1759 | + | |
1754 | 1760 | end | ... | ... |
test/unit/comment_test.rb
... | ... | @@ -724,6 +724,13 @@ class CommentTest < ActiveSupport::TestCase |
724 | 724 | assert_equal 2, comment.votes_against |
725 | 725 | end |
726 | 726 | |
727 | + should 'be able to remove a voted comment' do | |
728 | + comment = create_comment | |
729 | + person = create_user('voter').person | |
730 | + person.vote(comment, 5) | |
731 | + comment.destroy | |
732 | + end | |
733 | + | |
727 | 734 | private |
728 | 735 | |
729 | 736 | def create_comment(args = {}) | ... | ... |
vendor/plugins/vote_fu/lib/acts_as_voteable.rb
... | ... | @@ -16,7 +16,7 @@ module Juixe |
16 | 16 | # Note: Specifying a counter will add it to that model‘s list of readonly attributes using attr_readonly. |
17 | 17 | # |
18 | 18 | def acts_as_voteable options={} |
19 | - has_many :votes, :as => :voteable, :dependent => :nullify | |
19 | + has_many :votes, :as => :voteable, :dependent => :destroy | |
20 | 20 | include Juixe::Acts::Voteable::InstanceMethods |
21 | 21 | extend Juixe::Acts::Voteable::SingletonMethods |
22 | 22 | if (options[:vote_counter]) | ... | ... |