honor 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -2
- data/.travis.yml +6 -0
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/honor.gemspec +7 -6
- data/lib/honor/model_additions.rb +9 -9
- data/lib/honor/point.rb +7 -8
- data/lib/honor/scorecard.rb +2 -2
- data/lib/honor/version.rb +1 -1
- data/spec/generators/install_generator_spec.rb +1 -1
- data/spec/honor/model_additions_spec.rb +13 -13
- data/spec/honor/point_spec.rb +18 -18
- data/spec/honor/scorecard_spec.rb +37 -37
- data/spec/spec_helper.rb +6 -5
- metadata +30 -42
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4350ad2654f93c765aaa5568988bcbcd5d200359
|
4
|
+
data.tar.gz: 31f82491e8640ac63de4bd14b289eae8dcd5debd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8d094e43e49d08df632822a7ce69579bf2a6ef5c9fffcccdb576b0ecd73d01a8063ea0a797e8773d3dd044742453807c0246972a53573db5e6517adb234f90e
|
7
|
+
data.tar.gz: 4d0ba4a747927d414669be7ebd7ba67bfa7ce59798d3894f5b2cc1326ecd75ac0bfd0333daa6d572fbde694fdea1afad7eb066f3e3cc56f543c479b11ed7ad44
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Honor
|
2
|
+
[![Build Status](https://travis-ci.org/jrmyward/honor.png?branch=master)](https://travis-ci.org/jrmyward/honor)
|
2
3
|
|
3
4
|
Honor adds support for common gamification features such as points, leaderboards, and achievements.
|
4
5
|
|
@@ -24,7 +25,7 @@ Install and run the migrations:
|
|
24
25
|
|
25
26
|
```shell
|
26
27
|
rails g honor:install
|
27
|
-
|
28
|
+
rake db:migrate
|
28
29
|
```
|
29
30
|
|
30
31
|
## Usage
|
data/honor.gemspec
CHANGED
@@ -11,16 +11,17 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.description = %q{Adds common gamification features such as points, leaderboards, and achievements to a Rails Application.}
|
12
12
|
gem.summary = %q{General gamification-centric reputation system for Rails Applications.}
|
13
13
|
gem.homepage = "https://github.com/jrmyward/honor"
|
14
|
+
gem.license = 'MIT'
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
19
|
gem.require_paths = ["lib"]
|
19
20
|
|
20
|
-
gem.add_runtime_dependency 'rails', '~>
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency '
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency
|
25
|
-
gem.add_development_dependency
|
21
|
+
gem.add_runtime_dependency 'rails', '~> 4.0'
|
22
|
+
gem.add_development_dependency 'sqlite3', '~> 0'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 0'
|
24
|
+
gem.add_development_dependency 'ammeter', '~> 0'
|
25
|
+
gem.add_development_dependency 'database_cleaner', '~> 0'
|
26
|
+
gem.add_development_dependency 'timecop', '~> 0'
|
26
27
|
end
|
@@ -19,33 +19,33 @@ module Honor
|
|
19
19
|
|
20
20
|
def points_today(category = nil)
|
21
21
|
if category.nil?
|
22
|
-
points.where(:
|
22
|
+
points.where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).sum(:value)
|
23
23
|
else
|
24
|
-
points.where(:
|
24
|
+
points.where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).where("points.category = ?", category).sum(:value)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def points_this_week(category = nil)
|
29
29
|
if category.nil?
|
30
|
-
points.where(:
|
30
|
+
points.where(created_at: Time.zone.now.beginning_of_week..Time.zone.now.end_of_week).sum(:value)
|
31
31
|
else
|
32
|
-
points.where(:
|
32
|
+
points.where(created_at: Time.zone.now.beginning_of_week..Time.zone.now.end_of_week).where("points.category = ?", category).sum(:value)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def points_this_month(category = nil)
|
37
37
|
if category.nil?
|
38
|
-
points.where(:
|
38
|
+
points.where(created_at: Time.zone.now.beginning_of_month..Time.zone.now.end_of_month).sum(:value)
|
39
39
|
else
|
40
|
-
points.where(:
|
40
|
+
points.where(created_at: Time.zone.now.beginning_of_month..Time.zone.now.end_of_month).where("points.category = ?", category).sum(:value)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def points_this_year(category = nil)
|
45
45
|
if category.nil?
|
46
|
-
points.where(:
|
46
|
+
points.where(created_at: Time.zone.now.beginning_of_year..Time.zone.now.end_of_year).sum(:value)
|
47
47
|
else
|
48
|
-
points.where(:
|
48
|
+
points.where(created_at: Time.zone.now.beginning_of_year..Time.zone.now.end_of_year).where("points.category = ?", category).sum(:value)
|
49
49
|
end
|
50
50
|
end
|
51
|
-
end
|
51
|
+
end
|
data/lib/honor/point.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Honor
|
2
2
|
class Point < ActiveRecord::Base
|
3
|
-
attr_accessible :category, :message, :user_id, :value
|
4
3
|
|
5
4
|
after_save :update_scorecard
|
6
5
|
|
@@ -14,23 +13,23 @@ module Honor
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def user_points_total(user_id)
|
17
|
-
where(:
|
16
|
+
where(user_id: user_id).sum(:value)
|
18
17
|
end
|
19
18
|
|
20
19
|
def user_points_today(user_id)
|
21
|
-
where(:
|
20
|
+
where(user_id: user_id).where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).sum(:value)
|
22
21
|
end
|
23
22
|
|
24
23
|
def user_points_this_week(user_id)
|
25
|
-
where(:
|
24
|
+
where(user_id: user_id).where(created_at: Time.zone.now.beginning_of_week..Time.zone.now.end_of_week).sum(:value)
|
26
25
|
end
|
27
26
|
|
28
27
|
def user_points_this_month(user_id)
|
29
|
-
where(:
|
28
|
+
where(user_id: user_id).where(created_at: Time.zone.now.beginning_of_month..Time.zone.now.end_of_month).sum(:value)
|
30
29
|
end
|
31
30
|
|
32
31
|
def user_points_this_year(user_id)
|
33
|
-
where(:
|
32
|
+
where(user_id: user_id).where(created_at: Time.zone.now.beginning_of_year..Time.zone.now.end_of_year).sum(:value)
|
34
33
|
end
|
35
34
|
|
36
35
|
end
|
@@ -38,7 +37,7 @@ module Honor
|
|
38
37
|
private
|
39
38
|
|
40
39
|
def update_scorecard
|
41
|
-
scorecard = Honor::Scorecard.
|
40
|
+
scorecard = Honor::Scorecard.find_or_initialize_by user_id: user_id
|
42
41
|
scorecard.daily = Honor::Point.user_points_today(user_id)
|
43
42
|
scorecard.weekly = Honor::Point.user_points_this_week(user_id)
|
44
43
|
scorecard.monthly = Honor::Point.user_points_this_month(user_id)
|
@@ -48,4 +47,4 @@ module Honor
|
|
48
47
|
end
|
49
48
|
|
50
49
|
end
|
51
|
-
end
|
50
|
+
end
|
data/lib/honor/scorecard.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Honor
|
2
2
|
|
3
3
|
class Scorecard < ActiveRecord::Base
|
4
|
-
attr_accessible :daily, :lifetime, :monthly, :user_id, :weekly, :yearly, :position
|
4
|
+
#attr_accessible :daily, :lifetime, :monthly, :user_id, :weekly, :yearly, :position
|
5
5
|
attr_accessor :position
|
6
6
|
|
7
7
|
class << self
|
@@ -60,4 +60,4 @@ module Honor
|
|
60
60
|
|
61
61
|
end
|
62
62
|
|
63
|
-
end
|
63
|
+
end
|
data/lib/honor/version.rb
CHANGED
@@ -5,7 +5,7 @@ require 'generators/honor/install/install_generator'
|
|
5
5
|
|
6
6
|
describe Honor::Generators::InstallGenerator do
|
7
7
|
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
-
destination File.expand_path("
|
8
|
+
destination File.expand_path("../../../tmp", __FILE__)
|
9
9
|
|
10
10
|
before do
|
11
11
|
prepare_destination
|
@@ -8,11 +8,11 @@ describe Honor do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should create an instance attribute for points" do
|
11
|
-
user.
|
11
|
+
expect(user).to respond_to(:points)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should create an instance attribute for scorecard" do
|
15
|
-
user.
|
15
|
+
expect(user).to respond_to(:scorecard)
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "Method" do
|
@@ -31,7 +31,7 @@ describe Honor do
|
|
31
31
|
end
|
32
32
|
it "should set the value to a negative number" do
|
33
33
|
p = user.subtract_points(25, 'Manual Add', 'Test')
|
34
|
-
p.value.
|
34
|
+
expect(p.value).to equal(-25)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -49,46 +49,46 @@ describe Honor do
|
|
49
49
|
context "User" do
|
50
50
|
describe "points_total" do
|
51
51
|
it "should return a sum of all of the user's points" do
|
52
|
-
user.points_total.
|
52
|
+
expect(user.points_total).to equal(150)
|
53
53
|
end
|
54
54
|
it "should return a sum of user points for a given category" do
|
55
|
-
user.points_total('Test 2').
|
55
|
+
expect(user.points_total('Test 2')).to equal(75)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "points_today" do
|
60
60
|
it "should return a sum of all of the user's points" do
|
61
|
-
user.points_today.
|
61
|
+
expect(user.points_today).to equal(50)
|
62
62
|
end
|
63
63
|
it "should return a sum of user points for a given category" do
|
64
|
-
user.points_today('Test 2').
|
64
|
+
expect(user.points_today('Test 2')).to equal(25)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
describe "points_this_week" do
|
69
69
|
it "should return a sum of all of the user's points" do
|
70
|
-
user.points_this_week.
|
70
|
+
expect(user.points_this_week).to equal(50)
|
71
71
|
end
|
72
72
|
it "should return a sum of user points for a given category" do
|
73
|
-
user.points_this_week('Test 2').
|
73
|
+
expect(user.points_this_week('Test 2')).to equal(25)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "points_this_month" do
|
78
78
|
it "should return a sum of all of the user's points" do
|
79
|
-
user.points_this_month.
|
79
|
+
expect(user.points_this_month).to equal(150)
|
80
80
|
end
|
81
81
|
it "should return a sum of user points for a given category" do
|
82
|
-
user.points_this_month('Test 2').
|
82
|
+
expect(user.points_this_month('Test 2')).to equal(75)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "points_this_year" do
|
87
87
|
it "should return a sum of all of the user's points" do
|
88
|
-
user.points_this_year.
|
88
|
+
expect(user.points_this_year).to equal(150)
|
89
89
|
end
|
90
90
|
it "should return a sum of user points for a given category" do
|
91
|
-
user.points_this_year('Test 2').
|
91
|
+
expect(user.points_this_year('Test 2')).to equal(75)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
data/spec/honor/point_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Honor::Point do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should respond to the reciever" do
|
11
|
-
Honor::Point.new.
|
11
|
+
expect(Honor::Point.new).to respond_to(:user)
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "Method" do
|
@@ -27,7 +27,7 @@ describe Honor::Point do
|
|
27
27
|
end
|
28
28
|
it "should set the value to a negative number" do
|
29
29
|
p = Honor::Point.take_from(user.id, 25, 'Manual take away', 'Test')
|
30
|
-
p.value.
|
30
|
+
expect(p.value).to equal(-25)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -40,12 +40,12 @@ describe Honor::Point do
|
|
40
40
|
it "should update after Points are saved" do
|
41
41
|
Timecop.freeze(2012, 12, 4, 16, 00)
|
42
42
|
sc = Honor::Scorecard.find_by_user_id(user.id)
|
43
|
-
sc.
|
44
|
-
sc.daily.
|
45
|
-
sc.weekly.
|
46
|
-
sc.monthly.
|
47
|
-
sc.yearly.
|
48
|
-
sc.lifetime.
|
43
|
+
expect(sc).not_to be_nil
|
44
|
+
expect(sc.daily).to equal(50)
|
45
|
+
expect(sc.weekly).to equal(50)
|
46
|
+
expect(sc.monthly).to equal(50)
|
47
|
+
expect(sc.yearly).to equal(150)
|
48
|
+
expect(sc.lifetime).to equal(150)
|
49
49
|
Timecop.return
|
50
50
|
end
|
51
51
|
|
@@ -54,11 +54,11 @@ describe Honor::Point do
|
|
54
54
|
Timecop.freeze(2012, 12, 5, 16, 01)
|
55
55
|
Honor::Scorecard.update_scorecards
|
56
56
|
sc = Honor::Scorecard.find_by_user_id(user.id)
|
57
|
-
sc.daily.
|
58
|
-
sc.weekly.
|
59
|
-
sc.monthly.
|
60
|
-
sc.yearly.
|
61
|
-
sc.lifetime.
|
57
|
+
expect(sc.daily).to equal(0)
|
58
|
+
expect(sc.weekly).to equal(50)
|
59
|
+
expect(sc.monthly).to equal(50)
|
60
|
+
expect(sc.yearly).to equal(150)
|
61
|
+
expect(sc.lifetime).to equal(150)
|
62
62
|
Timecop.return
|
63
63
|
end
|
64
64
|
end
|
@@ -77,31 +77,31 @@ describe Honor::Point do
|
|
77
77
|
context "Self" do
|
78
78
|
describe "user_points_total" do
|
79
79
|
it "should return a sum of all of the user's points" do
|
80
|
-
Honor::Point.user_points_total(user.id).
|
80
|
+
expect(Honor::Point.user_points_total(user.id)).to equal(150)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
describe "user_points_today" do
|
85
85
|
it "should return a sum of all of the user's points" do
|
86
|
-
Honor::Point.user_points_today(user.id).
|
86
|
+
expect(Honor::Point.user_points_today(user.id)).to equal(50)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "user_points_this_week" do
|
91
91
|
it "should return a sum of all of the user's points" do
|
92
|
-
Honor::Point.user_points_this_week(user.id).
|
92
|
+
expect(Honor::Point.user_points_this_week(user.id)).to equal(50)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
describe "user_points_this_month" do
|
97
97
|
it "should return a sum of all of the user's points" do
|
98
|
-
Honor::Point.user_points_this_month(user.id).
|
98
|
+
expect(Honor::Point.user_points_this_month(user.id)).to equal(150)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe "user_points_this_year" do
|
103
103
|
it "should return a sum of all of the user's points" do
|
104
|
-
Honor::Point.user_points_this_year(user.id).
|
104
|
+
expect(Honor::Point.user_points_this_year(user.id)).to equal(150)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -15,18 +15,18 @@ describe Honor::Scorecard do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should respond to the reciever" do
|
18
|
-
Honor::Scorecard.new.
|
18
|
+
expect(Honor::Scorecard.new).to respond_to(:user)
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "Ranking" do
|
22
22
|
it "should produce rankings with correctly calculated tied positions" do
|
23
23
|
user_ids = [@user_2.id, @user_1.id]
|
24
24
|
daily_rankings = Honor::Scorecard.leaderboard(user_ids, rank_by: 'daily', sort_direction: 'desc')
|
25
|
-
daily_rankings[0].position.
|
26
|
-
daily_rankings[1].position.
|
25
|
+
expect(daily_rankings[0].position).to equal(1)
|
26
|
+
expect(daily_rankings[1].position).to equal(2)
|
27
27
|
weekly_rankings = Honor::Scorecard.leaderboard(user_ids, rank_by: 'weekly', sort_direction: 'desc')
|
28
|
-
weekly_rankings[0].position.
|
29
|
-
weekly_rankings[1].position.
|
28
|
+
expect(weekly_rankings[0].position).to equal(1)
|
29
|
+
expect(weekly_rankings[1].position).to equal(1)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -35,10 +35,10 @@ describe Honor::Scorecard do
|
|
35
35
|
it "should set the daily attribute to 0 if no updates have been made today" do
|
36
36
|
Honor::Scorecard.reset_daily_scores
|
37
37
|
sc = Honor::Scorecard.find_by_user_id(@user_1.id)
|
38
|
-
sc.daily.
|
39
|
-
sc.weekly.
|
40
|
-
sc.monthly.
|
41
|
-
sc.yearly.
|
38
|
+
expect(sc.daily).to equal(0)
|
39
|
+
expect(sc.weekly).to equal(100)
|
40
|
+
expect(sc.monthly).to equal(350)
|
41
|
+
expect(sc.yearly).to equal(1250)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should NOT change the daily attribute if an update was made today" do
|
@@ -46,20 +46,20 @@ describe Honor::Scorecard do
|
|
46
46
|
sc_before.update_attribute(:daily, 30)
|
47
47
|
Honor::Scorecard.reset_daily_scores
|
48
48
|
sc_after = Honor::Scorecard.find_by_user_id(@user_1.id)
|
49
|
-
sc_after.daily.
|
50
|
-
sc_after.weekly.
|
51
|
-
sc_after.monthly.
|
52
|
-
sc_after.yearly.
|
49
|
+
expect(sc_after.daily).to equal(30)
|
50
|
+
expect(sc_after.weekly).to equal(100)
|
51
|
+
expect(sc_after.monthly).to equal(350)
|
52
|
+
expect(sc_after.yearly).to equal(1250)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
describe "#reset_weekly_scores" do
|
56
56
|
it "should set the weekly attribute to 0 if no updates have been made this week" do
|
57
57
|
Honor::Scorecard.reset_weekly_scores
|
58
58
|
sc = Honor::Scorecard.find_by_user_id(@user_1.id)
|
59
|
-
sc.daily.
|
60
|
-
sc.weekly.
|
61
|
-
sc.monthly.
|
62
|
-
sc.yearly.
|
59
|
+
expect(sc.daily).to equal(25)
|
60
|
+
expect(sc.weekly).to equal(0)
|
61
|
+
expect(sc.monthly).to equal(350)
|
62
|
+
expect(sc.yearly).to equal(1250)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should NOT change the weekly attribute if an update was made this week" do
|
@@ -67,20 +67,20 @@ describe Honor::Scorecard do
|
|
67
67
|
sc_before.update_attribute(:weekly, 125)
|
68
68
|
Honor::Scorecard.reset_weekly_scores
|
69
69
|
sc_after = Honor::Scorecard.find_by_user_id(@user_1.id)
|
70
|
-
sc_after.daily.
|
71
|
-
sc_after.weekly.
|
72
|
-
sc_after.monthly.
|
73
|
-
sc_after.yearly.
|
70
|
+
expect(sc_after.daily).to equal(25)
|
71
|
+
expect(sc_after.weekly).to equal(125)
|
72
|
+
expect(sc_after.monthly).to equal(350)
|
73
|
+
expect(sc_after.yearly).to equal(1250)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
describe "#reset_monthly_scores" do
|
77
77
|
it "should set the monthly attribute to 0 if no updates have been made this month" do
|
78
78
|
Honor::Scorecard.reset_monthly_scores
|
79
79
|
sc = Honor::Scorecard.find_by_user_id(@user_1.id)
|
80
|
-
sc.daily.
|
81
|
-
sc.weekly.
|
82
|
-
sc.monthly.
|
83
|
-
sc.yearly.
|
80
|
+
expect(sc.daily).to equal(25)
|
81
|
+
expect(sc.weekly).to equal(100)
|
82
|
+
expect(sc.monthly).to equal(0)
|
83
|
+
expect(sc.yearly).to equal(1250)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should NOT change the monthly attribute if an update was made this month" do
|
@@ -88,20 +88,20 @@ describe Honor::Scorecard do
|
|
88
88
|
sc_before.update_attribute(:monthly, 400)
|
89
89
|
Honor::Scorecard.reset_monthly_scores
|
90
90
|
sc_after = Honor::Scorecard.find_by_user_id(@user_1.id)
|
91
|
-
sc_after.daily.
|
92
|
-
sc_after.weekly.
|
93
|
-
sc_after.monthly.
|
94
|
-
sc_after.yearly.
|
91
|
+
expect(sc_after.daily).to equal(25)
|
92
|
+
expect(sc_after.weekly).to equal(100)
|
93
|
+
expect(sc_after.monthly).to equal(400)
|
94
|
+
expect(sc_after.yearly).to equal(1250)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
describe "#reset_yearly_scores" do
|
98
98
|
it "should set the yearly attribute to 0 if no updates have been made this year" do
|
99
99
|
Honor::Scorecard.reset_yearly_scores
|
100
100
|
sc = Honor::Scorecard.find_by_user_id(@user_1.id)
|
101
|
-
sc.daily.
|
102
|
-
sc.weekly.
|
103
|
-
sc.monthly.
|
104
|
-
sc.yearly.
|
101
|
+
expect(sc.daily).to equal(25)
|
102
|
+
expect(sc.weekly).to equal(100)
|
103
|
+
expect(sc.monthly).to equal(350)
|
104
|
+
expect(sc.yearly).to equal(0)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should NOT change the yearly attribute if an update was made this year" do
|
@@ -109,10 +109,10 @@ describe Honor::Scorecard do
|
|
109
109
|
sc_before.update_attribute(:yearly, 1300)
|
110
110
|
Honor::Scorecard.reset_yearly_scores
|
111
111
|
sc_after = Honor::Scorecard.find_by_user_id(@user_1.id)
|
112
|
-
sc_after.daily.
|
113
|
-
sc_after.weekly.
|
114
|
-
sc_after.monthly.
|
115
|
-
sc_after.yearly.
|
112
|
+
expect(sc_after.daily).to equal(25)
|
113
|
+
expect(sc_after.weekly).to equal(100)
|
114
|
+
expect(sc_after.monthly).to equal(350)
|
115
|
+
expect(sc_after.yearly).to equal(1300)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rails/all'
|
1
2
|
require 'rubygems'
|
2
3
|
require 'honor'
|
3
4
|
require 'ammeter/init'
|
@@ -16,7 +17,7 @@ if File.exists?(database_yml)
|
|
16
17
|
config = ActiveRecord::Base.configurations[db_name]
|
17
18
|
|
18
19
|
begin
|
19
|
-
ActiveRecord::Base.establish_connection(db_name)
|
20
|
+
ActiveRecord::Base.establish_connection(db_name.to_sym)
|
20
21
|
ActiveRecord::Base.connection
|
21
22
|
rescue
|
22
23
|
case db_name
|
@@ -34,15 +35,15 @@ if File.exists?(database_yml)
|
|
34
35
|
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
|
35
36
|
ActiveRecord::Base.default_timezone = :utc
|
36
37
|
|
37
|
-
ActiveRecord::Base.silence do
|
38
|
+
#ActiveRecord::Base.logger.silence do
|
38
39
|
ActiveRecord::Migration.verbose = false
|
39
40
|
|
40
41
|
load(File.expand_path('../config/schema.rb', __FILE__))
|
41
42
|
load(File.expand_path('../config/models.rb', __FILE__))
|
42
|
-
end
|
43
|
+
#end
|
43
44
|
|
44
45
|
else
|
45
|
-
raise "Please create #{database_yml} first to configure your database. Take a look at: spec/config
|
46
|
+
raise "Please create #{database_yml} first to configure your database. Take a look at: spec/config/database.yml.sample"
|
46
47
|
end
|
47
48
|
|
48
49
|
RSpec.configure do |config|
|
@@ -60,4 +61,4 @@ RSpec.configure do |config|
|
|
60
61
|
config.after(:each) do
|
61
62
|
DatabaseCleaner.clean
|
62
63
|
end
|
63
|
-
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,110 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jeremy Ward
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '4.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '4.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: sqlite3
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
42
|
+
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
56
|
+
name: ammeter
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: database_cleaner
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: timecop
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - "~>"
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - "~>"
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
description: Adds common gamification features such as points, leaderboards, and achievements
|
@@ -115,15 +102,15 @@ executables: []
|
|
115
102
|
extensions: []
|
116
103
|
extra_rdoc_files: []
|
117
104
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .rspec
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
120
108
|
- CHANGELOG.md
|
121
109
|
- Gemfile
|
122
110
|
- LICENSE.txt
|
123
111
|
- README.md
|
124
112
|
- Rakefile
|
125
113
|
- honor.gemspec
|
126
|
-
- honor.sqlite3
|
127
114
|
- lib/generators/honor/install/install_generator.rb
|
128
115
|
- lib/generators/honor/install/templates/create_honor_points.rb
|
129
116
|
- lib/generators/honor/install/templates/create_honor_scorecards.rb
|
@@ -142,28 +129,28 @@ files:
|
|
142
129
|
- spec/honor/scorecard_spec.rb
|
143
130
|
- spec/spec_helper.rb
|
144
131
|
homepage: https://github.com/jrmyward/honor
|
145
|
-
licenses:
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
146
135
|
post_install_message:
|
147
136
|
rdoc_options: []
|
148
137
|
require_paths:
|
149
138
|
- lib
|
150
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
-
none: false
|
152
140
|
requirements:
|
153
|
-
- -
|
141
|
+
- - ">="
|
154
142
|
- !ruby/object:Gem::Version
|
155
143
|
version: '0'
|
156
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
-
none: false
|
158
145
|
requirements:
|
159
|
-
- -
|
146
|
+
- - ">="
|
160
147
|
- !ruby/object:Gem::Version
|
161
148
|
version: '0'
|
162
149
|
requirements: []
|
163
150
|
rubyforge_project:
|
164
|
-
rubygems_version:
|
151
|
+
rubygems_version: 2.4.5
|
165
152
|
signing_key:
|
166
|
-
specification_version:
|
153
|
+
specification_version: 4
|
167
154
|
summary: General gamification-centric reputation system for Rails Applications.
|
168
155
|
test_files:
|
169
156
|
- spec/config/database.yml.sample
|
@@ -174,3 +161,4 @@ test_files:
|
|
174
161
|
- spec/honor/point_spec.rb
|
175
162
|
- spec/honor/scorecard_spec.rb
|
176
163
|
- spec/spec_helper.rb
|
164
|
+
has_rdoc:
|