voteable_mongoid 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +19 -0
- data/lib/voteable_mongoid/version.rb +1 -1
- data/lib/voteable_mongoid/voteable/stats.rb +21 -29
- data/lib/voteable_mongoid/voteable/votes.rb +21 -0
- data/lib/voteable_mongoid/voteable.rb +44 -52
- data/lib/voteable_mongoid/voter.rb +19 -3
- data/lib/voteable_mongoid.rb +2 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/voteable_mongoid/voteable_spec.rb +6 -18
- data/spec/voteable_mongoid/voter_spec.rb +8 -0
- metadata +6 -26
- data/doc/Mongoid/Voteable/Stats.html +0 -733
- data/doc/Mongoid/Voteable.html +0 -505
- data/doc/Mongoid/Voter.html +0 -682
- data/doc/Mongoid.html +0 -93
- data/doc/Rails/VoteableMongoid/Railtie.html +0 -110
- data/doc/Rails/VoteableMongoid.html +0 -101
- data/doc/Rails.html +0 -101
- data/doc/VoteableMongoid.html +0 -94
- data/doc/_index.html +0 -164
- data/doc/class_list.html +0 -36
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -53
- data/doc/css/style.css +0 -318
- data/doc/file.README.html +0 -172
- data/doc/file_list.html +0 -38
- data/doc/frames.html +0 -13
- data/doc/index.html +0 -172
- data/doc/js/app.js +0 -203
- data/doc/js/full_list.js +0 -149
- data/doc/js/jquery.js +0 -16
- data/doc/method_list.html +0 -187
- data/doc/top-level-namespace.html +0 -88
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
== 0.6.0
|
2
|
+
* Minimize vote data store (using short field names votes.u, votes.d, votes.c ...)
|
3
|
+
* Add Voter#up_votees, Voter#down_votees
|
4
|
+
* Remove index and scope from statistic module. User have to add indexes and scopes manually (see https://github.com/vinova/simple_qa/blob/master/app/models/question.rb)
|
5
|
+
* Bug fixes
|
6
|
+
|
7
|
+
== 0.5.0
|
8
|
+
* Rename vote_point to voteable
|
9
|
+
|
10
|
+
== 0.4.5
|
11
|
+
* Can use rake db:mongoid:voteable:remake_stats in Rails apps
|
12
|
+
* Use mongoid 2.0.0
|
13
|
+
|
14
|
+
== 0.4.4
|
15
|
+
* Add up_votes_count, down_votes_count
|
16
|
+
* Re-generate vote statistic data (counters and point)
|
17
|
+
|
18
|
+
== 0.4.3
|
19
|
+
* Wrap vote data in voteable namespace (voteable.up_voters_id, voteable.down_voters_ids, voteable.votes_count ...)
|
@@ -3,36 +3,24 @@ module Mongoid
|
|
3
3
|
module Stats
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
included do
|
7
|
-
index 'voteable.up_votes_count'
|
8
|
-
index 'voteable.down_votes_count'
|
9
|
-
index 'voteable.votes_count'
|
10
|
-
index 'voteable.votes_point'
|
11
|
-
|
12
|
-
scope :most_up_voted, order_by(['voteable.up_votes_count', :desc])
|
13
|
-
scope :most_down_voted, order_by(['voteable.down_votes_count', :desc])
|
14
|
-
scope :most_voted, order_by(['voteable.votes_count', :desc])
|
15
|
-
scope :best_voted, order_by(['voteable.votes_point', :desc])
|
16
|
-
end
|
17
|
-
|
18
6
|
# Get the number of up votes
|
19
7
|
def up_votes_count
|
20
|
-
|
8
|
+
votes.try(:[], 'uc') || 0
|
21
9
|
end
|
22
10
|
|
23
11
|
# Get the number of down votes
|
24
12
|
def down_votes_count
|
25
|
-
|
13
|
+
votes.try(:[], 'dc') || 0
|
26
14
|
end
|
27
15
|
|
28
16
|
# Get the number of votes
|
29
17
|
def votes_count
|
30
|
-
|
18
|
+
votes.try(:[], 'c') || 0
|
31
19
|
end
|
32
20
|
|
33
21
|
# Get the votes point
|
34
22
|
def votes_point
|
35
|
-
|
23
|
+
votes.try(:[], 'p') || 0
|
36
24
|
end
|
37
25
|
|
38
26
|
# Re-generate vote counters and vote points
|
@@ -42,11 +30,11 @@ module Mongoid
|
|
42
30
|
end
|
43
31
|
|
44
32
|
def self.remake_stats(log)
|
45
|
-
|
33
|
+
VOTEABLE.each do |class_name, value_point|
|
46
34
|
klass = class_name.constantize
|
47
35
|
klass_value_point = value_point[class_name]
|
48
36
|
puts "Generating stats for #{class_name}" if log
|
49
|
-
klass.
|
37
|
+
klass.all.each{ |doc|
|
50
38
|
doc.remake_stats(klass_value_point)
|
51
39
|
}
|
52
40
|
end
|
@@ -55,12 +43,14 @@ module Mongoid
|
|
55
43
|
def remake_stats(value_point)
|
56
44
|
up_count = up_voter_ids.length
|
57
45
|
down_count = down_voter_ids.length
|
58
|
-
|
46
|
+
|
47
|
+
# puts self, votes.inspect # DEBUG
|
48
|
+
|
59
49
|
update_attributes(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
50
|
+
UP_VOTES_COUNT => up_count,
|
51
|
+
DOWN_VOTES_COUNT => down_count,
|
52
|
+
VOTES_COUNT => up_count + down_count,
|
53
|
+
VOTES_POINT => value_point[:up]*up_count + value_point[:down]*down_count
|
64
54
|
)
|
65
55
|
end
|
66
56
|
|
@@ -73,7 +63,7 @@ module Mongoid
|
|
73
63
|
parent_class = parent_class_name.constantize
|
74
64
|
foreign_key = relation_metadata.foreign_key
|
75
65
|
puts "Updating stats for #{class_name} > #{parent_class_name}" if log
|
76
|
-
klass.
|
66
|
+
klass.all.each{ |doc|
|
77
67
|
doc.update_parent_stats(parent_class, foreign_key, parent_value_point)
|
78
68
|
}
|
79
69
|
end
|
@@ -90,17 +80,19 @@ module Mongoid
|
|
90
80
|
return if up_count == 0 && down_count == 0
|
91
81
|
|
92
82
|
inc_options = {
|
93
|
-
|
83
|
+
VOTES_POINT => value_point[:up]*up_count + value_point[:down]*down_count
|
94
84
|
}
|
95
|
-
|
85
|
+
|
96
86
|
unless value_point[:update_counters] == false
|
97
87
|
inc_options.merge!(
|
98
|
-
|
99
|
-
|
100
|
-
|
88
|
+
VOTES_COUNT => up_count + down_count,
|
89
|
+
UP_VOTES_COUNT => up_count,
|
90
|
+
DOWN_VOTES_COUNT => down_count
|
101
91
|
)
|
102
92
|
end
|
103
93
|
|
94
|
+
# puts parent_id, inc_options.inspect # DEBUG
|
95
|
+
|
104
96
|
parent_class.collection.update(
|
105
97
|
{ :_id => parent_id },
|
106
98
|
{ '$inc' => inc_options }
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mongoid
|
2
|
+
module Voteable
|
3
|
+
UP_VOTER_IDS = 'votes.u'
|
4
|
+
DOWN_VOTER_IDS = 'votes.d'
|
5
|
+
UP_VOTES_COUNT = 'votes.uc'
|
6
|
+
DOWN_VOTES_COUNT = 'votes.dc'
|
7
|
+
VOTES_COUNT = 'votes.c'
|
8
|
+
VOTES_POINT = 'votes.p'
|
9
|
+
|
10
|
+
class Votes
|
11
|
+
include Mongoid::Document
|
12
|
+
|
13
|
+
field :u, :type => Array
|
14
|
+
field :d, :type => Array
|
15
|
+
field :uc, :type => Integer, :default => 0
|
16
|
+
field :dc, :type => Integer, :default => 0
|
17
|
+
field :c, :type => Integer, :default => 0
|
18
|
+
field :p, :type => Integer, :default => 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -7,13 +7,10 @@ module Mongoid
|
|
7
7
|
VOTEABLE = {}
|
8
8
|
|
9
9
|
included do
|
10
|
+
include Mongoid::Document
|
10
11
|
include Mongoid::Voteable::Stats
|
12
|
+
field :votes, :type => Mongoid::Voteable::Votes
|
11
13
|
|
12
|
-
def self.voteable_data_only
|
13
|
-
foreign_keys = relations.values.map{ |meta| meta.try(:foreign_key) }.compact
|
14
|
-
only(foreign_keys + %w[voteable])
|
15
|
-
end
|
16
|
-
|
17
14
|
# Set vote point for each up (down) vote on an object of this class
|
18
15
|
#
|
19
16
|
# @param [Hash] options a hash containings:
|
@@ -54,16 +51,16 @@ module Mongoid
|
|
54
51
|
|
55
52
|
if options[:revote]
|
56
53
|
if value == :up
|
57
|
-
positive_voter_ids =
|
58
|
-
negative_voter_ids =
|
59
|
-
positive_votes_count =
|
60
|
-
negative_votes_count =
|
54
|
+
positive_voter_ids = UP_VOTER_IDS
|
55
|
+
negative_voter_ids = DOWN_VOTER_IDS
|
56
|
+
positive_votes_count = UP_VOTES_COUNT
|
57
|
+
negative_votes_count = DOWN_VOTES_COUNT
|
61
58
|
point_delta = value_point[:up] - value_point[:down]
|
62
59
|
else
|
63
|
-
positive_voter_ids =
|
64
|
-
negative_voter_ids =
|
65
|
-
positive_votes_count =
|
66
|
-
negative_votes_count =
|
60
|
+
positive_voter_ids = DOWN_VOTER_IDS
|
61
|
+
negative_voter_ids = UP_VOTER_IDS
|
62
|
+
positive_votes_count = DOWN_VOTES_COUNT
|
63
|
+
negative_votes_count = UP_VOTES_COUNT
|
67
64
|
point_delta = -value_point[:up] + value_point[:down]
|
68
65
|
end
|
69
66
|
|
@@ -79,7 +76,7 @@ module Mongoid
|
|
79
76
|
'$inc' => {
|
80
77
|
positive_votes_count => +1,
|
81
78
|
negative_votes_count => -1,
|
82
|
-
|
79
|
+
VOTES_POINT => point_delta
|
83
80
|
}
|
84
81
|
}, {
|
85
82
|
:safe => true
|
@@ -87,13 +84,13 @@ module Mongoid
|
|
87
84
|
|
88
85
|
elsif options[:unvote]
|
89
86
|
if value == :up
|
90
|
-
positive_voter_ids =
|
91
|
-
negative_voter_ids =
|
92
|
-
positive_votes_count =
|
87
|
+
positive_voter_ids = UP_VOTER_IDS
|
88
|
+
negative_voter_ids = DOWN_VOTER_IDS
|
89
|
+
positive_votes_count = UP_VOTES_COUNT
|
93
90
|
else
|
94
|
-
positive_voter_ids =
|
95
|
-
negative_voter_ids =
|
96
|
-
positive_votes_count =
|
91
|
+
positive_voter_ids = DOWN_VOTER_IDS
|
92
|
+
negative_voter_ids = UP_VOTER_IDS
|
93
|
+
positive_votes_count = DOWN_VOTES_COUNT
|
97
94
|
end
|
98
95
|
|
99
96
|
# Check if voter_id did a vote with value for votee_id
|
@@ -107,8 +104,8 @@ module Mongoid
|
|
107
104
|
'$pull' => { positive_voter_ids => voter_id },
|
108
105
|
'$inc' => {
|
109
106
|
positive_votes_count => -1,
|
110
|
-
|
111
|
-
|
107
|
+
VOTES_COUNT => -1,
|
108
|
+
VOTES_POINT => -value_point[value]
|
112
109
|
}
|
113
110
|
}, {
|
114
111
|
:safe => true
|
@@ -116,25 +113,25 @@ module Mongoid
|
|
116
113
|
|
117
114
|
else # new vote
|
118
115
|
if value.to_sym == :up
|
119
|
-
positive_voter_ids =
|
120
|
-
positive_votes_count =
|
116
|
+
positive_voter_ids = UP_VOTER_IDS
|
117
|
+
positive_votes_count = UP_VOTES_COUNT
|
121
118
|
else
|
122
|
-
positive_voter_ids =
|
123
|
-
positive_votes_count =
|
119
|
+
positive_voter_ids = DOWN_VOTER_IDS
|
120
|
+
positive_votes_count = DOWN_VOTES_COUNT
|
124
121
|
end
|
125
122
|
|
126
123
|
update_result = collection.update({
|
127
124
|
# Validate voter_id did not vote for votee_id yet
|
128
125
|
:_id => votee_id,
|
129
|
-
|
130
|
-
|
126
|
+
UP_VOTER_IDS => { '$ne' => voter_id },
|
127
|
+
DOWN_VOTER_IDS => { '$ne' => voter_id }
|
131
128
|
}, {
|
132
129
|
# then update
|
133
130
|
'$push' => { positive_voter_ids => voter_id },
|
134
131
|
'$inc' => {
|
135
|
-
|
132
|
+
VOTES_COUNT => +1,
|
136
133
|
positive_votes_count => +1,
|
137
|
-
|
134
|
+
VOTES_POINT => value_point[value] }
|
138
135
|
}, {
|
139
136
|
:safe => true
|
140
137
|
})
|
@@ -149,7 +146,7 @@ module Mongoid
|
|
149
146
|
VOTEABLE[klass].each do |class_name, value_point|
|
150
147
|
# For other class in VOTEABLE options, if is parent of current class
|
151
148
|
next unless relation_metadata = relations[class_name.underscore]
|
152
|
-
next unless votee ||= options[:votee] ||
|
149
|
+
next unless votee ||= options[:votee] || find(options[:votee_id])
|
153
150
|
# If can find current votee foreign_key value for that class
|
154
151
|
next unless foreign_key_value = votee.read_attribute(relation_metadata.foreign_key)
|
155
152
|
|
@@ -157,36 +154,36 @@ module Mongoid
|
|
157
154
|
|
158
155
|
if options[:revote]
|
159
156
|
if value == :up
|
160
|
-
inc_options[
|
157
|
+
inc_options[VOTES_POINT] = value_point[:up] - value_point[:down]
|
161
158
|
unless value_point[:update_counters] == false
|
162
|
-
inc_options[
|
163
|
-
inc_options[
|
159
|
+
inc_options[UP_VOTES_COUNT] = +1
|
160
|
+
inc_options[DOWN_VOTES_COUNT] = -1
|
164
161
|
end
|
165
162
|
else
|
166
|
-
inc_options[
|
163
|
+
inc_options[VOTES_POINT] = -value_point[:up] + value_point[:down]
|
167
164
|
unless value_point[:update_counters] == false
|
168
|
-
inc_options[
|
169
|
-
inc_options[
|
165
|
+
inc_options[UP_VOTES_COUNT] = -1
|
166
|
+
inc_options[DOWN_VOTES_COUNT] = +1
|
170
167
|
end
|
171
168
|
end
|
172
169
|
elsif options[:unvote]
|
173
|
-
inc_options[
|
170
|
+
inc_options[VOTES_POINT] = -value_point[value]
|
174
171
|
unless value_point[:update_counters] == false
|
175
|
-
inc_options[
|
172
|
+
inc_options[VOTES_COUNT] = -1
|
176
173
|
if value == :up
|
177
|
-
inc_options[
|
174
|
+
inc_options[UP_VOTES_COUNT] = -1
|
178
175
|
else
|
179
|
-
inc_options[
|
176
|
+
inc_options[DOWN_VOTES_COUNT] = -1
|
180
177
|
end
|
181
178
|
end
|
182
179
|
else # new vote
|
183
|
-
inc_options[
|
180
|
+
inc_options[VOTES_POINT] = value_point[value]
|
184
181
|
unless value_point[:update_counters] == false
|
185
|
-
inc_options[
|
182
|
+
inc_options[VOTES_COUNT] = 1
|
186
183
|
if value == :up
|
187
|
-
inc_options[
|
184
|
+
inc_options[UP_VOTES_COUNT] = 1
|
188
185
|
else
|
189
|
-
inc_options[
|
186
|
+
inc_options[DOWN_VOTES_COUNT] = 1
|
190
187
|
end
|
191
188
|
end
|
192
189
|
end
|
@@ -231,17 +228,12 @@ module Mongoid
|
|
231
228
|
|
232
229
|
# Array of up voter ids
|
233
230
|
def up_voter_ids
|
234
|
-
|
231
|
+
votes.try(:[], 'u') || []
|
235
232
|
end
|
236
233
|
|
237
234
|
# Array of down voter ids
|
238
235
|
def down_voter_ids
|
239
|
-
|
236
|
+
votes.try(:[], 'd') || []
|
240
237
|
end
|
241
|
-
|
242
|
-
def voteable
|
243
|
-
read_attribute('voteable')
|
244
|
-
end
|
245
|
-
|
246
238
|
end
|
247
239
|
end
|
@@ -4,10 +4,26 @@ module Mongoid
|
|
4
4
|
|
5
5
|
# Get list of voted votees
|
6
6
|
#
|
7
|
-
# @param [Class] klass the
|
7
|
+
# @param [Class] klass the voteable class, e.g. `Post` or `Comment`
|
8
8
|
# @return [Array, nil] an array of voteable objects voted by this voter
|
9
9
|
def votees(klass)
|
10
|
-
klass.any_of({
|
10
|
+
klass.any_of({ Voteable::UP_VOTER_IDS => _id }, { Voteable::DOWN_VOTER_IDS => _id })
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get list of up voted votees
|
14
|
+
#
|
15
|
+
# @param [Class] klass the voteable class, e.g. `Post` or `Comment`
|
16
|
+
# @return [Array, nil] an array of voteable objects up voted by this voter
|
17
|
+
def up_votees(klass)
|
18
|
+
klass.any_of(Voteable::UP_VOTER_IDS => _id)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get list of down voted votees
|
22
|
+
#
|
23
|
+
# @param [Class] klass the voteable class, e.g. `Post` or `Comment`
|
24
|
+
# @return [Array, nil] an array of voteable objects down voted by this voter
|
25
|
+
def down_votees(klass)
|
26
|
+
klass.any_of(Voteable::DOWN_VOTER_IDS => _id)
|
11
27
|
end
|
12
28
|
|
13
29
|
# Check to see if this voter voted on the votee or not
|
@@ -40,7 +56,7 @@ module Mongoid
|
|
40
56
|
votee = unless options.is_a?(Hash)
|
41
57
|
options
|
42
58
|
else
|
43
|
-
options[:votee] || options[:votee_type].classify.constantize.only(:
|
59
|
+
options[:votee] || options[:votee_type].classify.constantize.only(:votes).where(
|
44
60
|
:_id => options[:votee_id]
|
45
61
|
).first
|
46
62
|
end
|
data/lib/voteable_mongoid.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -60,7 +60,6 @@ describe Mongoid::Voteable do
|
|
60
60
|
context 'user1 vote up post1 the first time' do
|
61
61
|
before :all do
|
62
62
|
Post.vote(:votee_id => @post1.id, :voter_id => @user1.id, :value => :up)
|
63
|
-
Mongoid::Voteable::Stats.remake
|
64
63
|
@post1.reload
|
65
64
|
end
|
66
65
|
|
@@ -93,7 +92,6 @@ describe Mongoid::Voteable do
|
|
93
92
|
context 'user2 vote down post1 the first time' do
|
94
93
|
before :all do
|
95
94
|
Post.vote(:votee_id => @post1.id, :voter_id => @user2.id, :value => :down)
|
96
|
-
Mongoid::Voteable::Stats.remake
|
97
95
|
@post1.reload
|
98
96
|
end
|
99
97
|
|
@@ -135,7 +133,6 @@ describe Mongoid::Voteable do
|
|
135
133
|
context 'user1 vote down post2 the first time' do
|
136
134
|
before :all do
|
137
135
|
Post.vote(:votee_id => @post2.id, :voter_id => @user1.id, :value => :down)
|
138
|
-
Mongoid::Voteable::Stats.remake
|
139
136
|
@post2.reload
|
140
137
|
end
|
141
138
|
|
@@ -176,7 +173,6 @@ describe Mongoid::Voteable do
|
|
176
173
|
context 'user1 vote up post2 comment the first time' do
|
177
174
|
before :all do
|
178
175
|
@comment.vote(:voter_id => @user1.id, :value => :up)
|
179
|
-
Mongoid::Voteable::Stats.remake
|
180
176
|
@comment.reload
|
181
177
|
@post2.reload
|
182
178
|
end
|
@@ -198,7 +194,6 @@ describe Mongoid::Voteable do
|
|
198
194
|
context 'user1 revote post2 comment from up to down' do
|
199
195
|
before :all do
|
200
196
|
@user1.vote(:votee => @comment, :value => :down)
|
201
|
-
Mongoid::Voteable::Stats.remake
|
202
197
|
@comment.reload
|
203
198
|
@post2.reload
|
204
199
|
end
|
@@ -263,14 +258,7 @@ describe Mongoid::Voteable do
|
|
263
258
|
@post2.down_votes_count.should == 1
|
264
259
|
@post2.votes_count.should == 2
|
265
260
|
@post2.votes_point.should == 0
|
266
|
-
end
|
267
|
-
|
268
|
-
it "test scopes" do
|
269
|
-
Post.most_up_voted.first.should == @post2
|
270
|
-
Post.most_down_voted.first.should == @post1
|
271
|
-
Post.most_voted.first.should == @post2
|
272
|
-
Post.best_voted.first.should == @post2
|
273
|
-
end
|
261
|
+
end
|
274
262
|
end
|
275
263
|
|
276
264
|
context "user1 unvote on comment" do
|
@@ -282,15 +270,15 @@ describe Mongoid::Voteable do
|
|
282
270
|
end
|
283
271
|
|
284
272
|
it "" do
|
285
|
-
@post2.up_votes_count.should == 1
|
286
|
-
@post2.down_votes_count.should == 0
|
287
|
-
@post2.votes_count.should == 1
|
288
|
-
@post2.votes_point.should == 1
|
289
|
-
|
290
273
|
@comment.up_votes_count.should == 0
|
291
274
|
@comment.down_votes_count.should == 0
|
292
275
|
@comment.votes_count.should == 0
|
293
276
|
@comment.votes_point.should == 0
|
277
|
+
|
278
|
+
@post2.up_votes_count.should == 1
|
279
|
+
@post2.down_votes_count.should == 0
|
280
|
+
@post2.votes_count.should == 1
|
281
|
+
@post2.votes_point.should == 1
|
294
282
|
end
|
295
283
|
end
|
296
284
|
|
@@ -14,10 +14,14 @@ describe Mongoid::Voter do
|
|
14
14
|
context "just created" do
|
15
15
|
it '' do
|
16
16
|
@user1.votees(Post).should be_empty
|
17
|
+
@user1.up_votees(Post).should be_empty
|
18
|
+
@user1.down_votees(Post).should be_empty
|
17
19
|
@user1.voted?(@post1).should be_false
|
18
20
|
@user1.voted?(@post2).should be_false
|
19
21
|
|
20
22
|
@user2.votees(Post).should be_empty
|
23
|
+
@user2.up_votees(Post).should be_empty
|
24
|
+
@user2.down_votees(Post).should be_empty
|
21
25
|
@user2.voted?(@post1).should be_false
|
22
26
|
@user2.voted?(@post2).should be_false
|
23
27
|
end
|
@@ -48,6 +52,8 @@ describe Mongoid::Voter do
|
|
48
52
|
@user2.should_not be_voted(:votee_type => 'Post', :votee_id => @post1.id)
|
49
53
|
|
50
54
|
@user1.votees(Post).to_a.should == [ @post1 ]
|
55
|
+
@user1.up_votees(Post).to_a.should == [ @post1 ]
|
56
|
+
@user1.down_votees(Post).to_a.should be_empty
|
51
57
|
@user2.votees(Post).to_a.should be_empty
|
52
58
|
end
|
53
59
|
|
@@ -77,6 +83,8 @@ describe Mongoid::Voter do
|
|
77
83
|
|
78
84
|
@user1.votees(Post).to_a.should == [ @post1 ]
|
79
85
|
@user2.votees(Post).to_a.should == [ @post1 ]
|
86
|
+
@user2.up_votees(Post).to_a.should be_empty
|
87
|
+
@user2.down_votees(Post).to_a.should == [ @post1 ]
|
80
88
|
end
|
81
89
|
end
|
82
90
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: voteable_mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Nguyen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-31 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -88,38 +88,18 @@ extra_rdoc_files: []
|
|
88
88
|
files:
|
89
89
|
- .gitignore
|
90
90
|
- .watchr
|
91
|
+
- CHANGELOG.rdoc
|
91
92
|
- Gemfile
|
92
93
|
- README.rdoc
|
93
94
|
- Rakefile
|
94
95
|
- TODO
|
95
|
-
- doc/Mongoid.html
|
96
|
-
- doc/Mongoid/Voteable.html
|
97
|
-
- doc/Mongoid/Voteable/Stats.html
|
98
|
-
- doc/Mongoid/Voter.html
|
99
|
-
- doc/Rails.html
|
100
|
-
- doc/Rails/VoteableMongoid.html
|
101
|
-
- doc/Rails/VoteableMongoid/Railtie.html
|
102
|
-
- doc/VoteableMongoid.html
|
103
|
-
- doc/_index.html
|
104
|
-
- doc/class_list.html
|
105
|
-
- doc/css/common.css
|
106
|
-
- doc/css/full_list.css
|
107
|
-
- doc/css/style.css
|
108
|
-
- doc/file.README.html
|
109
|
-
- doc/file_list.html
|
110
|
-
- doc/frames.html
|
111
|
-
- doc/index.html
|
112
|
-
- doc/js/app.js
|
113
|
-
- doc/js/full_list.js
|
114
|
-
- doc/js/jquery.js
|
115
|
-
- doc/method_list.html
|
116
|
-
- doc/top-level-namespace.html
|
117
96
|
- lib/voteable_mongoid.rb
|
118
97
|
- lib/voteable_mongoid/railtie.rb
|
119
98
|
- lib/voteable_mongoid/railties/database.rake
|
120
99
|
- lib/voteable_mongoid/version.rb
|
121
100
|
- lib/voteable_mongoid/voteable.rb
|
122
101
|
- lib/voteable_mongoid/voteable/stats.rb
|
102
|
+
- lib/voteable_mongoid/voteable/votes.rb
|
123
103
|
- lib/voteable_mongoid/voter.rb
|
124
104
|
- spec/.rspec
|
125
105
|
- spec/models/comment.rb
|