From 880488dc501fd8da1bcb2bc0aedf190accc627e8 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 9 Nov 2015 14:04:10 -0300 Subject: [PATCH] Fix search for the score point category --- lib/gamification_plugin/dashboard_helper.rb | 2 +- test/unit/dashboard_helper_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/gamification_plugin/dashboard_helper.rb b/lib/gamification_plugin/dashboard_helper.rb index 93d7c99..300ff9c 100644 --- a/lib/gamification_plugin/dashboard_helper.rb +++ b/lib/gamification_plugin/dashboard_helper.rb @@ -12,7 +12,7 @@ module GamificationPlugin::DashboardHelper end def score_point_category(point) - point = GamificationPlugin::PointsType.where(name: point.score.category).first + point = GamificationPlugin::PointsType.where(id: point.score.category).first point.nil? ? '' : point.description end diff --git a/test/unit/dashboard_helper_test.rb b/test/unit/dashboard_helper_test.rb index 64b3034..69d1d43 100644 --- a/test/unit/dashboard_helper_test.rb +++ b/test/unit/dashboard_helper_test.rb @@ -22,4 +22,13 @@ class DashboardHelperTest < ActiveSupport::TestCase assert_equal [[badge2.owner, [badge2]], [badge1.owner, [badge1]]], grouped_badges end + should 'return category of a score point' do + point_type = GamificationPlugin::PointsType.create!(name: "point category", description: "point category") + score = Merit::Score.new + score.category = point_type.id.to_s + score.save! + point = score.score_points.create! + assert_equal "point category", score_point_category(point) + end + end -- libgit2 0.21.2