qalam_merit 4.5.01 → 4.5.02
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/merit/models/active_record/{merit_score.rb → qalam_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/{merit_score_test.rb → qalam_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: 21d74a55846470b62cdd1e64d58c11c047e9b56482c6a9c1eacf9db5ea636fcd
|
4
|
+
data.tar.gz: 4946a1d94267fb8f4f6150db6e38150d9bd1ca2f0a4e55978ac535fdc05bae40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ce2b946fd4d7774b5bfd6af4abe87633e2ef76d6d2f04a83432d7a5d4a5950a08b78c2015af76e6f7c378a43373b99b75e78b304164289e2de58eafcc92bf5
|
7
|
+
data.tar.gz: 3297fdeaef38f6c391fd26f931e059a478772715a6ab0aa2e131bd078c65a62e33e985477487f9f542f8aa67381a1fb9493ab09d9c845e8756b80f7048c2a387
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Merit::Models::ActiveRecord
|
2
|
-
class
|
2
|
+
class QalamScore < 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::QalamScore::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::QalamScore < Merit::Models::ActiveRecord::QalamScore; end
|
25
|
+
class Merit::QalamScore::Point < Merit::Models::ActiveRecord::QalamScore::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::QalamScore'
|
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::QalamScore::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::QalamScore::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::QalamScore.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::QalamScore::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::QalamScore.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.02'
|
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::QalamScore::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::QalamScore::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::QalamScore.new
|
6
6
|
score.sash_id = 33
|
7
7
|
|
8
|
-
point = Merit::
|
8
|
+
point = Merit::QalamScore::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::QalamScore.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::QalamScore::Point.count", 1) do
|
23
23
|
@sash.add_points 5
|
24
24
|
end
|
25
|
-
score = Merit::
|
25
|
+
score = Merit::QalamScore.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::QalamScore.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::QalamScore::Point.count", 1) do
|
47
47
|
@sash.subtract_points 5
|
48
48
|
end
|
49
|
-
score = Merit::
|
49
|
+
score = Merit::QalamScore.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.02
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tute Costa
|
@@ -158,7 +158,7 @@ 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/
|
161
|
+
- lib/merit/models/active_record/qalam_score.rb
|
162
162
|
- lib/merit/models/active_record/sash.rb
|
163
163
|
- lib/merit/models/badges_sash_concern.rb
|
164
164
|
- lib/merit/models/base/badges_sash.rb
|
@@ -246,8 +246,8 @@ 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
|
250
249
|
- test/unit/merit_unit_test.rb
|
250
|
+
- test/unit/qalam_score_test.rb
|
251
251
|
- test/unit/rule_unit_test.rb
|
252
252
|
- test/unit/rules_matcher_test.rb
|
253
253
|
- test/unit/sash_finder_test.rb
|
@@ -351,8 +351,8 @@ 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
|
355
354
|
- test/unit/merit_unit_test.rb
|
355
|
+
- test/unit/qalam_score_test.rb
|
356
356
|
- test/unit/rule_unit_test.rb
|
357
357
|
- test/unit/rules_matcher_test.rb
|
358
358
|
- test/unit/sash_finder_test.rb
|