Commit 880488dc501fd8da1bcb2bc0aedf190accc627e8

Authored by Victor Costa
1 parent 7ab9ee86

Fix search for the score point category

lib/gamification_plugin/dashboard_helper.rb
... ... @@ -12,7 +12,7 @@ module GamificationPlugin::DashboardHelper
12 12 end
13 13  
14 14 def score_point_category(point)
15   - point = GamificationPlugin::PointsType.where(name: point.score.category).first
  15 + point = GamificationPlugin::PointsType.where(id: point.score.category).first
16 16 point.nil? ? '' : point.description
17 17 end
18 18  
... ...
test/unit/dashboard_helper_test.rb
... ... @@ -22,4 +22,13 @@ class DashboardHelperTest < ActiveSupport::TestCase
22 22 assert_equal [[badge2.owner, [badge2]], [badge1.owner, [badge1]]], grouped_badges
23 23 end
24 24  
  25 + should 'return category of a score point' do
  26 + point_type = GamificationPlugin::PointsType.create!(name: "point category", description: "point category")
  27 + score = Merit::Score.new
  28 + score.category = point_type.id.to_s
  29 + score.save!
  30 + point = score.score_points.create!
  31 + assert_equal "point category", score_point_category(point)
  32 + end
  33 +
25 34 end
... ...