Commit 07b117ff003d7de05abf45e098b2e9a858a3e613
1 parent
63c14bfa
Exists in
master
and in
1 other branch
Add points to article when receive a comment
Showing
2 changed files
with
14 additions
and
0 deletions
Show diff stats
lib/merit/point_rules.rb
| @@ -19,6 +19,14 @@ module Merit | @@ -19,6 +19,14 @@ module Merit | ||
| 19 | :description => _('Point weight for article author of a comment'), | 19 | :description => _('Point weight for article author of a comment'), |
| 20 | :default_weight => 50 | 20 | :default_weight => 50 |
| 21 | }, | 21 | }, |
| 22 | + :comment_article => { | ||
| 23 | + :action => 'comment#create', | ||
| 24 | + :undo_action => 'comment#destroy', | ||
| 25 | + :to => lambda {|comment| comment.source}, | ||
| 26 | + :value => 1, | ||
| 27 | + :description => _('Point weight for source article of a comment'), | ||
| 28 | + :default_weight => 50 | ||
| 29 | + }, | ||
| 22 | :article_author => { | 30 | :article_author => { |
| 23 | :action => 'article#create', | 31 | :action => 'article#create', |
| 24 | :undo_action => 'article#destroy', | 32 | :undo_action => 'article#destroy', |
test/unit/comment_test.rb
| @@ -100,4 +100,10 @@ class CommentTest < ActiveSupport::TestCase | @@ -100,4 +100,10 @@ class CommentTest < ActiveSupport::TestCase | ||
| 100 | end | 100 | end |
| 101 | end | 101 | end |
| 102 | 102 | ||
| 103 | + should 'add merit points to source article when create a comment' do | ||
| 104 | + assert_difference 'article.points(:category => :comment_article)', 50 do | ||
| 105 | + create(Comment, :source => article, :author_id => person.id) | ||
| 106 | + end | ||
| 107 | + end | ||
| 108 | + | ||
| 103 | end | 109 | end |