merit 3.0.3 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -9
- data/NEWS.md +7 -0
- data/README.md +14 -2
- data/app/models/merit/badge.rb +1 -9
- data/lib/merit.rb +6 -36
- data/lib/merit/{rules_badge_methods.rb → badge_rules_methods.rb} +0 -0
- data/lib/merit/base_target_finder.rb +1 -6
- data/lib/merit/{model_additions.rb → class_methods.rb} +0 -11
- data/lib/merit/controller_extensions.rb +4 -22
- data/lib/{generators → merit/generators}/active_record/install_generator.rb +8 -8
- data/lib/{generators → merit/generators}/active_record/merit_generator.rb +3 -3
- data/lib/{generators → merit/generators}/active_record/remove_generator.rb +5 -5
- data/lib/{generators/active_record/templates/add_merit_fields_to_model.rb → merit/generators/active_record/templates/add_merit_fields_to_model.erb} +0 -0
- data/lib/{generators/active_record/templates/create_badges_sashes.rb → merit/generators/active_record/templates/create_badges_sashes.erb} +0 -0
- data/lib/{generators/active_record/templates/create_merit_actions.rb → merit/generators/active_record/templates/create_merit_actions.erb} +0 -0
- data/lib/{generators/active_record/templates/create_merit_activity_logs.rb → merit/generators/active_record/templates/create_merit_activity_logs.erb} +0 -0
- data/lib/{generators/active_record/templates/create_sashes.rb → merit/generators/active_record/templates/create_sashes.erb} +0 -0
- data/lib/{generators/active_record/templates/create_scores_and_points.rb → merit/generators/active_record/templates/create_scores_and_points.erb} +1 -1
- data/lib/{generators/active_record/templates/remove_merit_fields_from_model.rb → merit/generators/active_record/templates/remove_merit_fields_from_model.erb} +0 -0
- data/lib/{generators/active_record/templates/remove_merit_tables.rb → merit/generators/active_record/templates/remove_merit_tables.erb} +0 -0
- data/lib/merit/generators/install_generator.rb +18 -0
- data/lib/{generators/merit → merit/generators}/merit_generator.rb +3 -1
- data/lib/{generators/merit → merit/generators}/remove_generator.rb +3 -1
- data/lib/{generators/merit/templates/merit.rb → merit/generators/templates/merit.erb} +0 -3
- data/lib/{generators/merit/templates/merit_badge_rules.rb → merit/generators/templates/merit_badge_rules.erb} +0 -0
- data/lib/{generators/merit/templates/merit_point_rules.rb → merit/generators/templates/merit_point_rules.erb} +0 -0
- data/lib/{generators/merit/templates/merit_rank_rules.rb → merit/generators/templates/merit_rank_rules.erb} +0 -0
- data/{app/models/merit/action.rb → lib/merit/models/action_concern.rb} +12 -10
- data/lib/merit/models/active_record/{merit/action.rb → action.rb} +5 -1
- data/lib/merit/models/active_record/{merit/activity_log.rb → activity_log.rb} +3 -1
- data/lib/merit/models/active_record/{merit/badges_sash.rb → badges_sash.rb} +4 -2
- data/lib/merit/models/active_record/{merit/sash.rb → sash.rb} +5 -2
- data/lib/merit/models/active_record/{merit/score.rb → score.rb} +4 -1
- data/lib/merit/models/badges_sash_concern.rb +13 -0
- data/lib/merit/models/base/badges_sash.rb +1 -1
- data/lib/merit/models/base/sash.rb +1 -1
- data/lib/merit/models/sash_concern.rb +53 -0
- data/lib/merit/{rules_points_methods.rb → point_rules_methods.rb} +0 -0
- data/lib/merit/{rules_rank_methods.rb → rank_rules_methods.rb} +3 -18
- data/merit.gemspec +4 -2
- data/test/dummy/app/models/address.rb +1 -12
- data/test/dummy/app/models/comment.rb +3 -21
- data/test/dummy/app/models/user.rb +1 -14
- data/test/dummy/config/application.rb +5 -1
- data/test/dummy/config/application_api_only.rb +1 -1
- data/test/dummy/db/schema.rb +1 -6
- data/test/integration/navigation_test.rb +2 -2
- data/test/test_helper.rb +0 -2
- data/test/unit/base_target_finder_test.rb +7 -26
- data/test/unit/merit_unit_test.rb +6 -8
- data/test/unit/rule_unit_test.rb +8 -8
- data/test/unit/rules_matcher_test.rb +9 -6
- data/test/unit/sash_finder_test.rb +5 -5
- data/test/unit/score_test.rb +1 -1
- data/test/unit/target_finder_test.rb +13 -13
- metadata +47 -59
- data/UPGRADING.md +0 -256
- data/lib/generators/active_record/templates/add_target_data_to_merit_actions.rb +0 -5
- data/lib/generators/active_record/upgrade_generator.rb +0 -40
- data/lib/generators/merit/install_generator.rb +0 -16
- data/lib/generators/merit/upgrade_generator.rb +0 -7
- data/lib/merit/models/mongoid/merit/action.rb +0 -18
- data/lib/merit/models/mongoid/merit/activity_log.rb +0 -11
- data/lib/merit/models/mongoid/merit/badges_sash.rb +0 -20
- data/lib/merit/models/mongoid/merit/sash.rb +0 -30
- data/lib/merit/models/mongoid/merit/score.rb +0 -45
- data/test/dummy/db/migrate/20140906225844_create_players.rb +0 -8
- data/test/dummy/public/javascripts/application.js +0 -2
- data/test/dummy/public/javascripts/controls.js +0 -965
- data/test/dummy/public/javascripts/dragdrop.js +0 -974
- data/test/dummy/public/javascripts/effects.js +0 -1123
- data/test/dummy/public/javascripts/prototype.js +0 -6001
- data/test/dummy/public/javascripts/rails.js +0 -191
- data/test/orm_models/active_record.rb +0 -11
- data/test/orm_models/mongoid.rb +0 -15
@@ -5,29 +5,32 @@ describe Merit::RulesMatcher do
|
|
5
5
|
describe 'rules actions are treated as a regexp' do
|
6
6
|
it 'selects matching rules (suffix)' do
|
7
7
|
matcher = Merit::RulesMatcher.new('comments', 'update')
|
8
|
-
matcher.select_from(
|
8
|
+
selected = matcher.select_from(
|
9
9
|
'comments#update' => 'comments#update',
|
10
10
|
'comments#up' => 'comments#up',
|
11
11
|
'comments#up$' => 'comments#up$',
|
12
12
|
'comments#up.+$' => 'comments#up.+$',
|
13
|
-
)
|
13
|
+
)
|
14
|
+
_(selected).must_be :==, ['comments#update', 'comments#up.+$']
|
14
15
|
|
15
16
|
matcher = Merit::RulesMatcher.new('comments', 'up')
|
16
|
-
matcher.select_from(
|
17
|
+
selected = matcher.select_from(
|
17
18
|
'comments#update' => 'comments#update',
|
18
19
|
'comments#up' => 'comments#up',
|
19
20
|
'comments#up$' => 'comments#up$',
|
20
21
|
'comments#up.+$' => 'comments#up.+$',
|
21
|
-
)
|
22
|
+
)
|
23
|
+
_(selected).must_be :==, ['comments#up', 'comments#up$']
|
22
24
|
end
|
23
25
|
|
24
26
|
it 'selects matching rules (prefix)' do
|
25
27
|
matcher = Merit::RulesMatcher.new('/posts/1/comments', 'create')
|
26
|
-
matcher.select_from(
|
28
|
+
selected = matcher.select_from(
|
27
29
|
'comments#create' => 'comments#create',
|
28
30
|
'^comments#create' => '^comments#create',
|
29
31
|
'^.*/comments#create' => '^.*/comments#create',
|
30
|
-
)
|
32
|
+
)
|
33
|
+
_(selected).must_be :==, ['^.*/comments#create']
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
@@ -3,11 +3,11 @@ require 'test_helper'
|
|
3
3
|
describe Merit::SashFinder do
|
4
4
|
it 'should return an array of sashes of the target objects' do
|
5
5
|
sash_1 = Merit::Sash.new
|
6
|
-
user_1 =
|
6
|
+
user_1 = User.new
|
7
7
|
user_1.stubs(:_sash).returns(sash_1)
|
8
8
|
|
9
9
|
sash_2 = Merit::Sash.new
|
10
|
-
user_2 =
|
10
|
+
user_2 = User.new
|
11
11
|
user_2.stubs(:_sash).returns(sash_2)
|
12
12
|
|
13
13
|
# TODO: With stub we are not exercising compact
|
@@ -20,8 +20,8 @@ describe Merit::SashFinder do
|
|
20
20
|
|
21
21
|
Merit::SashFinder.stubs(:targets).returns(users)
|
22
22
|
sashes = Merit::SashFinder.find(rule, action)
|
23
|
-
sashes.count.must_be :==, 2
|
24
|
-
sashes.must_include sash_1
|
25
|
-
sashes.must_include sash_2
|
23
|
+
_(sashes.count).must_be :==, 2
|
24
|
+
_(sashes).must_include sash_1
|
25
|
+
_(sashes).must_include sash_2
|
26
26
|
end
|
27
27
|
end
|
data/test/unit/score_test.rb
CHANGED
@@ -17,14 +17,14 @@ describe Merit::TargetFinder do
|
|
17
17
|
|
18
18
|
finder = Merit::TargetFinder.new(rule, action)
|
19
19
|
collection = finder.find
|
20
|
-
collection.size.must_be :==, 1
|
21
|
-
collection.must_include comment
|
20
|
+
_(collection.size).must_be :==, 1
|
21
|
+
_(collection).must_include comment
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'rule#to is :action_user' do
|
26
26
|
before do
|
27
|
-
Merit.setup { |config| config.user_model_name = '
|
27
|
+
Merit.setup { |config| config.user_model_name = 'User' }
|
28
28
|
end
|
29
29
|
after do
|
30
30
|
Merit.setup { |config| config.user_model_name = 'User' }
|
@@ -34,14 +34,14 @@ describe Merit::TargetFinder do
|
|
34
34
|
rule = Merit::Rule.new
|
35
35
|
rule.to = :action_user
|
36
36
|
action = Merit::Action.new(user_id: 22)
|
37
|
-
user =
|
37
|
+
user = User.new
|
38
38
|
|
39
|
-
|
39
|
+
User.stubs(:find_by_id).with(22).returns(user)
|
40
40
|
|
41
41
|
finder = Merit::TargetFinder.new(rule, action)
|
42
42
|
collection = finder.find
|
43
|
-
collection.size.must_be :==, 1
|
44
|
-
collection.must_include user
|
43
|
+
_(collection.size).must_be :==, 1
|
44
|
+
_(collection).must_include user
|
45
45
|
end
|
46
46
|
|
47
47
|
describe 'when user does not exist' do
|
@@ -50,9 +50,9 @@ describe Merit::TargetFinder do
|
|
50
50
|
rule.to = :action_user
|
51
51
|
action = Merit::Action.new(user_id: 22)
|
52
52
|
|
53
|
-
Rails.logger.expects(:warn).with('[merit] no
|
53
|
+
Rails.logger.expects(:warn).with('[merit] no User found with id 22')
|
54
54
|
finder = Merit::TargetFinder.new(rule, action)
|
55
|
-
finder.find.must_be_empty
|
55
|
+
_(finder.find).must_be_empty
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -64,15 +64,15 @@ describe Merit::TargetFinder do
|
|
64
64
|
rule.model_name = 'comments'
|
65
65
|
action = Merit::Action.new(target_id: 40)
|
66
66
|
|
67
|
-
user =
|
67
|
+
user = User.new
|
68
68
|
comment = Comment.new
|
69
69
|
comment.stubs(:user).returns(user)
|
70
70
|
Comment.stubs(:find_by_id).with(40).returns(comment)
|
71
71
|
|
72
72
|
finder = Merit::TargetFinder.new(rule, action)
|
73
73
|
collection = finder.find
|
74
|
-
collection.size.must_be :==, 1
|
75
|
-
collection.must_include user
|
74
|
+
_(collection.size).must_be :==, 1
|
75
|
+
_(collection).must_include user
|
76
76
|
end
|
77
77
|
|
78
78
|
describe 'rule#to does not exist as a method on the original target' do
|
@@ -90,7 +90,7 @@ describe Merit::TargetFinder do
|
|
90
90
|
|
91
91
|
Rails.logger.expects(:warn).with(str)
|
92
92
|
finder = Merit::TargetFinder.new(rule, action)
|
93
|
-
finder.find.must_be_empty
|
93
|
+
_(finder.find).must_be_empty
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tute Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ambry
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: zeitwerk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rails
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,54 +136,47 @@ files:
|
|
122
136
|
- RELEASING.md
|
123
137
|
- Rakefile
|
124
138
|
- TESTING.txt
|
125
|
-
- UPGRADING.md
|
126
|
-
- app/models/merit/action.rb
|
127
139
|
- app/models/merit/badge.rb
|
128
140
|
- config/locales/en.yml
|
129
|
-
- lib/generators/active_record/install_generator.rb
|
130
|
-
- lib/generators/active_record/merit_generator.rb
|
131
|
-
- lib/generators/active_record/remove_generator.rb
|
132
|
-
- lib/generators/active_record/templates/add_merit_fields_to_model.rb
|
133
|
-
- lib/generators/active_record/templates/add_target_data_to_merit_actions.rb
|
134
|
-
- lib/generators/active_record/templates/create_badges_sashes.rb
|
135
|
-
- lib/generators/active_record/templates/create_merit_actions.rb
|
136
|
-
- lib/generators/active_record/templates/create_merit_activity_logs.rb
|
137
|
-
- lib/generators/active_record/templates/create_sashes.rb
|
138
|
-
- lib/generators/active_record/templates/create_scores_and_points.rb
|
139
|
-
- lib/generators/active_record/templates/remove_merit_fields_from_model.rb
|
140
|
-
- lib/generators/active_record/templates/remove_merit_tables.rb
|
141
|
-
- lib/generators/active_record/upgrade_generator.rb
|
142
|
-
- lib/generators/merit/install_generator.rb
|
143
|
-
- lib/generators/merit/merit_generator.rb
|
144
|
-
- lib/generators/merit/remove_generator.rb
|
145
|
-
- lib/generators/merit/templates/merit.rb
|
146
|
-
- lib/generators/merit/templates/merit_badge_rules.rb
|
147
|
-
- lib/generators/merit/templates/merit_point_rules.rb
|
148
|
-
- lib/generators/merit/templates/merit_rank_rules.rb
|
149
|
-
- lib/generators/merit/upgrade_generator.rb
|
150
141
|
- lib/merit.rb
|
142
|
+
- lib/merit/badge_rules_methods.rb
|
151
143
|
- lib/merit/base_target_finder.rb
|
144
|
+
- lib/merit/class_methods.rb
|
152
145
|
- lib/merit/controller_extensions.rb
|
146
|
+
- lib/merit/generators/active_record/install_generator.rb
|
147
|
+
- lib/merit/generators/active_record/merit_generator.rb
|
148
|
+
- lib/merit/generators/active_record/remove_generator.rb
|
149
|
+
- lib/merit/generators/active_record/templates/add_merit_fields_to_model.erb
|
150
|
+
- lib/merit/generators/active_record/templates/create_badges_sashes.erb
|
151
|
+
- lib/merit/generators/active_record/templates/create_merit_actions.erb
|
152
|
+
- lib/merit/generators/active_record/templates/create_merit_activity_logs.erb
|
153
|
+
- lib/merit/generators/active_record/templates/create_sashes.erb
|
154
|
+
- lib/merit/generators/active_record/templates/create_scores_and_points.erb
|
155
|
+
- lib/merit/generators/active_record/templates/remove_merit_fields_from_model.erb
|
156
|
+
- lib/merit/generators/active_record/templates/remove_merit_tables.erb
|
157
|
+
- lib/merit/generators/install_generator.rb
|
158
|
+
- lib/merit/generators/merit_generator.rb
|
159
|
+
- lib/merit/generators/remove_generator.rb
|
160
|
+
- lib/merit/generators/templates/merit.erb
|
161
|
+
- lib/merit/generators/templates/merit_badge_rules.erb
|
162
|
+
- lib/merit/generators/templates/merit_point_rules.erb
|
163
|
+
- lib/merit/generators/templates/merit_rank_rules.erb
|
153
164
|
- lib/merit/judge.rb
|
154
|
-
- lib/merit/
|
155
|
-
- lib/merit/models/active_record/
|
156
|
-
- lib/merit/models/active_record/
|
157
|
-
- lib/merit/models/active_record/
|
158
|
-
- lib/merit/models/active_record/
|
159
|
-
- lib/merit/models/active_record/
|
165
|
+
- lib/merit/models/action_concern.rb
|
166
|
+
- lib/merit/models/active_record/action.rb
|
167
|
+
- lib/merit/models/active_record/activity_log.rb
|
168
|
+
- lib/merit/models/active_record/badges_sash.rb
|
169
|
+
- lib/merit/models/active_record/sash.rb
|
170
|
+
- lib/merit/models/active_record/score.rb
|
171
|
+
- lib/merit/models/badges_sash_concern.rb
|
160
172
|
- lib/merit/models/base/badges_sash.rb
|
161
173
|
- lib/merit/models/base/sash.rb
|
162
|
-
- lib/merit/models/
|
163
|
-
- lib/merit/
|
164
|
-
- lib/merit/
|
165
|
-
- lib/merit/models/mongoid/merit/sash.rb
|
166
|
-
- lib/merit/models/mongoid/merit/score.rb
|
174
|
+
- lib/merit/models/sash_concern.rb
|
175
|
+
- lib/merit/point_rules_methods.rb
|
176
|
+
- lib/merit/rank_rules_methods.rb
|
167
177
|
- lib/merit/reputation_change_observer.rb
|
168
178
|
- lib/merit/rule.rb
|
169
|
-
- lib/merit/rules_badge_methods.rb
|
170
179
|
- lib/merit/rules_matcher.rb
|
171
|
-
- lib/merit/rules_points_methods.rb
|
172
|
-
- lib/merit/rules_rank_methods.rb
|
173
180
|
- lib/merit/sash_finder.rb
|
174
181
|
- lib/merit/target_finder.rb
|
175
182
|
- merit.gemspec
|
@@ -232,26 +239,17 @@ files:
|
|
232
239
|
- test/dummy/db/migrate/20130329224410_create_scores_and_points.rb
|
233
240
|
- test/dummy/db/migrate/20140211144001_create_addresses.rb
|
234
241
|
- test/dummy/db/migrate/20140819133931_add_target_data_to_merit_actions.rb
|
235
|
-
- test/dummy/db/migrate/20140906225844_create_players.rb
|
236
242
|
- test/dummy/db/schema.rb
|
237
243
|
- test/dummy/db/seeds.rb
|
238
244
|
- test/dummy/public/404.html
|
239
245
|
- test/dummy/public/422.html
|
240
246
|
- test/dummy/public/500.html
|
241
247
|
- test/dummy/public/favicon.ico
|
242
|
-
- test/dummy/public/javascripts/application.js
|
243
|
-
- test/dummy/public/javascripts/controls.js
|
244
|
-
- test/dummy/public/javascripts/dragdrop.js
|
245
|
-
- test/dummy/public/javascripts/effects.js
|
246
|
-
- test/dummy/public/javascripts/prototype.js
|
247
|
-
- test/dummy/public/javascripts/rails.js
|
248
248
|
- test/dummy/public/rails.js
|
249
249
|
- test/dummy/public/stylesheets/.gitkeep
|
250
250
|
- test/dummy/public/stylesheets/scaffold.css
|
251
251
|
- test/dummy/script/rails
|
252
252
|
- test/integration/navigation_test.rb
|
253
|
-
- test/orm_models/active_record.rb
|
254
|
-
- test/orm_models/mongoid.rb
|
255
253
|
- test/support/integration_case.rb
|
256
254
|
- test/test_helper.rb
|
257
255
|
- test/unit/action_test.rb
|
@@ -282,8 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
280
|
- !ruby/object:Gem::Version
|
283
281
|
version: '0'
|
284
282
|
requirements: []
|
285
|
-
|
286
|
-
rubygems_version: 2.7.6.2
|
283
|
+
rubygems_version: 3.0.3
|
287
284
|
signing_key:
|
288
285
|
specification_version: 4
|
289
286
|
summary: Reputation engine for Rails apps
|
@@ -347,26 +344,17 @@ test_files:
|
|
347
344
|
- test/dummy/db/migrate/20130329224410_create_scores_and_points.rb
|
348
345
|
- test/dummy/db/migrate/20140211144001_create_addresses.rb
|
349
346
|
- test/dummy/db/migrate/20140819133931_add_target_data_to_merit_actions.rb
|
350
|
-
- test/dummy/db/migrate/20140906225844_create_players.rb
|
351
347
|
- test/dummy/db/schema.rb
|
352
348
|
- test/dummy/db/seeds.rb
|
353
349
|
- test/dummy/public/404.html
|
354
350
|
- test/dummy/public/422.html
|
355
351
|
- test/dummy/public/500.html
|
356
352
|
- test/dummy/public/favicon.ico
|
357
|
-
- test/dummy/public/javascripts/application.js
|
358
|
-
- test/dummy/public/javascripts/controls.js
|
359
|
-
- test/dummy/public/javascripts/dragdrop.js
|
360
|
-
- test/dummy/public/javascripts/effects.js
|
361
|
-
- test/dummy/public/javascripts/prototype.js
|
362
|
-
- test/dummy/public/javascripts/rails.js
|
363
353
|
- test/dummy/public/rails.js
|
364
354
|
- test/dummy/public/stylesheets/.gitkeep
|
365
355
|
- test/dummy/public/stylesheets/scaffold.css
|
366
356
|
- test/dummy/script/rails
|
367
357
|
- test/integration/navigation_test.rb
|
368
|
-
- test/orm_models/active_record.rb
|
369
|
-
- test/orm_models/mongoid.rb
|
370
358
|
- test/support/integration_case.rb
|
371
359
|
- test/test_helper.rb
|
372
360
|
- test/unit/action_test.rb
|
data/UPGRADING.md
DELETED
@@ -1,256 +0,0 @@
|
|
1
|
-
# Main Changes / Upgrading Notes
|
2
|
-
|
3
|
-
## 2.1.0
|
4
|
-
|
5
|
-
Adds serialisation of destroyed target models so that reputation can be awarded
|
6
|
-
when the item is already deleted from the DB. For this to work you need a new
|
7
|
-
column, to add it you can run:
|
8
|
-
|
9
|
-
```
|
10
|
-
rails generate merit:upgrade
|
11
|
-
rake db:migrate
|
12
|
-
```
|
13
|
-
|
14
|
-
This is a backwards compatible addition, so if you don't add the column but
|
15
|
-
upgrade, your application should continue to work well, without the new feature.
|
16
|
-
|
17
|
-
## 2.0.0
|
18
|
-
|
19
|
-
* Removes deprecated methods: `Merit::Badge.last_granted` and
|
20
|
-
`Merit::Score.top_scored`.
|
21
|
-
* Removes `add_points` `log` parameter.
|
22
|
-
* Adds points category option.
|
23
|
-
|
24
|
-
## 1.9.0
|
25
|
-
|
26
|
-
* Deprecates `Merit::Badge.last_granted` and `Merit::Score.top_scored`.
|
27
|
-
Code can be readded to client applications following instructions in:
|
28
|
-
https://github.com/tute/merit/wiki/How-to-show-a-points-leaderboard
|
29
|
-
https://github.com/tute/merit/wiki/How-to-show-last-granted-badges
|
30
|
-
* Deprecates `add_points` `log` parameter.
|
31
|
-
|
32
|
-
## 1.8.0
|
33
|
-
|
34
|
-
* Completes implementation of observer patter for getting reputation grant
|
35
|
-
notifications to the client app. See: https://github.com/tute/merit#getting-
|
36
|
-
notifications.
|
37
|
-
* Work on mongoid adapter (not yet ready), and other internals polishing.
|
38
|
-
|
39
|
-
## 1.7.0
|
40
|
-
|
41
|
-
* Adds support for dynamic scoring
|
42
|
-
* `substract_points` is deprecated in favor of `subtract_points`. Careless
|
43
|
-
computers didn't mind my misspellings. ;-)
|
44
|
-
* JRuby and Rubinius compatibility
|
45
|
-
|
46
|
-
## 1.6.0
|
47
|
-
|
48
|
-
* Rails 4 ready.
|
49
|
-
* Adds ability to wildcard controllers like:
|
50
|
-
```ruby
|
51
|
-
grant_on '.*search#index', badge: 'searcher', multiple: true
|
52
|
-
```
|
53
|
-
* Allows custom fields to be defined on badges [97c998f]. Example:
|
54
|
-
Merit::Badge.create!({
|
55
|
-
id: 1,
|
56
|
-
name: 'best-unicorn',
|
57
|
-
custom_fields: { category: 'fantasy' }
|
58
|
-
})
|
59
|
-
|
60
|
-
## 1.5.0
|
61
|
-
|
62
|
-
* Adds `Merit::ActivityLog` join model between `Merit::Action` and
|
63
|
-
`Merit::BadgesSash` and `Merit::Score::Point` for logging purposes. Every
|
64
|
-
time a badge is granted or removed, or points are changed, a new
|
65
|
-
`ActivityLog` object gets created.
|
66
|
-
* Namespaces `Badge`, `Sash` and `BadgesSash` into `Merit` module. If your app
|
67
|
-
uses any of those class names, you should add a `Merit::` prefix.
|
68
|
-
* Removes undocumented `log:string` column from `merit_actions`.
|
69
|
-
|
70
|
-
Run the following migration to upgrade from 1.4.0:
|
71
|
-
|
72
|
-
```ruby
|
73
|
-
class UpgradeMeritTo150 < ActiveRecord::Migration
|
74
|
-
def self.up
|
75
|
-
remove_column :merit_actions, :log
|
76
|
-
create_table "merit_activity_logs", :force => true do |t|
|
77
|
-
t.integer "action_id"
|
78
|
-
t.string "related_change_type"
|
79
|
-
t.integer "related_change_id"
|
80
|
-
t.string "description"
|
81
|
-
t.datetime "created_at"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
```
|
86
|
-
|
87
|
-
## 1.4.0
|
88
|
-
|
89
|
-
* Removed `BadgesSash#set_notified!` undocumented method from code base.
|
90
|
-
* `:to` option for points and badges granting may now return an array of
|
91
|
-
objects. For instance:
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
# All user's comments earn points
|
95
|
-
score 2, to: :user_comments, on: 'comments#vote'
|
96
|
-
```
|
97
|
-
|
98
|
-
## to 1.3.0
|
99
|
-
|
100
|
-
Adds two methods meant to display a leaderboard.
|
101
|
-
|
102
|
-
* `Badge.last_granted(options = {})`. Accepts options:
|
103
|
-
* `:since_date` (`1.month.ago` by default)
|
104
|
-
* `:limit` (10 by default).
|
105
|
-
|
106
|
-
It lists last 10 badge grants in the last month, unless you change query
|
107
|
-
parameters.
|
108
|
-
|
109
|
-
* `Merit::Score.top_scored(options = {})`. Accepts options:
|
110
|
-
* `:table_name` (`users` by default)
|
111
|
-
* `:since_date` (`1.month.ago` by default)
|
112
|
-
* `:limit` (10 by default).
|
113
|
-
|
114
|
-
It lists top 10 scored objects in the last month, unless you change query
|
115
|
-
parameters.
|
116
|
-
|
117
|
-
## to 1.2.0
|
118
|
-
|
119
|
-
* `Badge#grant_to(meritable_object)` no longer exists. Use
|
120
|
-
`meritable_object.add_badge(badge_id)` (may add badges more than once).
|
121
|
-
* `Badge#delete_from(meritable_object)` no longer exists. Use
|
122
|
-
`meritable_object.rm_badge(badge_id)`.
|
123
|
-
|
124
|
-
## to 1.1.0
|
125
|
-
|
126
|
-
Code refactorings. Support for Ruby 1.8.7 has been dropped.
|
127
|
-
|
128
|
-
## to 1.0.1
|
129
|
-
|
130
|
-
Adds `Merit::Point#created_at` (`merit_score_points` table) attribute.
|
131
|
-
May already be added if upgrading from merit < 1).
|
132
|
-
|
133
|
-
## to 1.0.0
|
134
|
-
|
135
|
-
Points granting history is now logged.
|
136
|
-
|
137
|
-
* Attribute `points` and method `points=` don't exist anymore (method `points`
|
138
|
-
still works for querying number of points for a resource).
|
139
|
-
* There are new methods `add_points(num_points, log_message)` and
|
140
|
-
`remove_points(num_points, log_message)` in meritable resources to manually
|
141
|
-
change their amount of points, keeping a history log.
|
142
|
-
|
143
|
-
Run the following migration to have the new DB tables:
|
144
|
-
|
145
|
-
class UpgradeMerit < ActiveRecord::Migration
|
146
|
-
def self.up
|
147
|
-
create_table :merit_scores do |t|
|
148
|
-
t.references :sash
|
149
|
-
t.string :category, :default => 'default'
|
150
|
-
end
|
151
|
-
|
152
|
-
create_table :merit_score_points do |t|
|
153
|
-
t.references :score
|
154
|
-
t.integer :num_points, :default => 0
|
155
|
-
t.string :log
|
156
|
-
t.datetime :created_at
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def self.down
|
161
|
-
drop_table :merit_scores
|
162
|
-
drop_table :merit_score_points
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# This will create a single point entry log, with previous points granted
|
167
|
-
# to each meritable resource. Code example for a User class.
|
168
|
-
|
169
|
-
class UpgradeMeritableResources < ActiveRecord::Migration
|
170
|
-
def up
|
171
|
-
User.find_each do |user|
|
172
|
-
unless user.sash
|
173
|
-
user.sash = Sash.create!
|
174
|
-
user.save
|
175
|
-
end
|
176
|
-
|
177
|
-
user.sash.scores << Merit::Score.create
|
178
|
-
user.add_points(user.read_attribute(:points), 'Initial merit points import.')
|
179
|
-
end
|
180
|
-
remove_column :users, :points
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
If you get an `ActiveRecord::DangerousAttributeError: points` exception, you
|
185
|
-
may need to temporarily tweak your meritable model, as explained in
|
186
|
-
http://stackoverflow.com/a/1515571/356060.
|
187
|
-
|
188
|
-
|
189
|
-
## to 0.10.0
|
190
|
-
|
191
|
-
`badges_sashes` table gets a primary key `id` column. Run the following migration:
|
192
|
-
|
193
|
-
class AddIdToBadgesSashes < ActiveRecord::Migration
|
194
|
-
def self.up
|
195
|
-
add_column :badges_sashes, :id, :primary_key
|
196
|
-
end
|
197
|
-
|
198
|
-
def self.down
|
199
|
-
remove_column :badges_sashes, :id
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
`set_notified!(badge = nil, sash = nil)` no longer exists, just call `set_notified!`
|
204
|
-
over the `badge_sash` object, with no parameters.
|
205
|
-
|
206
|
-
## to 0.9.0
|
207
|
-
|
208
|
-
Adds `allow_multiple` boolean option to `Badge#grant_to` (defaults to
|
209
|
-
`false`). If you used this method to grant a badge it will now grant only if
|
210
|
-
resource doesn't have the badge.
|
211
|
-
|
212
|
-
Use `badge.grant_to resource, :allow_multiple => true` where needed.
|
213
|
-
|
214
|
-
## to 0.8.0
|
215
|
-
|
216
|
-
No changes needed. Adds Mongoid support.
|
217
|
-
|
218
|
-
## to 0.7.0
|
219
|
-
|
220
|
-
No changes needed. Adds `:multiple` boolean option to `grant_on` to grant
|
221
|
-
badge multiple times.
|
222
|
-
|
223
|
-
## to 0.6.0
|
224
|
-
|
225
|
-
<tt>MeritBadgeRules</tt>, <tt>MeritPointRules</tt> and <tt>MeritRankRules</tt>
|
226
|
-
are now namespaced into Merit module. Move and change:
|
227
|
-
|
228
|
-
<pre>
|
229
|
-
app/models/merit_{badge|point|rank}_rules.rb -> app/models/merit/{badge|point|rank}_rules.rb
|
230
|
-
</pre>
|
231
|
-
<pre>
|
232
|
-
-class Merit{Badge|Point|Rank}Rules
|
233
|
-
- include Merit::{Badge|Point|Rank}Rules
|
234
|
-
+module Merit
|
235
|
-
+ class {Badge|Point|Rank}Rules
|
236
|
-
+ include Merit::{Badge|Point|Rank}RulesMethods
|
237
|
-
</pre>
|
238
|
-
|
239
|
-
## to 0.5.0
|
240
|
-
|
241
|
-
Add <tt>log:string</tt> column to <tt>merit_actions</tt> table.
|
242
|
-
|
243
|
-
## to 0.4.0
|
244
|
-
|
245
|
-
Rankings are now integer attributes (<tt>level</tt>), they are not badges
|
246
|
-
anymore. <tt>set_rank</tt> doesn't accept <tt>badge_name</tt> anymore.
|
247
|
-
|
248
|
-
## to 0.3.0
|
249
|
-
|
250
|
-
Badges data is now stored in <tt>config/initializers/merit.rb</tt> using
|
251
|
-
<tt>ambry</tt> syntax (not in the DB anymore, as that table needed to be in
|
252
|
-
sync in all development environments).
|
253
|
-
|
254
|
-
## to 0.2.0
|
255
|
-
|
256
|
-
Added <tt>had_errors</tt> boolean attribute to <tt>merit_actions</tt> table.
|