commontator 4.0.2 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/app/assets/stylesheets/commontator/comments.css +16 -5
- data/app/assets/stylesheets/commontator/comments.css~ +98 -0
- data/app/controllers/commontator/application_controller.rb +6 -3
- data/app/controllers/commontator/application_controller.rb~ +30 -0
- data/app/controllers/commontator/threads_controller.rb +2 -0
- data/app/controllers/commontator/threads_controller.rb~ +44 -0
- data/app/helpers/commontator/threads_helper.rb +1 -8
- data/app/helpers/commontator/threads_helper.rb~ +11 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +2 -4
- data/app/mailers/commontator/subscriptions_mailer.rb~ +50 -0
- data/app/models/commontator/comment.rb +23 -19
- data/app/models/commontator/comment.rb~ +106 -0
- data/app/models/commontator/thread.rb +10 -10
- data/app/models/commontator/thread.rb~ +124 -0
- data/app/views/commontator/comments/_show.html.erb +36 -34
- data/app/views/commontator/comments/_show.html.erb~ +47 -0
- data/app/views/commontator/comments/_votes.html.erb +6 -2
- data/app/views/commontator/comments/_votes.html.erb~ +61 -0
- data/app/views/commontator/comments/delete.js.erb +2 -2
- data/app/views/commontator/comments/delete.js.erb~ +17 -0
- data/app/views/commontator/comments/update.js.erb +2 -2
- data/app/views/commontator/comments/update.js.erb~ +7 -0
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +2 -2
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb~ +6 -0
- data/app/views/commontator/threads/_show.html.erb +3 -7
- data/app/views/commontator/threads/_show.html.erb~ +58 -0
- data/config/initializers/commontator.rb +52 -47
- data/config/initializers/commontator.rb~ +176 -0
- data/lib/commontator.rb +6 -7
- data/lib/commontator.rb~ +61 -0
- data/lib/commontator/controller_includes.rb +1 -3
- data/lib/commontator/controller_includes.rb~ +22 -0
- data/lib/commontator/shared_helper.rb +3 -8
- data/lib/commontator/shared_helper.rb~ +37 -0
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +3 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +64 -45
- data/spec/app/controllers/commontator/comments_controller_spec.rb~ +580 -0
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +3 -3
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +99 -0
- data/spec/app/controllers/commontator/threads_controller_spec.rb +15 -9
- data/spec/app/controllers/commontator/threads_controller_spec.rb~ +126 -0
- data/spec/app/helpers/commontator/application_helper_spec.rb +1 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb~ +9 -0
- data/spec/app/helpers/commontator/threads_helper_spec.rb +1 -5
- data/spec/app/helpers/commontator/threads_helper_spec.rb~ +13 -0
- data/spec/app/models/commontator/comment_spec.rb +4 -3
- data/spec/app/models/commontator/comment_spec.rb~ +62 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/application.rb~ +27 -0
- data/spec/dummy/config/initializers/commontator.rb +67 -55
- data/spec/dummy/config/initializers/commontator.rb~ +176 -0
- data/spec/dummy/config/initializers/commontator2.rb~ +169 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +84489 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/02d4b791eb831cf2057bf4703a1218d1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0f196a1a50363b0a076ec6e1ee5417f6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e1f674c11941d62aac1764ef3a7134e4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e85565206c3e5fdf9dfeb367c85557b1 +0 -0
- data/spec/lib/commontator/commontable_config_spec.rb +1 -1
- data/spec/lib/commontator/commontable_config_spec.rb~ +26 -0
- data/spec/lib/commontator/commontator_config_spec.rb +5 -5
- data/spec/lib/commontator/commontator_config_spec.rb~ +26 -0
- data/spec/lib/commontator_spec.rb +6 -4
- data/spec/lib/commontator_spec.rb~ +28 -0
- data/spec/test_helper.rb +4 -4
- data/spec/test_helper.rb~ +37 -0
- metadata +46 -2
data/lib/commontator.rb
CHANGED
@@ -6,16 +6,15 @@ module Commontator
|
|
6
6
|
|
7
7
|
# Can be set in initializer only
|
8
8
|
ENGINE_ATTRIBUTES = [
|
9
|
-
:
|
9
|
+
:current_user_proc,
|
10
10
|
:javascript_proc
|
11
11
|
]
|
12
12
|
|
13
13
|
# Can be set in initializer or passed as an option to acts_as_commontator
|
14
14
|
COMMONTATOR_ATTRIBUTES = [
|
15
|
-
:user_missing_name,
|
16
15
|
:user_name_clickable,
|
17
|
-
:
|
18
|
-
:
|
16
|
+
:user_name_proc,
|
17
|
+
:user_email_proc,
|
19
18
|
:user_admin_proc,
|
20
19
|
:subscription_email_enable_proc
|
21
20
|
]
|
@@ -27,7 +26,6 @@ module Commontator
|
|
27
26
|
:comment_create_verb_past,
|
28
27
|
:comment_edit_verb_present,
|
29
28
|
:comment_edit_verb_past,
|
30
|
-
:commontable_name,
|
31
29
|
:timestamp_format,
|
32
30
|
:admin_can_edit_comments,
|
33
31
|
:auto_subscribe_on_comment,
|
@@ -37,12 +35,13 @@ module Commontator
|
|
37
35
|
:can_delete_old_comments,
|
38
36
|
:can_subscribe_to_thread,
|
39
37
|
:can_vote_on_comments,
|
38
|
+
:combine_upvotes_and_downvotes,
|
40
39
|
:comments_ordered_by_votes,
|
41
40
|
:closed_threads_are_readable,
|
42
41
|
:deleted_comments_are_visible,
|
43
|
-
:commontable_id_method,
|
44
|
-
:can_edit_thread_proc,
|
45
42
|
:can_read_thread_proc,
|
43
|
+
:can_edit_thread_proc,
|
44
|
+
:commontable_name_proc,
|
46
45
|
:commontable_url_proc,
|
47
46
|
:subscription_email_from_proc,
|
48
47
|
:subscription_email_subject_proc
|
data/lib/commontator.rb~
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'commontator/engine'
|
2
|
+
require 'commontator/controller_includes'
|
3
|
+
|
4
|
+
module Commontator
|
5
|
+
# Attributes
|
6
|
+
|
7
|
+
# Can be set in initializer only
|
8
|
+
ENGINE_ATTRIBUTES = [
|
9
|
+
:current_user_method,
|
10
|
+
:javascript_proc
|
11
|
+
]
|
12
|
+
|
13
|
+
# Can be set in initializer or passed as an option to acts_as_commontator
|
14
|
+
COMMONTATOR_ATTRIBUTES = [
|
15
|
+
:user_name_clickable,
|
16
|
+
:user_name_proc,
|
17
|
+
:user_email_proc,
|
18
|
+
:user_admin_proc,
|
19
|
+
:subscription_email_enable_proc
|
20
|
+
]
|
21
|
+
|
22
|
+
# Can be set in initializer or passed as an option to acts_as_commontable
|
23
|
+
COMMONTABLE_ATTRIBUTES = [
|
24
|
+
:comment_name,
|
25
|
+
:comment_create_verb_present,
|
26
|
+
:comment_create_verb_past,
|
27
|
+
:comment_edit_verb_present,
|
28
|
+
:comment_edit_verb_past,
|
29
|
+
:timestamp_format,
|
30
|
+
:admin_can_edit_comments,
|
31
|
+
:auto_subscribe_on_comment,
|
32
|
+
:can_edit_own_comments,
|
33
|
+
:can_edit_old_comments,
|
34
|
+
:can_delete_own_comments,
|
35
|
+
:can_delete_old_comments,
|
36
|
+
:can_subscribe_to_thread,
|
37
|
+
:can_vote_on_comments,
|
38
|
+
:combine_upvotes_and_downvotes,
|
39
|
+
:comments_ordered_by_votes,
|
40
|
+
:closed_threads_are_readable,
|
41
|
+
:deleted_comments_are_visible,
|
42
|
+
:can_read_thread_proc,
|
43
|
+
:can_edit_thread_proc,
|
44
|
+
:commontable_name_proc,
|
45
|
+
:commontable_url_proc,
|
46
|
+
:subscription_email_from_proc,
|
47
|
+
:subscription_email_subject_proc
|
48
|
+
]
|
49
|
+
|
50
|
+
(ENGINE_ATTRIBUTES + COMMONTATOR_ATTRIBUTES + \
|
51
|
+
COMMONTABLE_ATTRIBUTES).each do |attribute|
|
52
|
+
mattr_accessor attribute
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.configure
|
56
|
+
yield self
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
require 'commontator/acts_as_commontator'
|
61
|
+
require 'commontator/acts_as_commontable'
|
@@ -10,9 +10,7 @@ module Commontator
|
|
10
10
|
protected
|
11
11
|
|
12
12
|
def commontator_thread_show(commontable)
|
13
|
-
user =
|
14
|
-
raise SecurityTransgression unless (user.nil? || user.is_commontator)
|
15
|
-
|
13
|
+
user = Commontator.current_user_proc.call(self)
|
16
14
|
thread = commontable.thread
|
17
15
|
raise SecurityTransgression unless thread.can_be_read_by?(user)
|
18
16
|
thread.mark_as_read_for(user)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'commontator/shared_helper'
|
2
|
+
require 'commontator/security_transgression'
|
3
|
+
|
4
|
+
module Commontator
|
5
|
+
module ControllerIncludes
|
6
|
+
def self.included(base)
|
7
|
+
base.helper Commontator::SharedHelper
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def commontator_thread_show(commontable)
|
13
|
+
user = send Commontator.current_user_proc.call(self)
|
14
|
+
thread = commontable.thread
|
15
|
+
raise SecurityTransgression unless thread.can_be_read_by?(user)
|
16
|
+
thread.mark_as_read_for(user)
|
17
|
+
@commontator_thread_show = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
ActionController::Base.send :include, Commontator::ControllerIncludes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Commontator
|
2
2
|
module SharedHelper
|
3
3
|
def commontator_thread(commontable)
|
4
|
-
user =
|
4
|
+
user = Commontator.current_user_proc.call(self)
|
5
5
|
|
6
6
|
render(:partial => 'commontator/shared/thread',
|
7
7
|
:locals => {:thread => commontable.thread,
|
@@ -9,16 +9,11 @@ module Commontator
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def commontator_name(user)
|
12
|
-
|
13
|
-
config = user.commontator_config
|
14
|
-
config.user_name_method.blank? ? config.user_missing_name : \
|
15
|
-
user.send(config.user_name_method)
|
12
|
+
user.commontator_config.user_name_proc.call(user)
|
16
13
|
end
|
17
14
|
|
18
15
|
def commontator_email(user)
|
19
|
-
|
20
|
-
config = user.commontator_config
|
21
|
-
config.user_email_method.blank? ? '' : user.send(config.user_email_method)
|
16
|
+
user.commontator_config.user_email_proc.call(user)
|
22
17
|
end
|
23
18
|
|
24
19
|
def commontator_gravatar_url(user, options = {})
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Commontator
|
2
|
+
module SharedHelper
|
3
|
+
def commontator_thread(commontable)
|
4
|
+
user = send(Commontator.current_user_method)
|
5
|
+
|
6
|
+
render(:partial => 'commontator/shared/thread',
|
7
|
+
:locals => {:thread => commontable.thread,
|
8
|
+
:user => user}).html_safe
|
9
|
+
end
|
10
|
+
|
11
|
+
def commontator_name(user)
|
12
|
+
user.commontator_config.user_name_proc.call(user)
|
13
|
+
end
|
14
|
+
|
15
|
+
def commontator_email(user)
|
16
|
+
user.commontator_config.user_email_proc.call(user)
|
17
|
+
end
|
18
|
+
|
19
|
+
def commontator_gravatar_url(user, options = {})
|
20
|
+
options[:secure] ||= request.ssl?
|
21
|
+
options[:size] ||= 50
|
22
|
+
|
23
|
+
hash = Digest::MD5.hexdigest(commontator_email(user))
|
24
|
+
base = options[:secure] ? "s://secure" : "://www"
|
25
|
+
|
26
|
+
"http#{base}.gravatar.com/avatar/#{hash}?s=#{options[:size]}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def commontator_gravatar_image(user, options = {})
|
30
|
+
name = commontator_name(user)
|
31
|
+
image_tag(commontator_gravatar_url(user, options),
|
32
|
+
{ :alt => name,
|
33
|
+
:title => name,
|
34
|
+
:border => 1 })
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/commontator/version.rb
CHANGED
@@ -13,7 +13,7 @@ module Commontator
|
|
13
13
|
@comment.is_votable?.must_equal true
|
14
14
|
end
|
15
15
|
|
16
|
-
it '
|
16
|
+
it "won't get new unless authorized" do
|
17
17
|
get :new, :thread_id => @thread.id, :use_route => :commontator
|
18
18
|
assert_response 403
|
19
19
|
|
@@ -43,7 +43,7 @@ module Commontator
|
|
43
43
|
assigns(:comment).errors.must_be_empty
|
44
44
|
end
|
45
45
|
|
46
|
-
it '
|
46
|
+
it "won't create unless authorized" do
|
47
47
|
attributes = Hash.new
|
48
48
|
attributes[:body] = 'Something else'
|
49
49
|
|
@@ -99,7 +99,7 @@ module Commontator
|
|
99
99
|
assigns(:comment).thread.must_equal @thread
|
100
100
|
end
|
101
101
|
|
102
|
-
it '
|
102
|
+
it "won't create if double posting" do
|
103
103
|
sign_in @user
|
104
104
|
@user.can_read = true
|
105
105
|
attributes = Hash.new
|
@@ -124,7 +124,7 @@ module Commontator
|
|
124
124
|
assigns(:comment).errors.wont_be_empty
|
125
125
|
end
|
126
126
|
|
127
|
-
it '
|
127
|
+
it "won't edit unless authorized" do
|
128
128
|
get :edit, :id => @comment.id, :use_route => :commontator
|
129
129
|
assert_response 403
|
130
130
|
|
@@ -174,20 +174,22 @@ module Commontator
|
|
174
174
|
assigns(:comment).errors.must_be_empty
|
175
175
|
end
|
176
176
|
|
177
|
-
it '
|
177
|
+
it "won't update unless authorized" do
|
178
178
|
attributes = Hash.new
|
179
179
|
attributes[:body] = 'Something else'
|
180
180
|
|
181
181
|
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
182
182
|
assert_response 403
|
183
|
-
|
184
|
-
|
183
|
+
@comment.reload
|
184
|
+
@comment.body.must_equal 'Something'
|
185
|
+
@comment.editor.must_be_nil
|
185
186
|
|
186
187
|
sign_in @user
|
187
188
|
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
188
189
|
assert_response 403
|
189
|
-
|
190
|
-
|
190
|
+
@comment.reload
|
191
|
+
@comment.body.must_equal 'Something'
|
192
|
+
@comment.editor.must_be_nil
|
191
193
|
|
192
194
|
user2 = DummyUser.create
|
193
195
|
user2.can_read = true
|
@@ -196,8 +198,9 @@ module Commontator
|
|
196
198
|
sign_in user2
|
197
199
|
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
198
200
|
assert_response 403
|
199
|
-
|
200
|
-
|
201
|
+
@comment.reload
|
202
|
+
@comment.body.must_equal 'Something'
|
203
|
+
@comment.editor.must_be_nil
|
201
204
|
|
202
205
|
@user.can_read = true
|
203
206
|
@user.can_edit = true
|
@@ -209,9 +212,9 @@ module Commontator
|
|
209
212
|
comment2.body = 'Something else'
|
210
213
|
comment2.save!
|
211
214
|
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
+
@comment.reload
|
216
|
+
@comment.body.must_equal 'Something'
|
217
|
+
@comment.editor.must_be_nil
|
215
218
|
end
|
216
219
|
|
217
220
|
it 'must update if authorized' do
|
@@ -240,16 +243,18 @@ module Commontator
|
|
240
243
|
assigns(:comment).editor.must_equal @user
|
241
244
|
end
|
242
245
|
|
243
|
-
it '
|
246
|
+
it "won't delete unless authorized and not deleted" do
|
244
247
|
put :delete, :id => @comment.id, :use_route => :commontator
|
245
248
|
assert_response 403
|
246
|
-
|
249
|
+
@comment.reload
|
250
|
+
@comment.is_deleted?.must_equal false
|
247
251
|
|
248
252
|
sign_in @user
|
249
253
|
|
250
254
|
put :delete, :id => @comment.id, :use_route => :commontator
|
251
255
|
assert_response 403
|
252
|
-
|
256
|
+
@comment.reload
|
257
|
+
@comment.is_deleted?.must_equal false
|
253
258
|
|
254
259
|
@user.can_read = true
|
255
260
|
@comment.delete_by(@user).must_equal true
|
@@ -265,7 +270,8 @@ module Commontator
|
|
265
270
|
@comment.undelete_by(@user).must_equal true
|
266
271
|
put :delete, :id => @comment.id, :use_route => :commontator
|
267
272
|
assert_response 403
|
268
|
-
|
273
|
+
@comment.reload
|
274
|
+
@comment.is_deleted?.must_equal false
|
269
275
|
end
|
270
276
|
|
271
277
|
it 'must delete if authorized and not deleted' do
|
@@ -304,17 +310,19 @@ module Commontator
|
|
304
310
|
assigns(:comment).editor.must_equal user2
|
305
311
|
end
|
306
312
|
|
307
|
-
it '
|
313
|
+
it "won't undelete unless authorized and deleted" do
|
308
314
|
@comment.delete_by(@user).must_equal true
|
309
315
|
put :undelete, :id => @comment.id, :use_route => :commontator
|
310
316
|
assert_response 403
|
311
|
-
|
317
|
+
@comment.reload
|
318
|
+
@comment.is_deleted?.must_equal true
|
312
319
|
|
313
320
|
sign_in @user
|
314
321
|
|
315
322
|
put :undelete, :id => @comment.id, :use_route => :commontator
|
316
323
|
assert_response 403
|
317
|
-
|
324
|
+
@comment.reload
|
325
|
+
@comment.is_deleted?.must_equal true
|
318
326
|
|
319
327
|
@user.can_read = true
|
320
328
|
@comment.undelete_by(@user).must_equal true
|
@@ -329,7 +337,8 @@ module Commontator
|
|
329
337
|
@comment.delete_by(user2).must_equal true
|
330
338
|
put :undelete, :id => @comment.id, :use_route => :commontator
|
331
339
|
assert_response 403
|
332
|
-
|
340
|
+
@comment.reload
|
341
|
+
@comment.is_deleted?.must_equal true
|
333
342
|
|
334
343
|
comment2 = Comment.new
|
335
344
|
comment2.thread = @thread
|
@@ -340,7 +349,8 @@ module Commontator
|
|
340
349
|
@comment.delete_by(@user).must_equal true
|
341
350
|
put :undelete, :id => @comment.id, :use_route => :commontator
|
342
351
|
assert_response 403
|
343
|
-
|
352
|
+
@comment.reload
|
353
|
+
@comment.is_deleted?.must_equal true
|
344
354
|
end
|
345
355
|
|
346
356
|
it 'must undelete if authorized and deleted' do
|
@@ -377,25 +387,28 @@ module Commontator
|
|
377
387
|
assigns(:comment).is_deleted?.must_equal false
|
378
388
|
end
|
379
389
|
|
380
|
-
it '
|
390
|
+
it "won't upvote unless authorized" do
|
381
391
|
put :upvote, :id => @comment.id, :use_route => :commontator
|
382
392
|
assert_response 403
|
383
|
-
|
384
|
-
|
393
|
+
@comment.reload
|
394
|
+
@comment.upvotes.must_be_empty
|
395
|
+
@comment.downvotes.must_be_empty
|
385
396
|
|
386
397
|
sign_in @user
|
387
398
|
@user.can_read = true
|
388
399
|
put :upvote, :id => @comment.id, :use_route => :commontator
|
389
400
|
assert_response 403
|
390
|
-
|
391
|
-
|
401
|
+
@comment.reload
|
402
|
+
@comment.upvotes.must_be_empty
|
403
|
+
@comment.downvotes.must_be_empty
|
392
404
|
|
393
405
|
user2 = DummyUser.create
|
394
406
|
sign_in user2
|
395
407
|
put :upvote, :id => @comment.id, :use_route => :commontator
|
396
408
|
assert_response 403
|
397
|
-
|
398
|
-
|
409
|
+
@comment.reload
|
410
|
+
@comment.upvotes.must_be_empty
|
411
|
+
@comment.downvotes.must_be_empty
|
399
412
|
end
|
400
413
|
|
401
414
|
it 'must upvote if authorized' do
|
@@ -421,25 +434,28 @@ module Commontator
|
|
421
434
|
assigns(:comment).downvotes.must_be_empty
|
422
435
|
end
|
423
436
|
|
424
|
-
it '
|
437
|
+
it "won't downvote unless authorized" do
|
425
438
|
put :downvote, :id => @comment.id, :use_route => :commontator
|
426
439
|
assert_response 403
|
427
|
-
|
428
|
-
|
440
|
+
@comment.reload
|
441
|
+
@comment.upvotes.must_be_empty
|
442
|
+
@comment.downvotes.must_be_empty
|
429
443
|
|
430
444
|
sign_in @user
|
431
445
|
@user.can_read = true
|
432
446
|
put :downvote, :id => @comment.id, :use_route => :commontator
|
433
447
|
assert_response 403
|
434
|
-
|
435
|
-
|
448
|
+
@comment.reload
|
449
|
+
@comment.upvotes.must_be_empty
|
450
|
+
@comment.downvotes.must_be_empty
|
436
451
|
|
437
452
|
user2 = DummyUser.create
|
438
453
|
sign_in user2
|
439
454
|
put :downvote, :id => @comment.id, :use_route => :commontator
|
440
455
|
assert_response 403
|
441
|
-
|
442
|
-
|
456
|
+
@comment.reload
|
457
|
+
@comment.upvotes.must_be_empty
|
458
|
+
@comment.downvotes.must_be_empty
|
443
459
|
end
|
444
460
|
|
445
461
|
it 'must downvote if authorized' do
|
@@ -465,27 +481,30 @@ module Commontator
|
|
465
481
|
assigns(:comment).downvotes.count.must_equal 1
|
466
482
|
end
|
467
483
|
|
468
|
-
it '
|
484
|
+
it "won't unvote unless authorized" do
|
469
485
|
@comment.upvote_from(@user).must_equal true
|
470
486
|
|
471
487
|
put :unvote, :id => @comment.id, :use_route => :commontator
|
472
488
|
assert_response 403
|
473
|
-
|
474
|
-
|
489
|
+
@comment.reload
|
490
|
+
@comment.upvotes.count.must_equal 1
|
491
|
+
@comment.downvotes.must_be_empty
|
475
492
|
|
476
493
|
sign_in @user
|
477
494
|
@user.can_read = true
|
478
495
|
put :unvote, :id => @comment.id, :use_route => :commontator
|
479
496
|
assert_response 403
|
480
|
-
|
481
|
-
|
497
|
+
@comment.reload
|
498
|
+
@comment.upvotes.count.must_equal 1
|
499
|
+
@comment.downvotes.must_be_empty
|
482
500
|
|
483
501
|
user2 = DummyUser.create
|
484
502
|
sign_in user2
|
485
503
|
put :unvote, :id => @comment.id, :use_route => :commontator
|
486
504
|
assert_response 403
|
487
|
-
|
488
|
-
|
505
|
+
@comment.reload
|
506
|
+
@comment.upvotes.count.must_equal 1
|
507
|
+
@comment.downvotes.must_be_empty
|
489
508
|
end
|
490
509
|
|
491
510
|
it 'must unvote if authorized' do
|
@@ -511,7 +530,7 @@ module Commontator
|
|
511
530
|
assigns(:comment).downvotes.must_be_empty
|
512
531
|
end
|
513
532
|
|
514
|
-
it '
|
533
|
+
it "won't send mail if recipients empty" do
|
515
534
|
if defined?(CommentsController::SubscriptionsMailer)
|
516
535
|
CommentsController::SubscriptionsMailer.__send__(:initialize)
|
517
536
|
else
|