commontator 0.1.46

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.
Files changed (156) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +35 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/images/commontator/downvote.png +0 -0
  5. data/app/assets/images/commontator/downvote_hover.png +0 -0
  6. data/app/assets/images/commontator/upvote.png +0 -0
  7. data/app/assets/images/commontator/upvote_hover.png +0 -0
  8. data/app/assets/stylesheets/commontator/application.css +13 -0
  9. data/app/assets/stylesheets/commontator/application.css~ +88 -0
  10. data/app/assets/stylesheets/commontator/comments.css +86 -0
  11. data/app/assets/stylesheets/commontator/comments.css~ +90 -0
  12. data/app/assets/stylesheets/commontator/threads.css +13 -0
  13. data/app/assets/stylesheets/commontator/threads.css~ +13 -0
  14. data/app/controllers/commontator/application_controller.rb +18 -0
  15. data/app/controllers/commontator/application_controller.rb~ +16 -0
  16. data/app/controllers/commontator/comments_controller.rb +143 -0
  17. data/app/controllers/commontator/comments_controller.rb~ +143 -0
  18. data/app/controllers/commontator/subscriptions_controller.rb +42 -0
  19. data/app/controllers/commontator/subscriptions_controller.rb~ +40 -0
  20. data/app/controllers/commontator/threads_controller.rb +42 -0
  21. data/app/controllers/commontator/threads_controller.rb~ +43 -0
  22. data/app/helpers/commontator/application_helper.rb +11 -0
  23. data/app/helpers/commontator/application_helper.rb~ +11 -0
  24. data/app/helpers/commontator/comments_helper.rb +47 -0
  25. data/app/helpers/commontator/comments_helper.rb~ +58 -0
  26. data/app/helpers/commontator/commontable_helper.rb~ +9 -0
  27. data/app/helpers/commontator/commontator_helper.rb +8 -0
  28. data/app/helpers/commontator/commontator_helper.rb~ +8 -0
  29. data/app/helpers/commontator/subscriptions_helper.rb +8 -0
  30. data/app/helpers/commontator/subscriptions_helper.rb~ +8 -0
  31. data/app/helpers/commontator/threads_helper.rb +21 -0
  32. data/app/helpers/commontator/threads_helper.rb~ +32 -0
  33. data/app/mailers/commontator/subscription_mailer.rb~ +38 -0
  34. data/app/mailers/commontator/subscriptions_mailer.rb +51 -0
  35. data/app/mailers/commontator/subscriptions_mailer.rb~ +51 -0
  36. data/app/models/commontator/comment.rb +84 -0
  37. data/app/models/commontator/comment.rb~ +84 -0
  38. data/app/models/commontator/subscription.rb +21 -0
  39. data/app/models/commontator/subscription.rb~ +21 -0
  40. data/app/models/commontator/thread.rb +138 -0
  41. data/app/models/commontator/thread.rb~ +141 -0
  42. data/app/views/commontator/comments/_actions.html.erb +32 -0
  43. data/app/views/commontator/comments/_actions.html.erb~ +33 -0
  44. data/app/views/commontator/comments/_body.html.erb +7 -0
  45. data/app/views/commontator/comments/_body.html.erb~ +8 -0
  46. data/app/views/commontator/comments/_form.html.erb +20 -0
  47. data/app/views/commontator/comments/_form.html.erb~ +21 -0
  48. data/app/views/commontator/comments/_show.html.erb +41 -0
  49. data/app/views/commontator/comments/_show.html.erb~ +45 -0
  50. data/app/views/commontator/comments/_votes.html.erb +60 -0
  51. data/app/views/commontator/comments/_votes.html.erb~ +62 -0
  52. data/app/views/commontator/comments/create.js.erb +15 -0
  53. data/app/views/commontator/comments/create.js.erb~ +15 -0
  54. data/app/views/commontator/comments/delete.js.erb +15 -0
  55. data/app/views/commontator/comments/delete.js.erb~ +15 -0
  56. data/app/views/commontator/comments/destroy.js.erb~ +1 -0
  57. data/app/views/commontator/comments/edit.html.erb +6 -0
  58. data/app/views/commontator/comments/edit.html.erb~ +6 -0
  59. data/app/views/commontator/comments/edit.js.erb +5 -0
  60. data/app/views/commontator/comments/edit.js.erb~ +5 -0
  61. data/app/views/commontator/comments/new.html.erb +8 -0
  62. data/app/views/commontator/comments/new.html.erb~ +8 -0
  63. data/app/views/commontator/comments/new.js.erb +12 -0
  64. data/app/views/commontator/comments/new.js.erb~ +12 -0
  65. data/app/views/commontator/comments/update.js.erb +7 -0
  66. data/app/views/commontator/comments/update.js.erb~ +7 -0
  67. data/app/views/commontator/comments/vote.js.erb +5 -0
  68. data/app/views/commontator/comments/vote.js.erb~ +5 -0
  69. data/app/views/commontator/commontator/_thread.html.erb +14 -0
  70. data/app/views/commontator/commontator/_thread.html.erb~ +15 -0
  71. data/app/views/commontator/subscriptions/_subscription_link.html.erb +12 -0
  72. data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +12 -0
  73. data/app/views/commontator/subscriptions/create.js.erb +5 -0
  74. data/app/views/commontator/subscriptions/create.js.erb~ +3 -0
  75. data/app/views/commontator/subscriptions/destroy.js.erb +5 -0
  76. data/app/views/commontator/subscriptions/destroy.js.erb~ +3 -0
  77. data/app/views/commontator/subscriptions/index.html.erb +16 -0
  78. data/app/views/commontator/subscriptions/index.html.erb~ +16 -0
  79. data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +14 -0
  80. data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +14 -0
  81. data/app/views/commontator/threads/_show.html.erb +26 -0
  82. data/app/views/commontator/threads/_show.html.erb~ +26 -0
  83. data/app/views/commontator/threads/show.html.erb +3 -0
  84. data/app/views/commontator/threads/show.js.erb +6 -0
  85. data/app/views/layouts/commontator/application.html.erb +14 -0
  86. data/config/initializers/commontator.rb +7 -0
  87. data/config/routes.rb +24 -0
  88. data/config/routes.rb~ +22 -0
  89. data/db/migrate/0_install_commontator.rb +40 -0
  90. data/db/migrate/0_install_commontator.rb~ +40 -0
  91. data/lib/commontator.rb +66 -0
  92. data/lib/commontator.rb~ +66 -0
  93. data/lib/commontator/acts_as_commontable.rb +39 -0
  94. data/lib/commontator/acts_as_commontable.rb~ +42 -0
  95. data/lib/commontator/acts_as_commontator.rb +28 -0
  96. data/lib/commontator/acts_as_commontator.rb~ +37 -0
  97. data/lib/commontator/commontable_config.rb +13 -0
  98. data/lib/commontator/commontator_config.rb +13 -0
  99. data/lib/commontator/engine.rb +5 -0
  100. data/lib/commontator/routes.rb~ +37 -0
  101. data/lib/commontator/version.rb +3 -0
  102. data/lib/commontator/version.rb~ +3 -0
  103. data/test/commontator_test.rb +7 -0
  104. data/test/dummy/README.rdoc +261 -0
  105. data/test/dummy/Rakefile +7 -0
  106. data/test/dummy/app/assets/javascripts/application.js +15 -0
  107. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  108. data/test/dummy/app/controllers/application_controller.rb +3 -0
  109. data/test/dummy/app/helpers/application_helper.rb +2 -0
  110. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  111. data/test/dummy/config.ru +4 -0
  112. data/test/dummy/config/application.rb +59 -0
  113. data/test/dummy/config/boot.rb +10 -0
  114. data/test/dummy/config/database.yml +25 -0
  115. data/test/dummy/config/environment.rb +5 -0
  116. data/test/dummy/config/environments/development.rb +37 -0
  117. data/test/dummy/config/environments/production.rb +67 -0
  118. data/test/dummy/config/environments/test.rb +37 -0
  119. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  120. data/test/dummy/config/initializers/inflections.rb +15 -0
  121. data/test/dummy/config/initializers/mime_types.rb +5 -0
  122. data/test/dummy/config/initializers/secret_token.rb +7 -0
  123. data/test/dummy/config/initializers/session_store.rb +8 -0
  124. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  125. data/test/dummy/config/locales/en.yml +5 -0
  126. data/test/dummy/config/routes.rb +4 -0
  127. data/test/dummy/db/development.sqlite3 +0 -0
  128. data/test/dummy/db/schema.rb +16 -0
  129. data/test/dummy/db/test.sqlite3 +0 -0
  130. data/test/dummy/log/development.log +204 -0
  131. data/test/dummy/public/404.html +26 -0
  132. data/test/dummy/public/422.html +26 -0
  133. data/test/dummy/public/500.html +25 -0
  134. data/test/dummy/public/favicon.ico +0 -0
  135. data/test/dummy/script/rails +6 -0
  136. data/test/functional/comment_thread_subscriptions_controller_test.rb~ +125 -0
  137. data/test/functional/comments_controller_test.rb +181 -0
  138. data/test/functional/comments_controller_test.rb~ +184 -0
  139. data/test/functional/subscriptions_controller_test.rb +122 -0
  140. data/test/functional/subscriptions_controller_test.rb~ +122 -0
  141. data/test/integration/navigation_test.rb +10 -0
  142. data/test/test_helper.rb +15 -0
  143. data/test/unit/comment_test.rb +35 -0
  144. data/test/unit/comment_test.rb~ +38 -0
  145. data/test/unit/comment_thread_subscription_test.rb~ +18 -0
  146. data/test/unit/comment_thread_test.rb~ +60 -0
  147. data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +7 -0
  148. data/test/unit/helpers/comments_helper_test.rb +4 -0
  149. data/test/unit/helpers/comments_helper_test.rb~ +7 -0
  150. data/test/unit/helpers/subscriptions_helper_test.rb +4 -0
  151. data/test/unit/helpers/subscriptions_helper_test.rb~ +4 -0
  152. data/test/unit/subscription_test.rb +15 -0
  153. data/test/unit/subscription_test.rb~ +15 -0
  154. data/test/unit/thread_test.rb +57 -0
  155. data/test/unit/thread_test.rb~ +57 -0
  156. metadata +301 -0
@@ -0,0 +1,122 @@
1
+ require 'test_helper'
2
+
3
+ class SubscriptionsControllerTest < ActionController::TestCase
4
+
5
+ setup do
6
+ @question = FactoryGirl.create(:simple_question)
7
+ @user = FactoryGirl.create(:user)
8
+ FactoryGirl.create(:project_question, :question => @question, :project => Project.default_for_user!(@user))
9
+ @published_question = make_simple_question(:method => :create, :published => true)
10
+ @user2 = FactoryGirl.create(:user)
11
+ end
12
+
13
+ test "should not get index not logged in" do
14
+ get :index
15
+ assert_redirected_to login_path
16
+ end
17
+
18
+ test "should get index" do
19
+ user_login
20
+ get :index
21
+ assert_response :success
22
+ end
23
+
24
+ test "should not create subscription not logged in" do
25
+ assert_difference('Subscription.count', 0) do
26
+ get :create, :question_id => @question.to_param
27
+ end
28
+
29
+ assert_redirected_to login_path
30
+ end
31
+
32
+ test "should not create subscription not authorized" do
33
+ user_login
34
+ assert_difference('Subscription.count', 0) do
35
+ get :create, :question_id => @question.to_param
36
+ end
37
+
38
+ assert_response(403)
39
+ end
40
+
41
+ test "should not create subscription already subscribed" do
42
+ sign_in @user
43
+ FactoryGirl.create(:subscription,
44
+ :user => @user, :thread => @question.thread)
45
+ assert_difference('Subscription.count', 0) do
46
+ get :create, :question_id => @question.to_param
47
+ end
48
+
49
+ assert_redirected_to question_comments_path(@question.to_param)
50
+ end
51
+
52
+ test "should create subscription" do
53
+ sign_in @user
54
+ assert_difference('Subscription.count') do
55
+ get :create, :question_id => @question.to_param
56
+ end
57
+
58
+ assert_redirected_to question_comments_path(@question.to_param)
59
+ end
60
+
61
+ test "should create subscription published question" do
62
+ user_login
63
+ assert_difference('Subscription.count') do
64
+ get :create, :question_id => @published_question.to_param
65
+ end
66
+
67
+ assert_redirected_to question_comments_path(@published_question.to_param)
68
+ end
69
+
70
+ test "should not destroy comment_thread_subscription not logged in" do
71
+ FactoryGirl.create(:comment_thread_subscription,
72
+ :user => @user, :comment_thread => @question.comment_thread)
73
+ assert_difference('CommentThreadSubscription.count', 0) do
74
+ get :destroy, :question_id => @question.to_param
75
+ end
76
+
77
+ assert_redirected_to login_path
78
+ end
79
+
80
+ test "should not destroy comment_thread_subscription not authorized" do
81
+ user_login
82
+ FactoryGirl.create(:comment_thread_subscription,
83
+ :user => @user, :comment_thread => @question.comment_thread)
84
+ assert_difference('CommentThreadSubscription.count', 0) do
85
+ get :destroy, :question_id => @question.to_param
86
+ end
87
+
88
+ assert_response(403)
89
+ end
90
+
91
+ test "should not destroy comment_thread_subscription no subscription" do
92
+ sign_in @user
93
+ assert_difference('CommentThreadSubscription.count', 0) do
94
+ get :destroy, :question_id => @question.to_param
95
+ end
96
+
97
+ assert_redirected_to question_comments_path(@question.to_param)
98
+ end
99
+
100
+ test "should destroy comment_thread_subscription" do
101
+ sign_in @user
102
+ FactoryGirl.create(:comment_thread_subscription,
103
+ :user => @user, :comment_thread => @question.comment_thread)
104
+ assert_difference('CommentThreadSubscription.count', -1) do
105
+ get :destroy, :question_id => @question.to_param
106
+ end
107
+
108
+ assert_redirected_to question_comments_path(@question.to_param)
109
+ end
110
+
111
+ test "should destroy comment_thread_subscription published question" do
112
+ sign_in @user2
113
+ FactoryGirl.create(:comment_thread_subscription,
114
+ :user => @user2, :comment_thread => @published_question.comment_thread)
115
+ assert_difference('CommentThreadSubscription.count', -1) do
116
+ get :destroy, :question_id => @published_question.to_param
117
+ end
118
+
119
+ assert_redirected_to question_comments_path(@published_question.to_param)
120
+ end
121
+
122
+ end
@@ -0,0 +1,122 @@
1
+ require 'test_helper'
2
+
3
+ class CommentThreadSubscriptionsControllerTest < ActionController::TestCase
4
+
5
+ setup do
6
+ @question = FactoryGirl.create(:simple_question)
7
+ @user = FactoryGirl.create(:user)
8
+ FactoryGirl.create(:project_question, :question => @question, :project => Project.default_for_user!(@user))
9
+ @published_question = make_simple_question(:method => :create, :published => true)
10
+ @user2 = FactoryGirl.create(:user)
11
+ end
12
+
13
+ test "should not get index not logged in" do
14
+ get :index
15
+ assert_redirected_to login_path
16
+ end
17
+
18
+ test "should get index" do
19
+ user_login
20
+ get :index
21
+ assert_response :success
22
+ end
23
+
24
+ test "should not create comment_thread_subscription not logged in" do
25
+ assert_difference('CommentThreadSubscription.count', 0) do
26
+ get :create, :question_id => @question.to_param
27
+ end
28
+
29
+ assert_redirected_to login_path
30
+ end
31
+
32
+ test "should not create comment_thread_subscription not authorized" do
33
+ user_login
34
+ assert_difference('CommentThreadSubscription.count', 0) do
35
+ get :create, :question_id => @question.to_param
36
+ end
37
+
38
+ assert_response(403)
39
+ end
40
+
41
+ test "should not create comment_thread_subscription already subscribed" do
42
+ sign_in @user
43
+ FactoryGirl.create(:comment_thread_subscription,
44
+ :user => @user, :comment_thread => @question.comment_thread)
45
+ assert_difference('CommentThreadSubscription.count', 0) do
46
+ get :create, :question_id => @question.to_param
47
+ end
48
+
49
+ assert_redirected_to question_comments_path(@question.to_param)
50
+ end
51
+
52
+ test "should create comment_thread_subscription" do
53
+ sign_in @user
54
+ assert_difference('CommentThreadSubscription.count') do
55
+ get :create, :question_id => @question.to_param
56
+ end
57
+
58
+ assert_redirected_to question_comments_path(@question.to_param)
59
+ end
60
+
61
+ test "should create comment_thread_subscription published question" do
62
+ user_login
63
+ assert_difference('CommentThreadSubscription.count') do
64
+ get :create, :question_id => @published_question.to_param
65
+ end
66
+
67
+ assert_redirected_to question_comments_path(@published_question.to_param)
68
+ end
69
+
70
+ test "should not destroy comment_thread_subscription not logged in" do
71
+ FactoryGirl.create(:comment_thread_subscription,
72
+ :user => @user, :comment_thread => @question.comment_thread)
73
+ assert_difference('CommentThreadSubscription.count', 0) do
74
+ get :destroy, :question_id => @question.to_param
75
+ end
76
+
77
+ assert_redirected_to login_path
78
+ end
79
+
80
+ test "should not destroy comment_thread_subscription not authorized" do
81
+ user_login
82
+ FactoryGirl.create(:comment_thread_subscription,
83
+ :user => @user, :comment_thread => @question.comment_thread)
84
+ assert_difference('CommentThreadSubscription.count', 0) do
85
+ get :destroy, :question_id => @question.to_param
86
+ end
87
+
88
+ assert_response(403)
89
+ end
90
+
91
+ test "should not destroy comment_thread_subscription no subscription" do
92
+ sign_in @user
93
+ assert_difference('CommentThreadSubscription.count', 0) do
94
+ get :destroy, :question_id => @question.to_param
95
+ end
96
+
97
+ assert_redirected_to question_comments_path(@question.to_param)
98
+ end
99
+
100
+ test "should destroy comment_thread_subscription" do
101
+ sign_in @user
102
+ FactoryGirl.create(:comment_thread_subscription,
103
+ :user => @user, :comment_thread => @question.comment_thread)
104
+ assert_difference('CommentThreadSubscription.count', -1) do
105
+ get :destroy, :question_id => @question.to_param
106
+ end
107
+
108
+ assert_redirected_to question_comments_path(@question.to_param)
109
+ end
110
+
111
+ test "should destroy comment_thread_subscription published question" do
112
+ sign_in @user2
113
+ FactoryGirl.create(:comment_thread_subscription,
114
+ :user => @user2, :comment_thread => @published_question.comment_thread)
115
+ assert_difference('CommentThreadSubscription.count', -1) do
116
+ get :destroy, :question_id => @published_question.to_param
117
+ end
118
+
119
+ assert_redirected_to question_comments_path(@published_question.to_param)
120
+ end
121
+
122
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
15
+ end
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ class CommentTest < ActiveSupport::TestCase
4
+
5
+ test "cannot mass-assign comment_thread, creator" do
6
+ ct = FactoryGirl.create(:comment_thread)
7
+ u = FactoryGirl.create(:user)
8
+ c = Comment.new(:comment_thread => ct, :creator => u)
9
+ assert c.comment_thread != ct
10
+ assert c.creator != u
11
+ end
12
+
13
+ test "is_modified" do
14
+ c = FactoryGirl.create(:comment)
15
+ assert !c.is_modified?
16
+ c.message = 'Another message'
17
+ c.save!
18
+ assert c.is_modified?
19
+ end
20
+
21
+ test "must have comment_thread and creator" do
22
+ ct = FactoryGirl.create(:comment_thread)
23
+ u = FactoryGirl.create(:user)
24
+ c = Comment.new(:message => "Some message")
25
+ assert !c.save
26
+ c.comment_thread = ct
27
+ assert !c.save
28
+ c.comment_thread = nil
29
+ c.creator = u
30
+ assert !c.save
31
+ c.comment_thread = ct
32
+ c.save!
33
+ end
34
+
35
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
+ # License version 3 or later. See the COPYRIGHT file for details.
3
+
4
+ require 'test_helper'
5
+
6
+ class CommentTest < ActiveSupport::TestCase
7
+
8
+ test "cannot mass-assign comment_thread, creator" do
9
+ ct = FactoryGirl.create(:comment_thread)
10
+ u = FactoryGirl.create(:user)
11
+ c = Comment.new(:comment_thread => ct, :creator => u)
12
+ assert c.comment_thread != ct
13
+ assert c.creator != u
14
+ end
15
+
16
+ test "is_modified" do
17
+ c = FactoryGirl.create(:comment)
18
+ assert !c.is_modified?
19
+ c.message = 'Another message'
20
+ c.save!
21
+ assert c.is_modified?
22
+ end
23
+
24
+ test "must have comment_thread and creator" do
25
+ ct = FactoryGirl.create(:comment_thread)
26
+ u = FactoryGirl.create(:user)
27
+ c = Comment.new(:message => "Some message")
28
+ assert !c.save
29
+ c.comment_thread = ct
30
+ assert !c.save
31
+ c.comment_thread = nil
32
+ c.creator = u
33
+ assert !c.save
34
+ c.comment_thread = ct
35
+ c.save!
36
+ end
37
+
38
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
+ # License version 3 or later. See the COPYRIGHT file for details.
3
+
4
+ require 'test_helper'
5
+
6
+ class CommentThreadSubscriptionTest < ActiveSupport::TestCase
7
+
8
+ test 'one comment_thread_subscription per user per thread' do
9
+ u = FactoryGirl.create(:user)
10
+ ct = FactoryGirl.create(:comment_thread)
11
+ cts0 = CommentThreadSubscription.create(:user => u, :comment_thread => ct)
12
+ cts1 = CommentThreadSubscription.new(:user => u, :comment_thread => ct)
13
+ assert !cts1.save
14
+ cts0.destroy
15
+ cts1.save!
16
+ end
17
+
18
+ end
@@ -0,0 +1,60 @@
1
+ # Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
+ # License version 3 or later. See the COPYRIGHT file for details.
3
+
4
+ require 'test_helper'
5
+
6
+ class CommentThreadTest < ActiveSupport::TestCase
7
+
8
+ test 'cannot mass-assign commentable, comments and comment_thread_subscriptions' do
9
+ sq = FactoryGirl.create(:simple_question)
10
+ c = [FactoryGirl.create(:comment)]
11
+ cts = [FactoryGirl.create(:comment_thread_subscription)]
12
+ ct = CommentThread.new(:commentable => sq,
13
+ :comments => c,
14
+ :comment_thread_subscriptions => cts)
15
+ assert ct.commentable != sq
16
+ assert ct.comments != c
17
+ assert ct.comment_thread_subscriptions != cts
18
+ end
19
+
20
+ test 'clear' do
21
+ u = FactoryGirl.create(:user)
22
+ q = FactoryGirl.create(:simple_question)
23
+ ct = q.comment_thread
24
+ c = Comment.new
25
+ c.comment_thread = ct
26
+ c.creator = u
27
+ c.save!
28
+
29
+ assert !q.comment_thread.comments.empty?
30
+ assert_equal q.comment_thread, ct
31
+
32
+ ct.clear!
33
+ q.reload
34
+
35
+ assert q.comment_thread.comments.empty?
36
+ assert q.comment_thread != ct
37
+ end
38
+
39
+ test 'subscribe' do
40
+ u = FactoryGirl.create(:user)
41
+ ct = FactoryGirl.create(:comment_thread)
42
+
43
+ assert !ct.subscription_for(u)
44
+ assert ct.subscribe!(u)
45
+ assert ct.subscription_for(u)
46
+ assert ct.subscribe!(u)
47
+ end
48
+
49
+ test 'unsubscribe' do
50
+ u = FactoryGirl.create(:user)
51
+ ct = FactoryGirl.create(:comment_thread)
52
+
53
+ assert !ct.unsubscribe!(u)
54
+ assert ct.subscribe!(u)
55
+ assert ct.subscription_for(u)
56
+ assert ct.unsubscribe!(u)
57
+ assert !ct.subscription_for(u)
58
+ end
59
+
60
+ end
@@ -0,0 +1,7 @@
1
+ # Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
+ # License version 3 or later. See the COPYRIGHT file for details.
3
+
4
+ require 'test_helper'
5
+
6
+ class CommentThreadSubscriptionsHelperTest < ActionView::TestCase
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class CommentsHelperTest < ActionView::TestCase
4
+ end