Commit 418172afad4ed8d004f7babd74d9a8bf719c0d76
1 parent
4503f6c5
Exists in
master
and in
1 other branch
Add points for new friends added
Showing
2 changed files
with
14 additions
and
0 deletions
Show diff stats
lib/merit/point_rules.rb
| ... | ... | @@ -79,6 +79,14 @@ module Merit |
| 79 | 79 | :description => _('Voter'), |
| 80 | 80 | :default_weight => 10 |
| 81 | 81 | }, |
| 82 | + :friends => { | |
| 83 | + :action => 'friendship#create', | |
| 84 | + :undo_action => 'friendship#destroy', | |
| 85 | + :to => lambda {|friendship| friendship.person}, | |
| 86 | + :value => 1, | |
| 87 | + :description => _('Friends'), | |
| 88 | + :default_weight => 5 | |
| 89 | + }, | |
| 82 | 90 | } |
| 83 | 91 | |
| 84 | 92 | def weight(category) | ... | ... |
test/unit/person_test.rb
| ... | ... | @@ -27,4 +27,10 @@ class PersonTest < ActiveSupport::TestCase |
| 27 | 27 | assert_equal 'friendly', person.reload.badges.first.name |
| 28 | 28 | end |
| 29 | 29 | |
| 30 | + should 'add points when add someone as a friendly' do | |
| 31 | + other_person = create_user("testuserfriend").person | |
| 32 | + person.add_friend(other_person) | |
| 33 | + assert_equal 5, person.score_points(:category => :friends).sum(:num_points) | |
| 34 | + end | |
| 35 | + | |
| 30 | 36 | end | ... | ... |