Commit 2e1af6c93a27dbfd5c7f40e5f5d1acbe8ad5439a
1 parent
c12f8abd
Exists in
master
and in
1 other branch
Add action reference to point
Showing
5 changed files
with
27 additions
and
0 deletions
Show diff stats
lib/gamification_plugin.rb
... | ... | @@ -58,6 +58,7 @@ class GamificationPlugin < Noosfero::Plugin |
58 | 58 | config.checks_on_each_request = false |
59 | 59 | config.user_model_name = 'Profile' |
60 | 60 | config.current_user_method = 'current_person' |
61 | + config.add_observer 'Merit::PointTrackObserver' | |
61 | 62 | config.add_observer 'Merit::RankObserver' |
62 | 63 | end |
63 | 64 | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +module Merit | |
2 | + | |
3 | + class PointTrackObserver | |
4 | + def update(changed_data) | |
5 | + merit = changed_data[:merit_object] | |
6 | + if merit.kind_of?(Merit::Score::Point) | |
7 | + merit.update_attribute(:action_id, changed_data[:merit_action_id]) | |
8 | + end | |
9 | + end | |
10 | + end | |
11 | + | |
12 | +end | ... | ... |
lib/merit_ext.rb
test/unit/article_test.rb
... | ... | @@ -13,6 +13,7 @@ class ArticleTest < ActiveSupport::TestCase |
13 | 13 | should 'add merit points to author when create a new article' do |
14 | 14 | create(TextArticle, :profile_id => person.id, :author => person) |
15 | 15 | assert_equal 1, person.score_points.count |
16 | + assert person.score_points.first.action.present? | |
16 | 17 | end |
17 | 18 | |
18 | 19 | should 'subtract merit points to author when destroy an article' do | ... | ... |