Commit 418172afad4ed8d004f7babd74d9a8bf719c0d76

Authored by Victor Costa
1 parent 4503f6c5

Add points for new friends added

lib/merit/point_rules.rb
@@ -79,6 +79,14 @@ module Merit @@ -79,6 +79,14 @@ module Merit
79 :description => _('Voter'), 79 :description => _('Voter'),
80 :default_weight => 10 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 def weight(category) 92 def weight(category)
test/unit/person_test.rb
@@ -27,4 +27,10 @@ class PersonTest < ActiveSupport::TestCase @@ -27,4 +27,10 @@ class PersonTest < ActiveSupport::TestCase
27 assert_equal 'friendly', person.reload.badges.first.name 27 assert_equal 'friendly', person.reload.badges.first.name
28 end 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 end 36 end