Commit 223c534017d0a79d04210cb518bdeac889bef435
1 parent
07b117ff
Exists in
master
and in
1 other branch
Add points to community when a comment is created
Showing
2 changed files
with
17 additions
and
0 deletions
Show diff stats
lib/merit/point_rules.rb
| ... | ... | @@ -27,6 +27,15 @@ module Merit |
| 27 | 27 | :description => _('Point weight for source article of a comment'), |
| 28 | 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 | 39 | :article_author => { |
| 31 | 40 | :action => 'article#create', |
| 32 | 41 | :undo_action => 'article#destroy', | ... | ... |
test/unit/comment_test.rb
| ... | ... | @@ -106,4 +106,12 @@ class CommentTest < ActiveSupport::TestCase |
| 106 | 106 | end |
| 107 | 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 | 117 | end | ... | ... |