commontator 2.0.2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +20 -2
  4. data/app/controllers/commontator/comments_controller.rb +19 -11
  5. data/app/controllers/commontator/subscriptions_controller.rb +5 -5
  6. data/app/controllers/commontator/threads_controller.rb +3 -3
  7. data/app/mailers/commontator/subscriptions_mailer.rb +3 -2
  8. data/app/models/commontator/comment.rb +0 -6
  9. data/app/models/commontator/subscription.rb +0 -4
  10. data/app/models/commontator/thread.rb +4 -7
  11. data/app/views/commontator/comments/_actions.html.erb +1 -1
  12. data/app/views/commontator/comments/_votes.html.erb +4 -4
  13. data/app/views/commontator/shared/_thread.html.erb +1 -1
  14. data/app/views/commontator/subscriptions/_link.html.erb +1 -1
  15. data/app/views/commontator/threads/_show.html.erb +1 -1
  16. data/config/initializers/commontator.rb +1 -1
  17. data/config/routes.rb +15 -15
  18. data/db/migrate/0_install.rb +50 -0
  19. data/db/migrate/0_install.rb~ +3 -3
  20. data/lib/commontator/shared_helper.rb +1 -1
  21. data/lib/commontator/version.rb +1 -1
  22. data/lib/commontator/version.rb~ +1 -1
  23. data/spec/app/controllers/commontator/comments_controller_spec.rb +90 -41
  24. data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +16 -16
  25. data/spec/app/controllers/commontator/threads_controller_spec.rb +13 -13
  26. data/spec/app/helpers/commontator/application_helper_spec.rb +1 -1
  27. data/spec/app/helpers/commontator/threads_helper_spec.rb +1 -1
  28. data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +2 -2
  29. data/spec/app/models/commontator/comment_spec.rb +1 -1
  30. data/spec/app/models/commontator/subscription_spec.rb +1 -1
  31. data/spec/app/models/commontator/thread_spec.rb +1 -1
  32. data/spec/dummy/Rakefile +0 -1
  33. data/spec/dummy/config.ru +1 -1
  34. data/spec/dummy/config/application.rb +4 -36
  35. data/spec/dummy/config/boot.rb +4 -9
  36. data/spec/dummy/config/environment.rb +2 -2
  37. data/spec/dummy/config/environments/development.rb +11 -19
  38. data/spec/dummy/config/environments/production.rb +40 -27
  39. data/spec/dummy/config/environments/test.rb +13 -14
  40. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/spec/dummy/config/initializers/inflections.rb +6 -5
  42. data/spec/dummy/config/initializers/secret_token.rb +7 -2
  43. data/spec/dummy/config/initializers/session_store.rb +0 -5
  44. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  45. data/spec/dummy/config/locales/en.yml +20 -2
  46. data/spec/dummy/db/schema.rb +41 -41
  47. data/spec/dummy/db/test.sqlite3 +0 -0
  48. data/spec/dummy/log/test.log +0 -8352
  49. data/spec/lib/commontator/acts_as_commontable_spec.rb +1 -1
  50. data/spec/lib/commontator/acts_as_commontable_spec.rb~ +2 -2
  51. data/spec/lib/commontator/acts_as_commontator_spec.rb +1 -1
  52. data/spec/lib/commontator/commontable_config_spec.rb +1 -1
  53. data/spec/lib/commontator/commontator_config_spec.rb +1 -1
  54. data/spec/lib/commontator/controller_includes_spec.rb +3 -3
  55. data/spec/lib/commontator/shared_helper_spec.rb +7 -3
  56. data/spec/lib/commontator_spec.rb +1 -1
  57. data/spec/{minitest_helper.rb → test_helper.rb} +8 -4
  58. metadata +9 -10
  59. data/app/models/commontator/comment_observer.rb +0 -12
  60. data/db/migrate/0_install_commontator.rb +0 -50
  61. data/spec/app/models/commontator/comment_observer_spec.rb +0 -27
@@ -16,7 +16,7 @@ class Install < ActiveRecord::Migration
16
16
  t.timestamps
17
17
  end
18
18
 
19
- add_index :commontator_comments, [:creator_type, :creator_id, :thread_id], :name => "index_c_c_on_c_type_and_c_id_and_t_id"
19
+ add_index :commontator_comments, [:creator_type, :creator_id, :thread_id], :name => 'index_c_c_on_c_type_and_c_id_and_t_id'
20
20
  add_index :commontator_comments, :thread_id
21
21
 
22
22
  add_index :commontator_comments, :cached_votes_total
@@ -32,7 +32,7 @@ class Install < ActiveRecord::Migration
32
32
  t.timestamps
33
33
  end
34
34
 
35
- add_index :commontator_subscriptions, [:subscriber_type, :subscriber_id, :thread_id], :unique => true, :name => "index_c_s_on_s_type_and_s_id_and_t_id"
35
+ add_index :commontator_subscriptions, [:subscriber_type, :subscriber_id, :thread_id], :unique => true, :name => 'index_c_s_on_s_type_and_s_id_and_t_id'
36
36
  add_index :commontator_subscriptions, :thread_id
37
37
 
38
38
  create_table "commontator_threads" do |t|
@@ -45,6 +45,6 @@ class Install < ActiveRecord::Migration
45
45
  t.timestamps
46
46
  end
47
47
 
48
- add_index :commontator_threads, [:commontable_type, :commontable_id], :unique => true
48
+ add_index :commontator_threads, [:commontable_type, :commontable_id], :unique => true, :name => 'index_c_t_on_c_type_and_c_id'
49
49
  end
50
50
  end
@@ -1,7 +1,7 @@
1
1
  module Commontator
2
2
  module SharedHelper
3
3
  def commontator_thread(commontable)
4
- user = self.send Commontator.current_user_method
4
+ user = send(Commontator.current_user_method)
5
5
 
6
6
  render(:partial => 'commontator/shared/thread',
7
7
  :locals => {:thread => commontable.thread,
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "2.0.2"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'minitest_helper'
1
+ require 'test_helper'
2
2
  require 'acts_as_votable'
3
3
 
4
4
  module Commontator
@@ -178,13 +178,13 @@ module Commontator
178
178
  attributes = Hash.new
179
179
  attributes[:body] = 'Something else'
180
180
 
181
- put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
181
+ patch :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
- put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
187
+ patch :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
- put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
197
+ patch :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
- put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
211
+ patch :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
- put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
223
+ patch :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
- put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
230
+ patch :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
- put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
237
+ patch :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
- put :delete, :id => @comment.id, :use_route => :commontator
244
+ patch :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
- put :delete, :id => @comment.id, :use_route => :commontator
250
+ patch :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
- put :delete, :id => @comment.id, :use_route => :commontator
256
+ patch :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
- put :delete, :id => @comment.id, :use_route => :commontator
266
+ patch :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
- put :delete, :id => @comment.id, :use_route => :commontator
275
+ patch :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
- put :delete, :id => @comment.id, :use_route => :commontator
291
+ patch :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
- put :delete, :id => @comment.id, :use_route => :commontator
300
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
309
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
315
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
321
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
330
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
341
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
351
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
366
+ patch :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
- put :undelete, :id => @comment.id, :use_route => :commontator
374
+ patch :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
- put :upvote, :id => @comment.id, :use_route => :commontator
381
+ patch :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
- put :upvote, :id => @comment.id, :use_route => :commontator
388
+ patch :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
- put :upvote, :id => @comment.id, :use_route => :commontator
395
+ patch :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
- put :upvote, :id => @comment.id, :use_route => :commontator
406
+ patch :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
- put :upvote, :id => @comment.id, :use_route => :commontator
411
+ patch :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
- put :upvote, :id => @comment.id, :use_route => :commontator
418
+ patch :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
- put :downvote, :id => @comment.id, :use_route => :commontator
425
+ patch :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
- put :downvote, :id => @comment.id, :use_route => :commontator
432
+ patch :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
- put :downvote, :id => @comment.id, :use_route => :commontator
439
+ patch :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
- put :downvote, :id => @comment.id, :use_route => :commontator
450
+ patch :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
- put :downvote, :id => @comment.id, :use_route => :commontator
455
+ patch :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
- put :downvote, :id => @comment.id, :use_route => :commontator
462
+ patch :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
- put :unvote, :id => @comment.id, :use_route => :commontator
471
+ patch :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
- put :unvote, :id => @comment.id, :use_route => :commontator
478
+ patch :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
- put :unvote, :id => @comment.id, :use_route => :commontator
485
+ patch :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,21 +494,70 @@ module Commontator
494
494
  sign_in user2
495
495
 
496
496
  @comment.upvote_from(user2).must_equal true
497
- put :unvote, :id => @comment.id, :use_route => :commontator
497
+ patch :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
- put :unvote, :id => @comment.id, :use_route => :commontator
502
+ patch :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
- put :unvote, :id => @comment.id, :use_route => :commontator
508
+ patch :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
512
512
  end
513
+
514
+ it 'wont send mail if recipients empty' do
515
+ if defined?(CommentsController::SubscriptionsMailer)
516
+ CommentsController::SubscriptionsMailer.__send__(:initialize)
517
+ else
518
+ CommentsController::SubscriptionsMailer = MiniTest::Mock.new
519
+ end
520
+
521
+ user2 = DummyUser.create
522
+ user2.can_read = true
523
+
524
+ email = MiniTest::Mock.new.expect(:deliver, nil)
525
+ CommentsController::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
526
+
527
+ @user.can_read = true
528
+ sign_in @user
529
+
530
+ attributes = {:body => 'Something else'}
531
+ post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
532
+ assigns(:comment).errors.must_be_empty
533
+
534
+ proc { CommentsController::SubscriptionsMailer.verify }.must_raise(MockExpectationError)
535
+ proc { email.verify }.must_raise(MockExpectationError)
536
+ end
537
+
538
+ it 'must send mail if recipients not empty' do
539
+ if defined?(CommentsController::SubscriptionsMailer)
540
+ CommentsController::SubscriptionsMailer.__send__(:initialize)
541
+ else
542
+ CommentsController::SubscriptionsMailer = MiniTest::Mock.new
543
+ end
544
+
545
+ user2 = DummyUser.create
546
+ user2.can_read = true
547
+ @thread.subscribe(user2)
548
+
549
+ email = MiniTest::Mock.new.expect(:deliver, nil)
550
+ CommentsController::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
551
+
552
+ @user.can_read = true
553
+ sign_in @user
554
+
555
+ attributes = {:body => 'Something else'}
556
+ post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
557
+ assigns(:comment).errors.must_be_empty
558
+
559
+ CommentsController::SubscriptionsMailer.verify
560
+ email.verify
561
+ end
513
562
  end
514
563
  end
@@ -1,4 +1,4 @@
1
- require 'minitest_helper'
1
+ require 'test_helper'
2
2
 
3
3
  module Commontator
4
4
  describe SubscriptionsController do
@@ -6,29 +6,29 @@ module Commontator
6
6
  setup_controller_spec
7
7
  end
8
8
 
9
- it 'wont create unless authorized' do
10
- post :create, :thread_id => @thread.id, :use_route => :commontator
9
+ it 'wont subscribe unless authorized' do
10
+ patch :subscribe, :thread_id => @thread.id, :use_route => :commontator
11
11
  assert_response 403
12
12
  @thread.subscription_for(nil).must_be_nil
13
13
  @thread.subscription_for(@user).must_be_nil
14
14
 
15
15
  sign_in @user
16
- post :create, :thread_id => @thread.id, :use_route => :commontator
16
+ patch :subscribe, :thread_id => @thread.id, :use_route => :commontator
17
17
  assert_response 403
18
18
  @thread.subscription_for(@user).must_be_nil
19
19
 
20
20
  @thread.subscribe(@user)
21
21
  @user.can_read = true
22
- post :create, :thread_id => @thread.id, :use_route => :commontator
22
+ patch :subscribe, :thread_id => @thread.id, :use_route => :commontator
23
23
  assert_redirected_to @thread
24
24
  assigns(:thread).errors.wont_be_empty
25
25
  end
26
26
 
27
- it 'must create if authorized' do
27
+ it 'must subscribe if authorized' do
28
28
  sign_in @user
29
29
 
30
30
  @user.can_read = true
31
- post :create, :thread_id => @thread.id, :use_route => :commontator
31
+ patch :subscribe, :thread_id => @thread.id, :use_route => :commontator
32
32
  assert_redirected_to @thread
33
33
  assigns(:thread).errors.must_be_empty
34
34
  @thread.subscription_for(@user).wont_be_nil
@@ -36,7 +36,7 @@ module Commontator
36
36
  @thread.unsubscribe(@user)
37
37
  @user.can_read = false
38
38
  @user.can_edit = true
39
- post :create, :thread_id => @thread.id, :use_route => :commontator
39
+ patch :subscribe, :thread_id => @thread.id, :use_route => :commontator
40
40
  assert_redirected_to @thread
41
41
  assigns(:thread).errors.must_be_empty
42
42
  @thread.subscription_for(@user).wont_be_nil
@@ -44,27 +44,27 @@ module Commontator
44
44
  @thread.unsubscribe(@user)
45
45
  @user.can_edit = false
46
46
  @user.is_admin = true
47
- post :create, :thread_id => @thread.id, :use_route => :commontator
47
+ patch :subscribe, :thread_id => @thread.id, :use_route => :commontator
48
48
  assert_redirected_to @thread
49
49
  assigns(:thread).errors.must_be_empty
50
50
  @thread.subscription_for(@user).wont_be_nil
51
51
  end
52
52
 
53
- it 'wont destroy unless authorized' do
53
+ it 'wont unsubscribe unless authorized' do
54
54
  @thread.subscribe(@user)
55
- delete :destroy, :thread_id => @thread.id, :use_route => :commontator
55
+ patch :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
56
56
  assert_response 403
57
57
  @thread.subscription_for(nil).must_be_nil
58
58
  @thread.subscription_for(@user).wont_be_nil
59
59
 
60
60
  sign_in @user
61
- delete :destroy, :thread_id => @thread.id, :use_route => :commontator
61
+ patch :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
62
62
  assert_response 403
63
63
  @thread.subscription_for(@user).wont_be_nil
64
64
 
65
65
  @thread.unsubscribe(@user)
66
66
  @user.can_read = true
67
- delete :destroy, :thread_id => @thread.id, :use_route => :commontator
67
+ patch :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
68
68
  assert_redirected_to @thread
69
69
  assigns(:thread).errors.wont_be_empty
70
70
  end
@@ -74,7 +74,7 @@ module Commontator
74
74
 
75
75
  @thread.subscribe(@user)
76
76
  @user.can_read = true
77
- delete :destroy, :thread_id => @thread.id, :use_route => :commontator
77
+ patch :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
78
78
  assert_redirected_to @thread
79
79
  assigns(:thread).errors.must_be_empty
80
80
  @thread.subscription_for(@user).must_be_nil
@@ -82,7 +82,7 @@ module Commontator
82
82
  @thread.subscribe(@user)
83
83
  @user.can_read = false
84
84
  @user.can_edit = true
85
- delete :destroy, :thread_id => @thread.id, :use_route => :commontator
85
+ patch :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
86
86
  assert_redirected_to @thread
87
87
  assigns(:thread).errors.must_be_empty
88
88
  @thread.subscription_for(@user).must_be_nil
@@ -90,7 +90,7 @@ module Commontator
90
90
  @thread.subscribe(@user)
91
91
  @user.can_edit = false
92
92
  @user.is_admin = true
93
- delete :destroy, :thread_id => @thread.id, :use_route => :commontator
93
+ patch :unsubscribe, :thread_id => @thread.id, :use_route => :commontator
94
94
  assert_redirected_to @thread
95
95
  assigns(:thread).errors.must_be_empty
96
96
  @thread.subscription_for(@user).must_be_nil