qalam_merit 4.5.00 → 4.5.01
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/merit/generators/merit_generator.rb +1 -1
- data/lib/merit/models/active_record/{score.rb → merit_score.rb} +4 -4
- data/lib/merit/models/active_record/sash.rb +2 -2
- data/lib/merit/models/base/sash.rb +2 -2
- data/lib/merit/models/sash_concern.rb +2 -2
- data/qalam_merit.gemspec +1 -1
- data/test/integration/navigation_test.rb +2 -2
- data/test/unit/{score_test.rb → merit_score_test.rb} +2 -2
- data/test/unit/sash_test.rb +6 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a062b61ba12835e8cc9ea7eeed4eb6b94eccaa7fdd4323cdc8efd226e5331aa7
|
4
|
+
data.tar.gz: b91428baa833ca06913fe27c2c54623db498e5a0a051c368fc3b3cb509e18971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a3e6f2eceff7d5971e4e8ebfc71a71d7cc553e76ca7bb07c5c51e071bbeeefe782fe7d6be7c27ccab85fb514a7de83a2cf1246bd081246d6ddda5c79ab0e79a
|
7
|
+
data.tar.gz: dff4b30e28a4f91bbc49f661fbc55aee612ab8ae849e429f545089690b582e533c993b39f3b01ef0f9a2d41283c290660007ffb383feb0f94f1d39f62b52377b
|
@@ -9,7 +9,7 @@ module Merit
|
|
9
9
|
if model_exists?
|
10
10
|
inject_into_class(model_path, class_name, " ### END ###\n\n")
|
11
11
|
inject_into_class(model_path, class_name, " has_many :created_badges, class_name: 'Merit::Badge'\n")
|
12
|
-
inject_into_class(model_path, class_name, " belongs_to :sash, foreign_key: 'sash_id', class_name: 'Merit::
|
12
|
+
inject_into_class(model_path, class_name, " belongs_to :sash, foreign_key: 'sash_id', class_name: 'Merit::Sash'\n")
|
13
13
|
inject_into_class(model_path, class_name, " has_merit\n")
|
14
14
|
inject_into_class(model_path, class_name, " ### QALAM_MERIT ###\n")
|
15
15
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Merit::Models::ActiveRecord
|
2
|
-
class
|
2
|
+
class MeritScore < ActiveRecord::Base
|
3
3
|
self.table_name = :merit_scores
|
4
4
|
belongs_to :sash
|
5
5
|
has_many :score_points,
|
6
6
|
dependent: :destroy,
|
7
|
-
class_name: 'Merit::
|
7
|
+
class_name: 'Merit::MeritScore::Point'
|
8
8
|
|
9
9
|
def points
|
10
10
|
score_points.group(:score_id).sum(:num_points).values.first || 0
|
@@ -21,5 +21,5 @@ module Merit::Models::ActiveRecord
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
class Merit::
|
25
|
-
class Merit::
|
24
|
+
class Merit::MeritScore < Merit::Models::ActiveRecord::Score; end
|
25
|
+
class Merit::MeritScore::Point < Merit::Models::ActiveRecord::Score::Point; end
|
@@ -11,7 +11,7 @@ module Merit::Models::ActiveRecord
|
|
11
11
|
|
12
12
|
has_many :badges_sashes, dependent: :destroy
|
13
13
|
has_many :badges, through: :badges_sashes, source: :badge
|
14
|
-
has_many :scores, dependent: :destroy, class_name: 'Merit::
|
14
|
+
has_many :scores, dependent: :destroy, class_name: 'Merit::MeritScore'
|
15
15
|
|
16
16
|
after_create :create_scores
|
17
17
|
|
@@ -20,7 +20,7 @@ module Merit::Models::ActiveRecord
|
|
20
20
|
# @param category [String] The category
|
21
21
|
# @return [ActiveRecord::Relation] containing the points
|
22
22
|
def score_points(options = {})
|
23
|
-
scope = Merit::
|
23
|
+
scope = Merit::MeritScore::Point
|
24
24
|
.joins(:score)
|
25
25
|
.where('merit_scores.sash_id = ?', id)
|
26
26
|
if (category = options[:category])
|
@@ -32,7 +32,7 @@ module Merit
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def add_points(num_points, options = {})
|
35
|
-
point = Merit::
|
35
|
+
point = Merit::MeritScore::Point.new
|
36
36
|
point.num_points = num_points
|
37
37
|
scores
|
38
38
|
.where(category: options[:category] || 'default')
|
@@ -48,7 +48,7 @@ module Merit
|
|
48
48
|
private
|
49
49
|
|
50
50
|
def create_scores
|
51
|
-
scores << Merit::
|
51
|
+
scores << Merit::MeritScore.create
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -31,7 +31,7 @@ module Merit::Models
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def add_points(num_points, options = {})
|
34
|
-
point = Merit::
|
34
|
+
point = Merit::MeritScore::Point.new
|
35
35
|
point.num_points = num_points
|
36
36
|
scores
|
37
37
|
.where(category: options[:category] || 'default')
|
@@ -47,7 +47,7 @@ module Merit::Models
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def create_scores
|
50
|
-
scores << Merit::
|
50
|
+
scores << Merit::MeritScore.create
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/qalam_merit.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.files = `git ls-files`.split("\n").reject{|f| f =~ /^\./ }
|
7
7
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
8
8
|
s.license = 'MIT'
|
9
|
-
s.version = '4.5.
|
9
|
+
s.version = '4.5.01'
|
10
10
|
s.authors = ["Tute Costa", "Ahmed Abdelhamid"]
|
11
11
|
s.email = ['tutecosta@gmail.com', 'a.hamid@nezam.io']
|
12
12
|
|
@@ -107,12 +107,12 @@ class NavigationTest < ActionDispatch::IntegrationTest
|
|
107
107
|
assert user.badges.empty?, 'Should not have badges'
|
108
108
|
|
109
109
|
assert_equal 0, user.points
|
110
|
-
assert_equal 0, Merit::
|
110
|
+
assert_equal 0, Merit::MeritScore::Point.count
|
111
111
|
user.add_points 15
|
112
112
|
assert_equal 15, user.points
|
113
113
|
user.subtract_points 15
|
114
114
|
assert_equal 0, user.points
|
115
|
-
assert_equal 2, Merit::
|
115
|
+
assert_equal 2, Merit::MeritScore::Point.count
|
116
116
|
|
117
117
|
# Tenth comment with errors doesn't change reputation
|
118
118
|
badges = user.reload.badges
|
@@ -2,10 +2,10 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
describe Merit::Score do
|
4
4
|
it 'Point#sash_id delegates to Score' do
|
5
|
-
score = Merit::
|
5
|
+
score = Merit::MeritScore.new
|
6
6
|
score.sash_id = 33
|
7
7
|
|
8
|
-
point = Merit::
|
8
|
+
point = Merit::MeritScore::Point.new
|
9
9
|
point.score = score
|
10
10
|
|
11
11
|
_(point.sash_id).must_be :==, score.sash_id
|
data/test/unit/sash_test.rb
CHANGED
@@ -10,7 +10,7 @@ class SashTest < ActiveSupport::TestCase
|
|
10
10
|
describe "when category specified" do
|
11
11
|
it "should create a new Point with specified category" do
|
12
12
|
@sash.add_points 5, category: @custom_category
|
13
|
-
score = Merit::
|
13
|
+
score = Merit::MeritScore.last
|
14
14
|
point = score.score_points.last
|
15
15
|
|
16
16
|
assert_equal point.num_points, 5
|
@@ -19,10 +19,10 @@ class SashTest < ActiveSupport::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should create a new Point in category default with specified number of points" do
|
22
|
-
assert_difference("Merit::
|
22
|
+
assert_difference("Merit::MeritScore::Point.count", 1) do
|
23
23
|
@sash.add_points 5
|
24
24
|
end
|
25
|
-
score = Merit::
|
25
|
+
score = Merit::MeritScore.last
|
26
26
|
point = score.score_points.last
|
27
27
|
|
28
28
|
assert_equal point.num_points, 5
|
@@ -34,7 +34,7 @@ class SashTest < ActiveSupport::TestCase
|
|
34
34
|
describe "when category specified" do
|
35
35
|
it "should create a new Point with specified category" do
|
36
36
|
@sash.subtract_points 5, category: @custom_category
|
37
|
-
score = Merit::
|
37
|
+
score = Merit::MeritScore.last
|
38
38
|
point = score.score_points.last
|
39
39
|
|
40
40
|
assert_equal point.num_points, -5
|
@@ -43,10 +43,10 @@ class SashTest < ActiveSupport::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should create a new Point in category default with inverse of specified number of points" do
|
46
|
-
assert_difference("Merit::
|
46
|
+
assert_difference("Merit::MeritScore::Point.count", 1) do
|
47
47
|
@sash.subtract_points 5
|
48
48
|
end
|
49
|
-
score = Merit::
|
49
|
+
score = Merit::MeritScore.last
|
50
50
|
point = score.score_points.last
|
51
51
|
|
52
52
|
assert_equal point.num_points, -5
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qalam_merit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.5.
|
4
|
+
version: 4.5.01
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tute Costa
|
@@ -158,8 +158,8 @@ files:
|
|
158
158
|
- lib/merit/models/active_record/action.rb
|
159
159
|
- lib/merit/models/active_record/activity_log.rb
|
160
160
|
- lib/merit/models/active_record/badges_sash.rb
|
161
|
+
- lib/merit/models/active_record/merit_score.rb
|
161
162
|
- lib/merit/models/active_record/sash.rb
|
162
|
-
- lib/merit/models/active_record/score.rb
|
163
163
|
- lib/merit/models/badges_sash_concern.rb
|
164
164
|
- lib/merit/models/base/badges_sash.rb
|
165
165
|
- lib/merit/models/base/sash.rb
|
@@ -246,12 +246,12 @@ files:
|
|
246
246
|
- test/test_helper.rb
|
247
247
|
- test/unit/action_test.rb
|
248
248
|
- test/unit/base_target_finder_test.rb
|
249
|
+
- test/unit/merit_score_test.rb
|
249
250
|
- test/unit/merit_unit_test.rb
|
250
251
|
- test/unit/rule_unit_test.rb
|
251
252
|
- test/unit/rules_matcher_test.rb
|
252
253
|
- test/unit/sash_finder_test.rb
|
253
254
|
- test/unit/sash_test.rb
|
254
|
-
- test/unit/score_test.rb
|
255
255
|
- test/unit/target_finder_test.rb
|
256
256
|
homepage: https://github.com/merit-gem/merit
|
257
257
|
licenses:
|
@@ -351,10 +351,10 @@ test_files:
|
|
351
351
|
- test/test_helper.rb
|
352
352
|
- test/unit/action_test.rb
|
353
353
|
- test/unit/base_target_finder_test.rb
|
354
|
+
- test/unit/merit_score_test.rb
|
354
355
|
- test/unit/merit_unit_test.rb
|
355
356
|
- test/unit/rule_unit_test.rb
|
356
357
|
- test/unit/rules_matcher_test.rb
|
357
358
|
- test/unit/sash_finder_test.rb
|
358
359
|
- test/unit/sash_test.rb
|
359
|
-
- test/unit/score_test.rb
|
360
360
|
- test/unit/target_finder_test.rb
|