activerecord-reputation-system 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,7 @@ module ReputationSystem
|
|
25
25
|
attrs = reputation[:of] == :self ? self : self.instance_eval(of.to_s) if of.is_a?(String) || of.is_a?(Symbol)
|
26
26
|
attrs = self.instance_exec(self, &of) if of.is_a?(Proc)
|
27
27
|
attrs = [attrs] unless attrs.is_a? Array
|
28
|
-
attrs
|
28
|
+
attrs.compact
|
29
29
|
end
|
30
30
|
|
31
31
|
def evaluate_reputation_scope(scope)
|
@@ -58,11 +58,6 @@ describe ActiveRecord::Base do
|
|
58
58
|
it "should have declared default value if any" do
|
59
59
|
@answer.reputation_for(:avg_rating).should == 1
|
60
60
|
end
|
61
|
-
|
62
|
-
it "should overwrite reputation definitions if the same reputation name is declared" do
|
63
|
-
Answer.has_reputation(:avg_rating, :source => :user, :aggregated_by => :average, :init_value => 2)
|
64
|
-
Answer.new.reputation_for(:avg_rating).should == 2
|
65
|
-
end
|
66
61
|
end
|
67
62
|
end
|
68
63
|
end
|
@@ -63,11 +63,11 @@ describe ActiveRecord::Base do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should raise exception if invalid scope is given" do
|
66
|
-
lambda{@phrase.add_evaluation(:difficulty_with_scope, 1, :invalid_scope)}.should raise_error(ArgumentError)
|
66
|
+
lambda { @phrase.add_evaluation(:difficulty_with_scope, 1, :invalid_scope) }.should raise_error(ArgumentError)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should raise exception if scope is not given" do
|
70
|
-
lambda{@phrase.add_evaluation(:difficulty_with_scope, 1)}.should raise_error(ArgumentError)
|
70
|
+
lambda { @phrase.add_evaluation(:difficulty_with_scope, 1) }.should raise_error(ArgumentError)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -79,17 +79,22 @@ describe ActiveRecord::Base do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should raise exception if invalid reputation name is given" do
|
82
|
-
lambda {@question.add_evaluation(:invalid, 1, @user)}.should raise_error(ArgumentError)
|
82
|
+
lambda { @question.add_evaluation(:invalid, 1, @user) }.should raise_error(ArgumentError)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should raise exception if the same source evaluates for the same target more than once" do
|
86
86
|
@question.add_evaluation(:total_votes, 1, @user)
|
87
|
-
lambda{@question.add_evaluation(:total_votes, 1, @user)}.should raise_error
|
87
|
+
lambda { @question.add_evaluation(:total_votes, 1, @user) }.should raise_error
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should not allow the same source to add an evaluation for the same target" do
|
91
91
|
@question.add_evaluation(:total_votes, 1, @user)
|
92
|
-
lambda{@question.add_evaluation(:total_votes, 1, @user)}.should raise_error
|
92
|
+
lambda { @question.add_evaluation(:total_votes, 1, @user) }.should raise_error
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should not raise exception if some association has not been initialized along during the propagation of reputation" do
|
96
|
+
answer = Answer.create!
|
97
|
+
lambda { answer.add_evaluation(:avg_rating, 3, @user) }.should_not raise_error
|
93
98
|
end
|
94
99
|
|
95
100
|
context "With Scopes" do
|
@@ -102,11 +107,11 @@ describe ActiveRecord::Base do
|
|
102
107
|
end
|
103
108
|
|
104
109
|
it "should raise exception if invalid scope is given" do
|
105
|
-
lambda{@phrase.add_evaluation(:difficulty_with_scope, 1, :invalid_scope)}.should raise_error(ArgumentError)
|
110
|
+
lambda { @phrase.add_evaluation(:difficulty_with_scope, 1, :invalid_scope) }.should raise_error(ArgumentError)
|
106
111
|
end
|
107
112
|
|
108
113
|
it "should raise exception if scope is not given" do
|
109
|
-
lambda{@phrase.add_evaluation(:difficulty_with_scope, 1)}.should raise_error(ArgumentError)
|
114
|
+
lambda { @phrase.add_evaluation(:difficulty_with_scope, 1) }.should raise_error(ArgumentError)
|
110
115
|
end
|
111
116
|
end
|
112
117
|
end
|
@@ -155,15 +160,15 @@ describe ActiveRecord::Base do
|
|
155
160
|
end
|
156
161
|
|
157
162
|
it "should raise exception if invalid reputation name is given" do
|
158
|
-
lambda {@question.update_evaluation(:invalid, 1, @user)}.should raise_error(ArgumentError)
|
163
|
+
lambda { @question.update_evaluation(:invalid, 1, @user) }.should raise_error(ArgumentError)
|
159
164
|
end
|
160
165
|
|
161
166
|
it "should raise exception if invalid source is given" do
|
162
|
-
lambda {@question.update_evaluation(:total_votes, 1, @answer)}.should raise_error(ArgumentError)
|
167
|
+
lambda { @question.update_evaluation(:total_votes, 1, @answer) }.should raise_error(ArgumentError)
|
163
168
|
end
|
164
169
|
|
165
170
|
it "should raise exception if evaluation does not exist" do
|
166
|
-
lambda{@answer.update_evaluation(:avg_rating, 1, @user)}.should raise_error
|
171
|
+
lambda { @answer.update_evaluation(:avg_rating, 1, @user) }.should raise_error
|
167
172
|
end
|
168
173
|
|
169
174
|
context "With Scopes" do
|
@@ -179,11 +184,11 @@ describe ActiveRecord::Base do
|
|
179
184
|
end
|
180
185
|
|
181
186
|
it "should raise exception if invalid scope is given" do
|
182
|
-
lambda{@phrase.update_evaluation(:difficulty_with_scope, 5, @user, :invalid_scope)}.should raise_error(ArgumentError)
|
187
|
+
lambda { @phrase.update_evaluation(:difficulty_with_scope, 5, @user, :invalid_scope) }.should raise_error(ArgumentError)
|
183
188
|
end
|
184
189
|
|
185
190
|
it "should raise exception if scope is not given" do
|
186
|
-
lambda{@phrase.update_evaluation(:difficulty_with_scope, 5, @user)}.should raise_error(ArgumentError)
|
191
|
+
lambda { @phrase.update_evaluation(:difficulty_with_scope, 5, @user) }.should raise_error(ArgumentError)
|
187
192
|
end
|
188
193
|
end
|
189
194
|
end
|
@@ -199,15 +204,15 @@ describe ActiveRecord::Base do
|
|
199
204
|
end
|
200
205
|
|
201
206
|
it "should raise exception if invalid reputation name is given" do
|
202
|
-
lambda {@question.delete_evaluation!(:invalid, @user)}.should raise_error(ArgumentError)
|
207
|
+
lambda { @question.delete_evaluation!(:invalid, @user) }.should raise_error(ArgumentError)
|
203
208
|
end
|
204
209
|
|
205
210
|
it "should raise exception if invalid source is given" do
|
206
|
-
lambda {@question.delete_evaluation!(:total_votes, @answer)}.should raise_error(ArgumentError)
|
211
|
+
lambda { @question.delete_evaluation!(:total_votes, @answer) }.should raise_error(ArgumentError)
|
207
212
|
end
|
208
213
|
|
209
214
|
it "should raise exception if evaluation does not exist" do
|
210
|
-
lambda{@answer.delete_evaluation!(:avg_rating, @user)}.should raise_error
|
215
|
+
lambda { @answer.delete_evaluation!(:avg_rating, @user) }.should raise_error
|
211
216
|
end
|
212
217
|
|
213
218
|
context "With Scopes" do
|
@@ -223,11 +228,11 @@ describe ActiveRecord::Base do
|
|
223
228
|
end
|
224
229
|
|
225
230
|
it "should raise exception if invalid scope is given" do
|
226
|
-
lambda{@phrase.delete_evaluation!(:difficulty_with_scope, @user, :invalid_scope)}.should raise_error(ArgumentError)
|
231
|
+
lambda { @phrase.delete_evaluation!(:difficulty_with_scope, @user, :invalid_scope) }.should raise_error(ArgumentError)
|
227
232
|
end
|
228
233
|
|
229
234
|
it "should raise exception if scope is not given" do
|
230
|
-
lambda{@phrase.delete_evaluation!(:difficulty_with_scope, @user)}.should raise_error(ArgumentError)
|
235
|
+
lambda { @phrase.delete_evaluation!(:difficulty_with_scope, @user) }.should raise_error(ArgumentError)
|
231
236
|
end
|
232
237
|
end
|
233
238
|
end
|
@@ -243,7 +248,7 @@ describe ActiveRecord::Base do
|
|
243
248
|
end
|
244
249
|
|
245
250
|
it "should raise exception if invalid reputation name is given" do
|
246
|
-
lambda {@question.delete_evaluation(:invalid, @user)}.should raise_error(ArgumentError)
|
251
|
+
lambda { @question.delete_evaluation(:invalid, @user) }.should raise_error(ArgumentError)
|
247
252
|
end
|
248
253
|
|
249
254
|
it "should return nil if evaluation does not exist" do
|
@@ -263,11 +268,11 @@ describe ActiveRecord::Base do
|
|
263
268
|
end
|
264
269
|
|
265
270
|
it "should raise exception if invalid scope is given" do
|
266
|
-
lambda{@phrase.delete_evaluation(:difficulty_with_scope, @user, :invalid_scope)}.should raise_error(ArgumentError)
|
271
|
+
lambda { @phrase.delete_evaluation(:difficulty_with_scope, @user, :invalid_scope) }.should raise_error(ArgumentError)
|
267
272
|
end
|
268
273
|
|
269
274
|
it "should raise exception if scope is not given" do
|
270
|
-
lambda{@phrase.delete_evaluation(:difficulty_with_scope, @user)}.should raise_error(ArgumentError)
|
275
|
+
lambda { @phrase.delete_evaluation(:difficulty_with_scope, @user) }.should raise_error(ArgumentError)
|
271
276
|
end
|
272
277
|
end
|
273
278
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-reputation-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 3
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 1
|
8
|
-
- 5
|
9
|
-
- 0
|
10
|
-
version: 1.5.0
|
5
|
+
version: 1.5.1
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Katsuya Noguchi
|
@@ -15,98 +10,73 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2012-
|
13
|
+
date: 2012-10-04 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
21
17
|
prerelease: false
|
22
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
19
|
none: false
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
23
|
version: "0"
|
31
24
|
type: :development
|
32
|
-
name: activerecord
|
33
25
|
version_requirements: *id001
|
34
26
|
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
35
28
|
prerelease: false
|
36
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
30
|
none: false
|
38
31
|
requirements:
|
39
32
|
- - ">="
|
40
33
|
- !ruby/object:Gem::Version
|
41
|
-
hash: 49
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
- 8
|
45
|
-
- 7
|
46
34
|
version: 0.8.7
|
47
35
|
type: :development
|
48
|
-
name: rake
|
49
36
|
version_requirements: *id002
|
50
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
51
39
|
prerelease: false
|
52
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
41
|
none: false
|
54
42
|
requirements:
|
55
43
|
- - ~>
|
56
44
|
- !ruby/object:Gem::Version
|
57
|
-
hash: 19
|
58
|
-
segments:
|
59
|
-
- 2
|
60
|
-
- 8
|
61
45
|
version: "2.8"
|
62
46
|
type: :development
|
63
|
-
name: rspec
|
64
47
|
version_requirements: *id003
|
65
48
|
- !ruby/object:Gem::Dependency
|
49
|
+
name: rdoc
|
66
50
|
prerelease: false
|
67
51
|
requirement: &id004 !ruby/object:Gem::Requirement
|
68
52
|
none: false
|
69
53
|
requirements:
|
70
54
|
- - ">="
|
71
55
|
- !ruby/object:Gem::Version
|
72
|
-
hash: 3
|
73
|
-
segments:
|
74
|
-
- 0
|
75
56
|
version: "0"
|
76
57
|
type: :development
|
77
|
-
name: rdoc
|
78
58
|
version_requirements: *id004
|
79
59
|
- !ruby/object:Gem::Dependency
|
60
|
+
name: database_cleaner
|
80
61
|
prerelease: false
|
81
62
|
requirement: &id005 !ruby/object:Gem::Requirement
|
82
63
|
none: false
|
83
64
|
requirements:
|
84
65
|
- - ~>
|
85
66
|
- !ruby/object:Gem::Version
|
86
|
-
hash: 1
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
- 7
|
90
|
-
- 1
|
91
67
|
version: 0.7.1
|
92
68
|
type: :development
|
93
|
-
name: database_cleaner
|
94
69
|
version_requirements: *id005
|
95
70
|
- !ruby/object:Gem::Dependency
|
71
|
+
name: sqlite3
|
96
72
|
prerelease: false
|
97
73
|
requirement: &id006 !ruby/object:Gem::Requirement
|
98
74
|
none: false
|
99
75
|
requirements:
|
100
76
|
- - ~>
|
101
77
|
- !ruby/object:Gem::Version
|
102
|
-
hash: 17
|
103
|
-
segments:
|
104
|
-
- 1
|
105
|
-
- 3
|
106
|
-
- 5
|
107
78
|
version: 1.3.5
|
108
79
|
type: :development
|
109
|
-
name: sqlite3
|
110
80
|
version_requirements: *id006
|
111
81
|
description: ActiveRecord Reputation System gem allows rails apps to compute and publish reputation scores for active record models.
|
112
82
|
email:
|
@@ -165,23 +135,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
135
|
requirements:
|
166
136
|
- - ">="
|
167
137
|
- !ruby/object:Gem::Version
|
168
|
-
hash: 3
|
169
|
-
segments:
|
170
|
-
- 0
|
171
138
|
version: "0"
|
172
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
140
|
none: false
|
174
141
|
requirements:
|
175
142
|
- - ">="
|
176
143
|
- !ruby/object:Gem::Version
|
177
|
-
hash: 3
|
178
|
-
segments:
|
179
|
-
- 0
|
180
144
|
version: "0"
|
181
145
|
requirements: []
|
182
146
|
|
183
147
|
rubyforge_project:
|
184
|
-
rubygems_version: 1.8.
|
148
|
+
rubygems_version: 1.8.10
|
185
149
|
signing_key:
|
186
150
|
specification_version: 3
|
187
151
|
summary: ActiveRecord Reputation System gem allows rails apps to compute and publish reputation scores for active record models
|