Commit 03304903d832200eb7fd19e1d447ce33cbe79061
1 parent
11902ec2
Exists in
master
Fix dashboard
Showing
4 changed files
with
8 additions
and
7 deletions
Show diff stats
lib/gamification_plugin/dashboard_helper.rb
| ... | ... | @@ -12,8 +12,8 @@ module GamificationPlugin::DashboardHelper |
| 12 | 12 | end |
| 13 | 13 | |
| 14 | 14 | def score_point_category(point) |
| 15 | - point = GamificationPlugin::PointsType.where(id: point.score.category).first | |
| 16 | - point.nil? ? '' : point.description | |
| 15 | + point_type = point.point_type | |
| 16 | + point_type.nil? ? '' : point_type.description | |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | def score_point_target_link(point, text) | ... | ... |
lib/merit/point_rules.rb
| ... | ... | @@ -168,7 +168,7 @@ module Merit |
| 168 | 168 | |
| 169 | 169 | AVAILABLE_RULES.map do |rule_name, rule| |
| 170 | 170 | point_type = GamificationPlugin::PointsType.find_by_name rule_name |
| 171 | - point_type = GamificationPlugin::PointsType.create name: rule_name, description: rule['description'] if point_type.nil? | |
| 171 | + point_type = GamificationPlugin::PointsType.create(name: rule_name, description: rule[:description]) if point_type.nil? | |
| 172 | 172 | GamificationPlugin::PointsCategorization.create point_type_id: point_type.id, weight: rule[:default_weight] |
| 173 | 173 | end |
| 174 | 174 | end | ... | ... |
lib/merit_ext.rb
| ... | ... | @@ -20,7 +20,7 @@ module Merit |
| 20 | 20 | belongs_to :action |
| 21 | 21 | |
| 22 | 22 | def point_type |
| 23 | - @point_type ||= GamificationPlugin::PointsType.where(id: score.category).first | |
| 23 | + @point_type ||= GamificationPlugin::PointsCategorization.find_by(id: score.category).point_type | |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | 26 | def undo_rule? | ... | ... |
test/unit/dashboard_helper_test.rb
| ... | ... | @@ -23,12 +23,13 @@ class DashboardHelperTest < ActiveSupport::TestCase |
| 23 | 23 | end |
| 24 | 24 | |
| 25 | 25 | should 'return category of a score point' do |
| 26 | - point_type = GamificationPlugin::PointsType.create!(name: "point category", description: "point category") | |
| 26 | + categorization = GamificationPlugin::PointsCategorization.for_type(:vote_voter).first | |
| 27 | + point_type = categorization.point_type | |
| 27 | 28 | score = Merit::Score.new |
| 28 | - score.category = point_type.id.to_s | |
| 29 | + score.category = categorization.id.to_s | |
| 29 | 30 | score.save! |
| 30 | 31 | point = score.score_points.create! |
| 31 | - assert_equal "point category", score_point_category(point) | |
| 32 | + assert_equal "Voter", score_point_category(point) | |
| 32 | 33 | end |
| 33 | 34 | |
| 34 | 35 | end | ... | ... |