Commit 223c534017d0a79d04210cb518bdeac889bef435

Authored by Victor Costa
1 parent 07b117ff

Add points to community when a comment is created

lib/merit/point_rules.rb
@@ -27,6 +27,15 @@ module Merit @@ -27,6 +27,15 @@ module Merit
27 :description => _('Point weight for source article of a comment'), 27 :description => _('Point weight for source article of a comment'),
28 :default_weight => 50 28 :default_weight => 50
29 }, 29 },
  30 + :comment_community => {
  31 + :action => 'comment#create',
  32 + :undo_action => 'comment#destroy',
  33 + :to => lambda {|comment| comment.profile},
  34 + :value => 1,
  35 + :description => _('Point weight for article community of a comment'),
  36 + :default_weight => 50,
  37 + :condition => lambda {|target| target.profile.community? }
  38 + },
30 :article_author => { 39 :article_author => {
31 :action => 'article#create', 40 :action => 'article#create',
32 :undo_action => 'article#destroy', 41 :undo_action => 'article#destroy',
test/unit/comment_test.rb
@@ -106,4 +106,12 @@ class CommentTest < ActiveSupport::TestCase @@ -106,4 +106,12 @@ class CommentTest < ActiveSupport::TestCase
106 end 106 end
107 end 107 end
108 108
  109 + should 'add merit points to source community when create a comment' do
  110 + community = fast_create(Community)
  111 + article = create(TextileArticle, :profile_id => community.id, :author_id => @author.id)
  112 + assert_difference 'community.points(:category => :comment_community)', 50 do
  113 + create(Comment, :source => article, :author_id => person.id)
  114 + end
  115 + end
  116 +
109 end 117 end