Commit 048f746d6b8a2d61821bf8c710be04d13382d273
1 parent
a1febfd2
Exists in
master
and in
1 other branch
Add test for avoiding infinite loop scoring a profile action
Showing
1 changed file
with
12 additions
and
0 deletions
Show diff stats
test/unit/profile_test.rb
| @@ -44,6 +44,18 @@ class ProfileTest < ActiveSupport::TestCase | @@ -44,6 +44,18 @@ class ProfileTest < ActiveSupport::TestCase | ||
| 44 | assert_equal 1, profile.gamification_plugin_calculate_level | 44 | assert_equal 1, profile.gamification_plugin_calculate_level |
| 45 | end | 45 | end |
| 46 | 46 | ||
| 47 | + should 'update profile level when a profile action makes a score with zero point' do | ||
| 48 | + #avoid loop when the score changes by zero and | ||
| 49 | + person = create_user('testuser').person | ||
| 50 | + Person.any_instance.stubs(:is_profile_complete?).returns(true) | ||
| 51 | + create_point_rule_definition('profile_completion', nil, {value: 0}) | ||
| 52 | + GamificationPlugin.gamification_set_rules(environment) | ||
| 53 | + assert_equal 0, person.level | ||
| 54 | + assert_nothing_raised do | ||
| 55 | + person.save | ||
| 56 | + end | ||
| 57 | + end | ||
| 58 | + | ||
| 47 | should 'update profile level when the score changes' do | 59 | should 'update profile level when the score changes' do |
| 48 | create_point_rule_definition('article_author') | 60 | create_point_rule_definition('article_author') |
| 49 | community = fast_create(Community) | 61 | community = fast_create(Community) |