commontator 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/app/controllers/commontator/comments_controller.rb +6 -6
- data/app/controllers/commontator/subscriptions_controller.rb +2 -2
- data/app/controllers/commontator/threads_controller.rb +2 -2
- data/app/views/commontator/comments/_actions.html.erb +1 -1
- data/app/views/commontator/comments/_votes.html.erb +4 -4
- data/app/views/commontator/shared/_thread.html.erb +1 -1
- data/app/views/commontator/subscriptions/_link.html.erb +1 -1
- data/app/views/commontator/threads/_show.html.erb +1 -1
- data/config/routes.rb +9 -9
- data/lib/commontator/version.rb +1 -1
- data/spec/app/controllers/commontator/comments_controller_spec.rb +40 -40
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +12 -12
- data/spec/app/controllers/commontator/threads_controller_spec.rb +12 -12
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +4176 -0
- metadata +4 -91
- data/app/controllers/commontator/application_controller.rb~ +0 -27
- data/app/controllers/commontator/comments_controller.rb~ +0 -144
- data/app/controllers/commontator/subscriptions_controller.rb~ +0 -32
- data/app/controllers/commontator/threads_controller.rb~ +0 -42
- data/app/mailers/commontator/subscriptions_mailer.rb~ +0 -50
- data/app/models/commontator/comment.rb~ +0 -104
- data/app/models/commontator/subscription.rb~ +0 -18
- data/app/models/commontator/thread.rb~ +0 -124
- data/app/models/commontator/tree.rb~ +0 -123
- data/app/views/commontator/comments/_actions.html.erb~ +0 -30
- data/app/views/commontator/comments/_body.html.erb~ +0 -8
- data/app/views/commontator/comments/_form.html.erb~ +0 -38
- data/app/views/commontator/comments/_show.html.erb~ +0 -44
- data/app/views/commontator/comments/_votes.html.erb~ +0 -57
- data/app/views/commontator/comments/delete.js.erb~ +0 -17
- data/app/views/commontator/shared/_thread.html.erb~ +0 -20
- data/app/views/commontator/subscriptions/_link.html.erb~ +0 -16
- data/app/views/commontator/threads/_show.html.erb~ +0 -62
- data/config/initializers/commontator.rb~ +0 -171
- data/config/routes.rb~ +0 -22
- data/db/migrate/0_install.rb~ +0 -50
- data/lib/commontator.rb~ +0 -61
- data/lib/commontator/acts_as_commontable.rb~ +0 -45
- data/lib/commontator/acts_as_commontator.rb~ +0 -31
- data/lib/commontator/controller_includes.rb~ +0 -22
- data/lib/commontator/security_transgression.rb~ +0 -3
- data/lib/commontator/shared_helper.rb~ +0 -42
- data/lib/commontator/version.rb~ +0 -3
- data/lib/tasks/commontator_tasks.rake~ +0 -42
- data/spec/app/controllers/commontator/comments_controller_spec.rb~ +0 -563
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +0 -99
- data/spec/app/controllers/commontator/threads_controller_spec.rb~ +0 -121
- data/spec/app/helpers/commontator/application_helper_spec.rb~ +0 -9
- data/spec/app/helpers/commontator/threads_helper_spec.rb~ +0 -17
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb~ +0 -30
- data/spec/app/models/commontator/comment_observer_spec.rb~ +0 -27
- data/spec/app/models/commontator/comment_spec.rb~ +0 -61
- data/spec/app/models/commontator/subscription_spec.rb~ +0 -28
- data/spec/app/models/commontator/thread_spec.rb~ +0 -130
- data/spec/dummy/README.md~ +0 -3
- data/spec/dummy/Rakefile~ +0 -7
- data/spec/dummy/config.ru~ +0 -4
- data/spec/dummy/config/application.rb~ +0 -23
- data/spec/dummy/config/environment.rb~ +0 -5
- data/spec/dummy/config/environments/development.rb~ +0 -31
- data/spec/dummy/config/environments/production.rb~ +0 -67
- data/spec/dummy/config/environments/test.rb~ +0 -31
- data/spec/dummy/config/initializers/secret_token.rb~ +0 -12
- data/spec/lib/commontator/acts_as_commontable_spec.rb~ +0 -26
- data/spec/lib/commontator/acts_as_commontator_spec.rb~ +0 -25
- data/spec/lib/commontator/commontable_config_spec.rb~ +0 -26
- data/spec/lib/commontator/commontator_config_spec.rb~ +0 -26
- data/spec/lib/commontator/controller_includes_spec.rb~ +0 -15
- data/spec/lib/commontator/shared_helper_spec.rb~ +0 -16
- data/spec/lib/commontator_spec.rb~ +0 -23
- data/spec/minitest_helper.rb~ +0 -35
- data/spec/spec_helper.rb~ +0 -36
- data/spec/test_helper.rb~ +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f96ed4a2b92b92ce20a0ab78422775c3a5ada743
|
4
|
+
data.tar.gz: 1ef5a31ee4e7abd7bf27a873d6827b38203a9fd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 239ae6a054aaa4f051648a4e9946b903b8d9fa5bca8d7c287edaeee5a34eccfa7bcfe705a844c2ad68ddc0c5e2dc6b9cebb9e9ac13248c34919d3b9c939a6b6e
|
7
|
+
data.tar.gz: f0317ca260ea97798c6d479d3d524f3ee8e859dce1950a4b56d7aad26630a0aaf6c1ae162dcba0d3c569b7548c4183005a305e340542cb46dc3c3670b6fc8435
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Commontator
|
2
2
|
|
3
|
-
Commontator is a Rails engine for comments.
|
3
|
+
Commontator is a Rails engine for comments. It is compatible with Rails 3.1+ and Rails 4.
|
4
4
|
Being an engine means it is fully functional as soon as you install and configure its gem, providing models, views and controllers of its own.
|
5
5
|
At the same time, almost anything about it can be configured or customized to suit your needs.
|
6
6
|
|
@@ -10,14 +10,12 @@ There are 4 steps you must follow to install commontator:
|
|
10
10
|
|
11
11
|
1. Gem
|
12
12
|
|
13
|
-
Add this line to your application's Gemfile
|
13
|
+
Add this line to your application's Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem 'commontator', '~> 4.0.
|
16
|
+
gem 'commontator', '~> 4.0.2'
|
17
17
|
```
|
18
18
|
|
19
|
-
If you are still using rails 3, use Commontator version 2.0.1 instead.
|
20
|
-
|
21
19
|
And then execute:
|
22
20
|
|
23
21
|
```sh
|
@@ -55,7 +55,7 @@ module Commontator
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
#
|
58
|
+
# PUT /comments/1
|
59
59
|
def update
|
60
60
|
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
|
61
61
|
@comment.body = params[:comment].nil? ? nil : params[:comment][:body]
|
@@ -72,7 +72,7 @@ module Commontator
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
#
|
75
|
+
# PUT /comments/1/delete
|
76
76
|
def delete
|
77
77
|
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
|
78
78
|
|
@@ -85,7 +85,7 @@ module Commontator
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
#
|
88
|
+
# PUT /comments/1/undelete
|
89
89
|
def undelete
|
90
90
|
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
|
91
91
|
|
@@ -98,7 +98,7 @@ module Commontator
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
#
|
101
|
+
# PUT /comments/1/upvote
|
102
102
|
def upvote
|
103
103
|
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
104
104
|
|
@@ -110,7 +110,7 @@ module Commontator
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
#
|
113
|
+
# PUT /comments/1/downvote
|
114
114
|
def downvote
|
115
115
|
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
116
116
|
|
@@ -122,7 +122,7 @@ module Commontator
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
#
|
125
|
+
# PUT /comments/1/unvote
|
126
126
|
def unvote
|
127
127
|
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
128
128
|
|
@@ -2,7 +2,7 @@ module Commontator
|
|
2
2
|
class SubscriptionsController < Commontator::ApplicationController
|
3
3
|
before_filter :get_thread
|
4
4
|
|
5
|
-
#
|
5
|
+
# PUT /threads/1/subscribe
|
6
6
|
def subscribe
|
7
7
|
raise SecurityTransgression unless @thread.can_subscribe?(@user)
|
8
8
|
|
@@ -16,7 +16,7 @@ module Commontator
|
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
#
|
19
|
+
# PUT /threads/1/unsubscribe
|
20
20
|
def unsubscribe
|
21
21
|
raise SecurityTransgression unless @thread.can_subscribe?(@user)
|
22
22
|
|
@@ -13,7 +13,7 @@ module Commontator
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
#
|
16
|
+
# PUT /threads/1/close
|
17
17
|
def close
|
18
18
|
raise SecurityTransgression unless @thread.can_be_edited_by?(@user)
|
19
19
|
|
@@ -26,7 +26,7 @@ module Commontator
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
#
|
29
|
+
# PUT /threads/1/reopen
|
30
30
|
def reopen
|
31
31
|
raise SecurityTransgression unless @thread.can_be_edited_by?(@user)
|
32
32
|
|
@@ -23,7 +23,7 @@
|
|
23
23
|
:confirm => (!is_deleted ? \
|
24
24
|
"Are you sure you want to delete this " + \
|
25
25
|
"#{comment.thread.config.comment_name}?" : nil),
|
26
|
-
:method => :
|
26
|
+
:method => :put,
|
27
27
|
:id => "comment_#{comment.id.to_s}_#{del_string}_link",
|
28
28
|
:class => "comment_#{del_string}_link",
|
29
29
|
:remote => true %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<span id="comment_<%= comment.id %>_upvote_span" class="comment_upvote">
|
11
11
|
<% if can_vote && (vote.blank? || !vote.vote_flag) %>
|
12
12
|
<%= form_tag commontator.upvote_comment_path(comment),
|
13
|
-
:method => :
|
13
|
+
:method => :put,
|
14
14
|
:remote => true do %>
|
15
15
|
<%= image_submit_tag "commontator/upvote.png",
|
16
16
|
:onmouseover => "this.src='/assets/commontator/upvote_hover.png'",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<% end %>
|
19
19
|
<% elsif can_vote %>
|
20
20
|
<%= form_tag commontator.unvote_comment_path(comment),
|
21
|
-
:method => :
|
21
|
+
:method => :put,
|
22
22
|
:remote => true do %>
|
23
23
|
<%= image_submit_tag "commontator/upvote_hover.png",
|
24
24
|
:onmouseover => "this.src='/assets/commontator/upvote.png'",
|
@@ -36,7 +36,7 @@
|
|
36
36
|
<span id="comment_<%= comment.id %>_downvote_span" class="comment_downvote">
|
37
37
|
<% if can_vote && (vote.blank? || vote.vote_flag) %>
|
38
38
|
<%= form_tag commontator.downvote_comment_path(comment),
|
39
|
-
:method => :
|
39
|
+
:method => :put,
|
40
40
|
:remote => true do %>
|
41
41
|
<%= image_submit_tag "commontator/downvote.png",
|
42
42
|
:onmouseover => "this.src='/assets/commontator/downvote_hover.png'",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
<% end %>
|
45
45
|
<% elsif can_vote %>
|
46
46
|
<%= form_tag commontator.unvote_comment_path(comment),
|
47
|
-
:method => :
|
47
|
+
:method => :put,
|
48
48
|
:remote => true do %>
|
49
49
|
<%= image_submit_tag "commontator/downvote_hover.png",
|
50
50
|
:onmouseover => "this.src='/assets/commontator/downvote.png'",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<%= render :partial => 'commontator/threads/show', :locals => {:thread => thread,
|
14
14
|
:user => user} %>
|
15
15
|
<% else %>
|
16
|
-
<%= link_to "Show #{thread.config.comment_name.pluralize} (#{subscription ? subscription.unread + '/' + thread.comments.count : thread.comments.count})", \
|
16
|
+
<%= link_to "Show #{thread.config.comment_name.pluralize} (#{subscription ? (subscription.unread.to_s + '/' + thread.comments.count.to_s) : thread.comments.count.to_s})", \
|
17
17
|
commontator.thread_path(thread), :remote => true %>
|
18
18
|
<% end %>
|
19
19
|
</div>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
:confirm => (is_subscribed ? \
|
11
11
|
"Are you sure you want to unsubscribe from this thread?" : \
|
12
12
|
nil),
|
13
|
-
:method => :
|
13
|
+
:method => :put,
|
14
14
|
:id => "thread_#{thread.id.to_s}_#{sub_string}_link",
|
15
15
|
:class => "thread_#{sub_string}_link",
|
16
16
|
:remote => true %>
|
@@ -28,7 +28,7 @@
|
|
28
28
|
commontator.polymorphic_path([close_string, thread]),
|
29
29
|
:confirm => (!is_closed ? \
|
30
30
|
'Are you sure you want to close this thread?' : nil),
|
31
|
-
:method => :
|
31
|
+
:method => :put,
|
32
32
|
:id => "thread_#{thread.id.to_s}_#{close_string}_link",
|
33
33
|
:class => "thread_#{close_string}_link",
|
34
34
|
:remote => true %>
|
data/config/routes.rb
CHANGED
@@ -2,21 +2,21 @@ Commontator::Engine.routes.draw do
|
|
2
2
|
resources :threads, :only => [:show] do
|
3
3
|
resources :comments, :except => [:index, :destroy], :shallow => true do
|
4
4
|
member do
|
5
|
-
|
6
|
-
|
5
|
+
put 'delete'
|
6
|
+
put 'undelete'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
put 'upvote'
|
9
|
+
put 'downvote'
|
10
|
+
put 'unvote'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
member do
|
15
|
-
|
16
|
-
|
15
|
+
put 'close'
|
16
|
+
put 'reopen'
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
put 'subscribe', :to => 'subscriptions#subscribe'
|
19
|
+
put 'unsubscribe', :to => 'subscriptions#unsubscribe'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/commontator/version.rb
CHANGED
@@ -178,13 +178,13 @@ module Commontator
|
|
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
183
|
assigns(:comment).body.must_equal 'Something'
|
184
184
|
assigns(:comment).editor.must_be_nil
|
185
185
|
|
186
186
|
sign_in @user
|
187
|
-
|
187
|
+
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
188
188
|
assert_response 403
|
189
189
|
assigns(:comment).body.must_equal 'Something'
|
190
190
|
assigns(:comment).editor.must_be_nil
|
@@ -194,7 +194,7 @@ module Commontator
|
|
194
194
|
user2.can_edit = true
|
195
195
|
user2.is_admin = true
|
196
196
|
sign_in user2
|
197
|
-
|
197
|
+
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
198
198
|
assert_response 403
|
199
199
|
assigns(:comment).body.must_equal 'Something'
|
200
200
|
assigns(:comment).editor.must_be_nil
|
@@ -208,7 +208,7 @@ module Commontator
|
|
208
208
|
comment2.creator = @user
|
209
209
|
comment2.body = 'Something else'
|
210
210
|
comment2.save!
|
211
|
-
|
211
|
+
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
212
212
|
assert_response 403
|
213
213
|
assigns(:comment).body.must_equal 'Something'
|
214
214
|
assigns(:comment).editor.must_be_nil
|
@@ -220,40 +220,40 @@ module Commontator
|
|
220
220
|
attributes[:body] = 'Something else'
|
221
221
|
|
222
222
|
@user.can_read = true
|
223
|
-
|
223
|
+
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
224
224
|
assert_redirected_to @thread
|
225
225
|
assigns(:comment).errors.must_be_empty
|
226
226
|
assigns(:comment).editor.must_equal @user
|
227
227
|
|
228
228
|
@user.can_read = false
|
229
229
|
@user.can_edit = true
|
230
|
-
|
230
|
+
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
231
231
|
assert_redirected_to @thread
|
232
232
|
assigns(:comment).errors.must_be_empty
|
233
233
|
assigns(:comment).editor.must_equal @user
|
234
234
|
|
235
235
|
@user.can_edit = false
|
236
236
|
@user.is_admin = true
|
237
|
-
|
237
|
+
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
238
238
|
assert_redirected_to @thread
|
239
239
|
assigns(:comment).errors.must_be_empty
|
240
240
|
assigns(:comment).editor.must_equal @user
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'wont delete unless authorized and not deleted' do
|
244
|
-
|
244
|
+
put :delete, :id => @comment.id, :use_route => :commontator
|
245
245
|
assert_response 403
|
246
246
|
assigns(:comment).is_deleted?.must_equal false
|
247
247
|
|
248
248
|
sign_in @user
|
249
249
|
|
250
|
-
|
250
|
+
put :delete, :id => @comment.id, :use_route => :commontator
|
251
251
|
assert_response 403
|
252
252
|
assigns(:comment).is_deleted?.must_equal false
|
253
253
|
|
254
254
|
@user.can_read = true
|
255
255
|
@comment.delete_by(@user).must_equal true
|
256
|
-
|
256
|
+
put :delete, :id => @comment.id, :use_route => :commontator
|
257
257
|
assert_redirected_to @thread
|
258
258
|
assigns(:comment).errors.wont_be_empty
|
259
259
|
|
@@ -263,7 +263,7 @@ module Commontator
|
|
263
263
|
comment2.body = 'Something else'
|
264
264
|
comment2.save!
|
265
265
|
@comment.undelete_by(@user).must_equal true
|
266
|
-
|
266
|
+
put :delete, :id => @comment.id, :use_route => :commontator
|
267
267
|
assert_response 403
|
268
268
|
assigns(:comment).is_deleted?.must_equal false
|
269
269
|
end
|
@@ -272,7 +272,7 @@ module Commontator
|
|
272
272
|
sign_in @user
|
273
273
|
|
274
274
|
@user.can_read = true
|
275
|
-
|
275
|
+
put :delete, :id => @comment.id, :use_route => :commontator
|
276
276
|
assert_redirected_to @thread
|
277
277
|
assigns(:comment).errors.must_be_empty
|
278
278
|
assigns(:comment).is_deleted?.must_equal true
|
@@ -288,7 +288,7 @@ module Commontator
|
|
288
288
|
|
289
289
|
assigns(:comment).undelete_by(@user).must_equal true
|
290
290
|
user2.can_edit = true
|
291
|
-
|
291
|
+
put :delete, :id => @comment.id, :use_route => :commontator
|
292
292
|
assert_redirected_to @thread
|
293
293
|
assigns(:comment).errors.must_be_empty
|
294
294
|
assigns(:comment).is_deleted?.must_equal true
|
@@ -297,7 +297,7 @@ module Commontator
|
|
297
297
|
assigns(:comment).undelete_by(@user).must_equal true
|
298
298
|
user2.can_edit = false
|
299
299
|
user2.is_admin = true
|
300
|
-
|
300
|
+
put :delete, :id => @comment.id, :use_route => :commontator
|
301
301
|
assert_redirected_to @thread
|
302
302
|
assigns(:comment).errors.must_be_empty
|
303
303
|
assigns(:comment).is_deleted?.must_equal true
|
@@ -306,19 +306,19 @@ module Commontator
|
|
306
306
|
|
307
307
|
it 'wont undelete unless authorized and deleted' do
|
308
308
|
@comment.delete_by(@user).must_equal true
|
309
|
-
|
309
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
310
310
|
assert_response 403
|
311
311
|
assigns(:comment).is_deleted?.must_equal true
|
312
312
|
|
313
313
|
sign_in @user
|
314
314
|
|
315
|
-
|
315
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
316
316
|
assert_response 403
|
317
317
|
assigns(:comment).is_deleted?.must_equal true
|
318
318
|
|
319
319
|
@user.can_read = true
|
320
320
|
@comment.undelete_by(@user).must_equal true
|
321
|
-
|
321
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
322
322
|
assert_redirected_to @thread
|
323
323
|
assigns(:comment).errors.wont_be_empty
|
324
324
|
|
@@ -327,7 +327,7 @@ module Commontator
|
|
327
327
|
user2.can_edit = true
|
328
328
|
user2.is_admin = true
|
329
329
|
@comment.delete_by(user2).must_equal true
|
330
|
-
|
330
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
331
331
|
assert_response 403
|
332
332
|
assigns(:comment).is_deleted?.must_equal true
|
333
333
|
|
@@ -338,7 +338,7 @@ module Commontator
|
|
338
338
|
comment2.save!
|
339
339
|
@comment.undelete_by(@user).must_equal true
|
340
340
|
@comment.delete_by(@user).must_equal true
|
341
|
-
|
341
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
342
342
|
assert_response 403
|
343
343
|
assigns(:comment).is_deleted?.must_equal true
|
344
344
|
end
|
@@ -348,7 +348,7 @@ module Commontator
|
|
348
348
|
|
349
349
|
@comment.delete_by(@user).must_equal true
|
350
350
|
@user.can_read = true
|
351
|
-
|
351
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
352
352
|
assert_redirected_to @thread
|
353
353
|
assigns(:comment).errors.must_be_empty
|
354
354
|
assigns(:comment).is_deleted?.must_equal false
|
@@ -363,7 +363,7 @@ module Commontator
|
|
363
363
|
|
364
364
|
assigns(:comment).delete_by(@user).must_equal true
|
365
365
|
user2.can_edit = true
|
366
|
-
|
366
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
367
367
|
assert_redirected_to @thread
|
368
368
|
assigns(:comment).errors.must_be_empty
|
369
369
|
assigns(:comment).is_deleted?.must_equal false
|
@@ -371,28 +371,28 @@ module Commontator
|
|
371
371
|
assigns(:comment).delete_by(@user).must_equal true
|
372
372
|
user2.can_edit = false
|
373
373
|
user2.is_admin = true
|
374
|
-
|
374
|
+
put :undelete, :id => @comment.id, :use_route => :commontator
|
375
375
|
assert_redirected_to @thread
|
376
376
|
assigns(:comment).errors.must_be_empty
|
377
377
|
assigns(:comment).is_deleted?.must_equal false
|
378
378
|
end
|
379
379
|
|
380
380
|
it 'wont upvote if not authorized' do
|
381
|
-
|
381
|
+
put :upvote, :id => @comment.id, :use_route => :commontator
|
382
382
|
assert_response 403
|
383
383
|
assigns(:comment).upvotes.must_be_empty
|
384
384
|
assigns(:comment).downvotes.must_be_empty
|
385
385
|
|
386
386
|
sign_in @user
|
387
387
|
@user.can_read = true
|
388
|
-
|
388
|
+
put :upvote, :id => @comment.id, :use_route => :commontator
|
389
389
|
assert_response 403
|
390
390
|
assigns(:comment).upvotes.must_be_empty
|
391
391
|
assigns(:comment).downvotes.must_be_empty
|
392
392
|
|
393
393
|
user2 = DummyUser.create
|
394
394
|
sign_in user2
|
395
|
-
|
395
|
+
put :upvote, :id => @comment.id, :use_route => :commontator
|
396
396
|
assert_response 403
|
397
397
|
assigns(:comment).upvotes.must_be_empty
|
398
398
|
assigns(:comment).downvotes.must_be_empty
|
@@ -403,40 +403,40 @@ module Commontator
|
|
403
403
|
user2.can_read = true
|
404
404
|
sign_in user2
|
405
405
|
|
406
|
-
|
406
|
+
put :upvote, :id => @comment.id, :use_route => :commontator
|
407
407
|
assert_redirected_to @thread
|
408
408
|
assigns(:comment).upvotes.count.must_equal 1
|
409
409
|
assigns(:comment).downvotes.must_be_empty
|
410
410
|
|
411
|
-
|
411
|
+
put :upvote, :id => @comment.id, :use_route => :commontator
|
412
412
|
assert_redirected_to @thread
|
413
413
|
assigns(:comment).upvotes.count.must_equal 1
|
414
414
|
assigns(:comment).downvotes.must_be_empty
|
415
415
|
|
416
416
|
@comment.downvote_from(user2).must_equal true
|
417
417
|
|
418
|
-
|
418
|
+
put :upvote, :id => @comment.id, :use_route => :commontator
|
419
419
|
assert_redirected_to @thread
|
420
420
|
assigns(:comment).upvotes.count.must_equal 1
|
421
421
|
assigns(:comment).downvotes.must_be_empty
|
422
422
|
end
|
423
423
|
|
424
424
|
it 'wont downvote if not authorized' do
|
425
|
-
|
425
|
+
put :downvote, :id => @comment.id, :use_route => :commontator
|
426
426
|
assert_response 403
|
427
427
|
assigns(:comment).upvotes.must_be_empty
|
428
428
|
assigns(:comment).downvotes.must_be_empty
|
429
429
|
|
430
430
|
sign_in @user
|
431
431
|
@user.can_read = true
|
432
|
-
|
432
|
+
put :downvote, :id => @comment.id, :use_route => :commontator
|
433
433
|
assert_response 403
|
434
434
|
assigns(:comment).upvotes.must_be_empty
|
435
435
|
assigns(:comment).downvotes.must_be_empty
|
436
436
|
|
437
437
|
user2 = DummyUser.create
|
438
438
|
sign_in user2
|
439
|
-
|
439
|
+
put :downvote, :id => @comment.id, :use_route => :commontator
|
440
440
|
assert_response 403
|
441
441
|
assigns(:comment).upvotes.must_be_empty
|
442
442
|
assigns(:comment).downvotes.must_be_empty
|
@@ -447,19 +447,19 @@ module Commontator
|
|
447
447
|
user2.can_read = true
|
448
448
|
sign_in user2
|
449
449
|
|
450
|
-
|
450
|
+
put :downvote, :id => @comment.id, :use_route => :commontator
|
451
451
|
assert_redirected_to @thread
|
452
452
|
assigns(:comment).upvotes.must_be_empty
|
453
453
|
assigns(:comment).downvotes.count.must_equal 1
|
454
454
|
|
455
|
-
|
455
|
+
put :downvote, :id => @comment.id, :use_route => :commontator
|
456
456
|
assert_redirected_to @thread
|
457
457
|
assigns(:comment).upvotes.must_be_empty
|
458
458
|
assigns(:comment).downvotes.count.must_equal 1
|
459
459
|
|
460
460
|
@comment.upvote_from(user2).must_equal true
|
461
461
|
|
462
|
-
|
462
|
+
put :downvote, :id => @comment.id, :use_route => :commontator
|
463
463
|
assert_redirected_to @thread
|
464
464
|
assigns(:comment).upvotes.must_be_empty
|
465
465
|
assigns(:comment).downvotes.count.must_equal 1
|
@@ -468,21 +468,21 @@ module Commontator
|
|
468
468
|
it 'wont unvote if not authorized' do
|
469
469
|
@comment.upvote_from(@user).must_equal true
|
470
470
|
|
471
|
-
|
471
|
+
put :unvote, :id => @comment.id, :use_route => :commontator
|
472
472
|
assert_response 403
|
473
473
|
assigns(:comment).upvotes.count.must_equal 1
|
474
474
|
assigns(:comment).downvotes.must_be_empty
|
475
475
|
|
476
476
|
sign_in @user
|
477
477
|
@user.can_read = true
|
478
|
-
|
478
|
+
put :unvote, :id => @comment.id, :use_route => :commontator
|
479
479
|
assert_response 403
|
480
480
|
assigns(:comment).upvotes.count.must_equal 1
|
481
481
|
assigns(:comment).downvotes.must_be_empty
|
482
482
|
|
483
483
|
user2 = DummyUser.create
|
484
484
|
sign_in user2
|
485
|
-
|
485
|
+
put :unvote, :id => @comment.id, :use_route => :commontator
|
486
486
|
assert_response 403
|
487
487
|
assigns(:comment).upvotes.count.must_equal 1
|
488
488
|
assigns(:comment).downvotes.must_be_empty
|
@@ -494,18 +494,18 @@ module Commontator
|
|
494
494
|
sign_in user2
|
495
495
|
|
496
496
|
@comment.upvote_from(user2).must_equal true
|
497
|
-
|
497
|
+
put :unvote, :id => @comment.id, :use_route => :commontator
|
498
498
|
assert_redirected_to @thread
|
499
499
|
assigns(:comment).upvotes.must_be_empty
|
500
500
|
assigns(:comment).downvotes.must_be_empty
|
501
501
|
|
502
|
-
|
502
|
+
put :unvote, :id => @comment.id, :use_route => :commontator
|
503
503
|
assert_redirected_to @thread
|
504
504
|
assigns(:comment).upvotes.must_be_empty
|
505
505
|
assigns(:comment).downvotes.must_be_empty
|
506
506
|
|
507
507
|
@comment.downvote_from(user2).must_equal true
|
508
|
-
|
508
|
+
put :unvote, :id => @comment.id, :use_route => :commontator
|
509
509
|
assert_redirected_to @thread
|
510
510
|
assigns(:comment).upvotes.must_be_empty
|
511
511
|
assigns(:comment).downvotes.must_be_empty
|