diff --git a/lib/merit/point_rules.rb b/lib/merit/point_rules.rb index 5bb4221..c69975a 100644 --- a/lib/merit/point_rules.rb +++ b/lib/merit/point_rules.rb @@ -27,6 +27,15 @@ module Merit :description => _('Point weight for source article of a comment'), :default_weight => 50 }, + :comment_community => { + :action => 'comment#create', + :undo_action => 'comment#destroy', + :to => lambda {|comment| comment.profile}, + :value => 1, + :description => _('Point weight for article community of a comment'), + :default_weight => 50, + :condition => lambda {|target| target.profile.community? } + }, :article_author => { :action => 'article#create', :undo_action => 'article#destroy', diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index c9e553d..a9f0895 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -106,4 +106,12 @@ class CommentTest < ActiveSupport::TestCase end end + should 'add merit points to source community when create a comment' do + community = fast_create(Community) + article = create(TextileArticle, :profile_id => community.id, :author_id => @author.id) + assert_difference 'community.points(:category => :comment_community)', 50 do + create(Comment, :source => article, :author_id => person.id) + end + end + end -- libgit2 0.21.2