From 812266b80edf5dd6833ec6cf825f5fb3cb8315f6 Mon Sep 17 00:00:00 2001 From: Denny Bresch Date: Thu, 27 Jun 2019 11:01:11 +0200 Subject: [PATCH] Fixed wrong score (range) for karma level Evangelist. --- ...190626000001_setting_update_karma_level.rb | 53 +++++++++++++++++++ db/seeds/settings.rb | 2 +- test/unit/karma_test.rb | 2 +- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20190626000001_setting_update_karma_level.rb diff --git a/db/migrate/20190626000001_setting_update_karma_level.rb b/db/migrate/20190626000001_setting_update_karma_level.rb new file mode 100644 index 000000000..c27987262 --- /dev/null +++ b/db/migrate/20190626000001_setting_update_karma_level.rb @@ -0,0 +1,53 @@ +class SettingUpdateKarmaLevel < ActiveRecord::Migration[5.1] + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + Setting.set( + 'karma_levels', + [ + { + name: 'Beginner', + start: 0, + end: 499, + }, + { + name: 'Newbie', + start: 500, + end: 1999, + }, + { + name: 'Intermediate', + start: 2000, + end: 4999, + }, + { + name: 'Professional', + start: 5000, + end: 6999, + }, + { + name: 'Expert', + start: 7000, + end: 8999, + }, + { + name: 'Master', + start: 9000, + end: 18_999, + }, + { + name: 'Evangelist', + start: 19_000, + end: 49_999, + }, + { + name: 'Hero', + start: 50_000, + end: nil, + } + ], + ) + end +end diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index e3bfde33d..19c41da42 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -4247,7 +4247,7 @@ Setting.create_if_not_exists( { name: 'Evangelist', start: 19_000, - end: 45_999, + end: 49_999, }, { name: 'Hero', diff --git a/test/unit/karma_test.rb b/test/unit/karma_test.rb index 2f1475459..04f679545 100644 --- a/test/unit/karma_test.rb +++ b/test/unit/karma_test.rb @@ -506,7 +506,7 @@ class KarmaTest < ActiveSupport::TestCase assert_equal('Master', Karma::User.level_by_score(9000)) assert_equal('Master', Karma::User.level_by_score(18_999)) assert_equal('Evangelist', Karma::User.level_by_score(19_000)) - assert_equal('Evangelist', Karma::User.level_by_score(45_999)) + assert_equal('Evangelist', Karma::User.level_by_score(49_999)) assert_equal('Hero', Karma::User.level_by_score(50_000)) # cleanup