From 03304903d832200eb7fd19e1d447ce33cbe79061 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 18 Feb 2016 10:30:43 -0300 Subject: [PATCH] Fix dashboard --- lib/gamification_plugin/dashboard_helper.rb | 4 ++-- lib/merit/point_rules.rb | 2 +- lib/merit_ext.rb | 2 +- test/unit/dashboard_helper_test.rb | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/gamification_plugin/dashboard_helper.rb b/lib/gamification_plugin/dashboard_helper.rb index 1100e11..7ee1ca3 100644 --- a/lib/gamification_plugin/dashboard_helper.rb +++ b/lib/gamification_plugin/dashboard_helper.rb @@ -12,8 +12,8 @@ module GamificationPlugin::DashboardHelper end def score_point_category(point) - point = GamificationPlugin::PointsType.where(id: point.score.category).first - point.nil? ? '' : point.description + point_type = point.point_type + point_type.nil? ? '' : point_type.description end def score_point_target_link(point, text) diff --git a/lib/merit/point_rules.rb b/lib/merit/point_rules.rb index ef94193..8a92143 100644 --- a/lib/merit/point_rules.rb +++ b/lib/merit/point_rules.rb @@ -168,7 +168,7 @@ module Merit AVAILABLE_RULES.map do |rule_name, rule| point_type = GamificationPlugin::PointsType.find_by_name rule_name - point_type = GamificationPlugin::PointsType.create name: rule_name, description: rule['description'] if point_type.nil? + point_type = GamificationPlugin::PointsType.create(name: rule_name, description: rule[:description]) if point_type.nil? GamificationPlugin::PointsCategorization.create point_type_id: point_type.id, weight: rule[:default_weight] end end diff --git a/lib/merit_ext.rb b/lib/merit_ext.rb index e933bb7..772c6dd 100644 --- a/lib/merit_ext.rb +++ b/lib/merit_ext.rb @@ -20,7 +20,7 @@ module Merit belongs_to :action def point_type - @point_type ||= GamificationPlugin::PointsType.where(id: score.category).first + @point_type ||= GamificationPlugin::PointsCategorization.find_by(id: score.category).point_type end def undo_rule? diff --git a/test/unit/dashboard_helper_test.rb b/test/unit/dashboard_helper_test.rb index 69d1d43..6c508e5 100644 --- a/test/unit/dashboard_helper_test.rb +++ b/test/unit/dashboard_helper_test.rb @@ -23,12 +23,13 @@ class DashboardHelperTest < ActiveSupport::TestCase end should 'return category of a score point' do - point_type = GamificationPlugin::PointsType.create!(name: "point category", description: "point category") + categorization = GamificationPlugin::PointsCategorization.for_type(:vote_voter).first + point_type = categorization.point_type score = Merit::Score.new - score.category = point_type.id.to_s + score.category = categorization.id.to_s score.save! point = score.score_points.create! - assert_equal "point category", score_point_category(point) + assert_equal "Voter", score_point_category(point) end end -- libgit2 0.21.2