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,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,125 @@
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 CommentThreadSubscriptionsControllerTest < ActionController::TestCase
7
+
8
+ setup do
9
+ @question = FactoryGirl.create(:simple_question)
10
+ @user = FactoryGirl.create(:user)
11
+ FactoryGirl.create(:project_question, :question => @question, :project => Project.default_for_user!(@user))
12
+ @published_question = make_simple_question(:method => :create, :published => true)
13
+ @user2 = FactoryGirl.create(:user)
14
+ end
15
+
16
+ test "should not get index not logged in" do
17
+ get :index
18
+ assert_redirected_to login_path
19
+ end
20
+
21
+ test "should get index" do
22
+ user_login
23
+ get :index
24
+ assert_response :success
25
+ end
26
+
27
+ test "should not create comment_thread_subscription not logged in" do
28
+ assert_difference('CommentThreadSubscription.count', 0) do
29
+ get :create, :question_id => @question.to_param
30
+ end
31
+
32
+ assert_redirected_to login_path
33
+ end
34
+
35
+ test "should not create comment_thread_subscription not authorized" do
36
+ user_login
37
+ assert_difference('CommentThreadSubscription.count', 0) do
38
+ get :create, :question_id => @question.to_param
39
+ end
40
+
41
+ assert_response(403)
42
+ end
43
+
44
+ test "should not create comment_thread_subscription already subscribed" do
45
+ sign_in @user
46
+ FactoryGirl.create(:comment_thread_subscription,
47
+ :user => @user, :comment_thread => @question.comment_thread)
48
+ assert_difference('CommentThreadSubscription.count', 0) do
49
+ get :create, :question_id => @question.to_param
50
+ end
51
+
52
+ assert_redirected_to question_comments_path(@question.to_param)
53
+ end
54
+
55
+ test "should create comment_thread_subscription" do
56
+ sign_in @user
57
+ assert_difference('CommentThreadSubscription.count') do
58
+ get :create, :question_id => @question.to_param
59
+ end
60
+
61
+ assert_redirected_to question_comments_path(@question.to_param)
62
+ end
63
+
64
+ test "should create comment_thread_subscription published question" do
65
+ user_login
66
+ assert_difference('CommentThreadSubscription.count') do
67
+ get :create, :question_id => @published_question.to_param
68
+ end
69
+
70
+ assert_redirected_to question_comments_path(@published_question.to_param)
71
+ end
72
+
73
+ test "should not destroy comment_thread_subscription not logged in" do
74
+ FactoryGirl.create(:comment_thread_subscription,
75
+ :user => @user, :comment_thread => @question.comment_thread)
76
+ assert_difference('CommentThreadSubscription.count', 0) do
77
+ get :destroy, :question_id => @question.to_param
78
+ end
79
+
80
+ assert_redirected_to login_path
81
+ end
82
+
83
+ test "should not destroy comment_thread_subscription not authorized" do
84
+ user_login
85
+ FactoryGirl.create(:comment_thread_subscription,
86
+ :user => @user, :comment_thread => @question.comment_thread)
87
+ assert_difference('CommentThreadSubscription.count', 0) do
88
+ get :destroy, :question_id => @question.to_param
89
+ end
90
+
91
+ assert_response(403)
92
+ end
93
+
94
+ test "should not destroy comment_thread_subscription no subscription" do
95
+ sign_in @user
96
+ assert_difference('CommentThreadSubscription.count', 0) do
97
+ get :destroy, :question_id => @question.to_param
98
+ end
99
+
100
+ assert_redirected_to question_comments_path(@question.to_param)
101
+ end
102
+
103
+ test "should destroy comment_thread_subscription" do
104
+ sign_in @user
105
+ FactoryGirl.create(:comment_thread_subscription,
106
+ :user => @user, :comment_thread => @question.comment_thread)
107
+ assert_difference('CommentThreadSubscription.count', -1) do
108
+ get :destroy, :question_id => @question.to_param
109
+ end
110
+
111
+ assert_redirected_to question_comments_path(@question.to_param)
112
+ end
113
+
114
+ test "should destroy comment_thread_subscription published question" do
115
+ sign_in @user2
116
+ FactoryGirl.create(:comment_thread_subscription,
117
+ :user => @user2, :comment_thread => @published_question.comment_thread)
118
+ assert_difference('CommentThreadSubscription.count', -1) do
119
+ get :destroy, :question_id => @published_question.to_param
120
+ end
121
+
122
+ assert_redirected_to question_comments_path(@published_question.to_param)
123
+ end
124
+
125
+ end
@@ -0,0 +1,181 @@
1
+ require 'test_helper'
2
+
3
+ class CommentsControllerTest < ActionController::TestCase
4
+
5
+ setup do
6
+ @comment = FactoryGirl.create(:comment)
7
+ @question = @comment.comment_thread.commentable
8
+ @user = @comment.creator
9
+ FactoryGirl.create(:project_question, :question => @question, :project => Project.default_for_user!(@user))
10
+ @published_question = make_simple_question(:method => :create, :published => true)
11
+ @published_comment = FactoryGirl.create(:comment,
12
+ :comment_thread => @published_question.comment_thread)
13
+ end
14
+
15
+ test "should not get index not logged in" do
16
+ get :index, :question_id => @question.to_param
17
+ assert_redirected_to login_path
18
+ end
19
+
20
+ test "should not get index not authorized" do
21
+ user_login
22
+ get :index, :question_id => @question.to_param
23
+ assert_response(403)
24
+ end
25
+
26
+ test "should get index" do
27
+ sign_in @user
28
+ get :index, :question_id => @question.to_param
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get index published question" do
33
+ user_login
34
+ get :index, :question_id => @published_question.to_param
35
+ assert_response :success
36
+ end
37
+
38
+ test "should not get new not logged in" do
39
+ get :new, :question_id => @question.to_param
40
+ assert_redirected_to login_path
41
+ end
42
+
43
+ test "should not get new not authorized" do
44
+ user_login
45
+ get :new, :question_id => @question.to_param
46
+ assert_response(403)
47
+ end
48
+
49
+ test "should get new" do
50
+ sign_in @user
51
+ get :new, :question_id => @question.to_param
52
+ assert_response :success
53
+ assert_not_nil assigns(:comments)
54
+ end
55
+
56
+ test "should get new published question" do
57
+ user_login
58
+ get :new, :question_id => @published_question.to_param
59
+ assert_response :success
60
+ assert_not_nil assigns(:comments)
61
+ end
62
+
63
+ test "should not create comment not logged in" do
64
+ assert_difference('Comment.count', 0) do
65
+ post :create, :question_id => @question.to_param, :comment => @comment.attributes
66
+ end
67
+
68
+ assert_redirected_to login_path
69
+ end
70
+
71
+ test "should not create comment not authorized" do
72
+ user_login
73
+ assert_difference('Comment.count', 0) do
74
+ post :create, :question_id => @question.to_param, :comment => @comment.attributes
75
+ end
76
+
77
+ assert_response(403)
78
+ end
79
+
80
+ test "should create comment" do
81
+ sign_in @user
82
+ assert_difference('Comment.count') do
83
+ post :create, :question_id => @question.to_param, :comment => @comment.attributes
84
+ end
85
+
86
+ assert_redirected_to question_comments_path(@question.to_param)
87
+ end
88
+
89
+ test "should create comment published question" do
90
+ user_login
91
+ assert_difference('Comment.count') do
92
+ post :create, :question_id => @published_question.to_param, :comment => @comment.attributes
93
+ end
94
+
95
+ assert_redirected_to question_comments_path(@published_question.to_param)
96
+ end
97
+
98
+ test "should not show comment not logged in" do
99
+ get :show, :id => @comment.to_param
100
+ assert_redirected_to login_path
101
+ end
102
+
103
+ test "should not show comment not authorized" do
104
+ user_login
105
+ get :show, :id => @comment.to_param
106
+ assert_response(403)
107
+ end
108
+
109
+ test "should show comment" do
110
+ sign_in @user
111
+ get :show, :id => @comment.to_param
112
+ assert_response :success
113
+ end
114
+
115
+ test "should show comment published question" do
116
+ user_login
117
+ get :show, :id => @published_comment.to_param
118
+ assert_response :success
119
+ end
120
+
121
+ test "should not get edit not logged in" do
122
+ get :edit, :id => @comment.to_param
123
+ assert_redirected_to login_path
124
+ end
125
+
126
+ test "should not get edit not authorized" do
127
+ user_login
128
+ get :edit, :id => @comment.to_param
129
+ assert_response(403)
130
+ end
131
+
132
+ test "should get edit" do
133
+ sign_in @user
134
+ get :edit, :id => @comment.to_param
135
+ assert_response :success
136
+ end
137
+
138
+ test "should not update comment not logged in" do
139
+ put :update, :id => @comment.to_param
140
+ assert_redirected_to login_path
141
+ end
142
+
143
+ test "should not update comment not authorized" do
144
+ user_login
145
+ put :update, :id => @comment.to_param
146
+ assert_response(403)
147
+ end
148
+
149
+ test "should update comment" do
150
+ sign_in @user
151
+ put :update, :id => @comment.to_param
152
+ assert_redirected_to question_comments_path(@question.to_param)
153
+ end
154
+
155
+ test "should not destroy comment not logged in" do
156
+ assert_difference('Comment.count', 0) do
157
+ delete :destroy, :id => @comment.to_param
158
+ end
159
+
160
+ assert_redirected_to login_path
161
+ end
162
+
163
+ test "should not destroy comment not authorized" do
164
+ user_login
165
+ assert_difference('Comment.count', 0) do
166
+ delete :destroy, :id => @comment.to_param
167
+ end
168
+
169
+ assert_response(403)
170
+ end
171
+
172
+ test "should destroy comment" do
173
+ sign_in @user
174
+ assert_difference('Comment.count', -1) do
175
+ delete :destroy, :id => @comment.to_param
176
+ end
177
+
178
+ assert_redirected_to question_comments_path(@question.to_param)
179
+ end
180
+
181
+ end
@@ -0,0 +1,184 @@
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 CommentsControllerTest < ActionController::TestCase
7
+
8
+ setup do
9
+ @comment = FactoryGirl.create(:comment)
10
+ @question = @comment.comment_thread.commentable
11
+ @user = @comment.creator
12
+ FactoryGirl.create(:project_question, :question => @question, :project => Project.default_for_user!(@user))
13
+ @published_question = make_simple_question(:method => :create, :published => true)
14
+ @published_comment = FactoryGirl.create(:comment,
15
+ :comment_thread => @published_question.comment_thread)
16
+ end
17
+
18
+ test "should not get index not logged in" do
19
+ get :index, :question_id => @question.to_param
20
+ assert_redirected_to login_path
21
+ end
22
+
23
+ test "should not get index not authorized" do
24
+ user_login
25
+ get :index, :question_id => @question.to_param
26
+ assert_response(403)
27
+ end
28
+
29
+ test "should get index" do
30
+ sign_in @user
31
+ get :index, :question_id => @question.to_param
32
+ assert_response :success
33
+ end
34
+
35
+ test "should get index published question" do
36
+ user_login
37
+ get :index, :question_id => @published_question.to_param
38
+ assert_response :success
39
+ end
40
+
41
+ test "should not get new not logged in" do
42
+ get :new, :question_id => @question.to_param
43
+ assert_redirected_to login_path
44
+ end
45
+
46
+ test "should not get new not authorized" do
47
+ user_login
48
+ get :new, :question_id => @question.to_param
49
+ assert_response(403)
50
+ end
51
+
52
+ test "should get new" do
53
+ sign_in @user
54
+ get :new, :question_id => @question.to_param
55
+ assert_response :success
56
+ assert_not_nil assigns(:comments)
57
+ end
58
+
59
+ test "should get new published question" do
60
+ user_login
61
+ get :new, :question_id => @published_question.to_param
62
+ assert_response :success
63
+ assert_not_nil assigns(:comments)
64
+ end
65
+
66
+ test "should not create comment not logged in" do
67
+ assert_difference('Comment.count', 0) do
68
+ post :create, :question_id => @question.to_param, :comment => @comment.attributes
69
+ end
70
+
71
+ assert_redirected_to login_path
72
+ end
73
+
74
+ test "should not create comment not authorized" do
75
+ user_login
76
+ assert_difference('Comment.count', 0) do
77
+ post :create, :question_id => @question.to_param, :comment => @comment.attributes
78
+ end
79
+
80
+ assert_response(403)
81
+ end
82
+
83
+ test "should create comment" do
84
+ sign_in @user
85
+ assert_difference('Comment.count') do
86
+ post :create, :question_id => @question.to_param, :comment => @comment.attributes
87
+ end
88
+
89
+ assert_redirected_to question_comments_path(@question.to_param)
90
+ end
91
+
92
+ test "should create comment published question" do
93
+ user_login
94
+ assert_difference('Comment.count') do
95
+ post :create, :question_id => @published_question.to_param, :comment => @comment.attributes
96
+ end
97
+
98
+ assert_redirected_to question_comments_path(@published_question.to_param)
99
+ end
100
+
101
+ test "should not show comment not logged in" do
102
+ get :show, :id => @comment.to_param
103
+ assert_redirected_to login_path
104
+ end
105
+
106
+ test "should not show comment not authorized" do
107
+ user_login
108
+ get :show, :id => @comment.to_param
109
+ assert_response(403)
110
+ end
111
+
112
+ test "should show comment" do
113
+ sign_in @user
114
+ get :show, :id => @comment.to_param
115
+ assert_response :success
116
+ end
117
+
118
+ test "should show comment published question" do
119
+ user_login
120
+ get :show, :id => @published_comment.to_param
121
+ assert_response :success
122
+ end
123
+
124
+ test "should not get edit not logged in" do
125
+ get :edit, :id => @comment.to_param
126
+ assert_redirected_to login_path
127
+ end
128
+
129
+ test "should not get edit not authorized" do
130
+ user_login
131
+ get :edit, :id => @comment.to_param
132
+ assert_response(403)
133
+ end
134
+
135
+ test "should get edit" do
136
+ sign_in @user
137
+ get :edit, :id => @comment.to_param
138
+ assert_response :success
139
+ end
140
+
141
+ test "should not update comment not logged in" do
142
+ put :update, :id => @comment.to_param
143
+ assert_redirected_to login_path
144
+ end
145
+
146
+ test "should not update comment not authorized" do
147
+ user_login
148
+ put :update, :id => @comment.to_param
149
+ assert_response(403)
150
+ end
151
+
152
+ test "should update comment" do
153
+ sign_in @user
154
+ put :update, :id => @comment.to_param
155
+ assert_redirected_to question_comments_path(@question.to_param)
156
+ end
157
+
158
+ test "should not destroy comment not logged in" do
159
+ assert_difference('Comment.count', 0) do
160
+ delete :destroy, :id => @comment.to_param
161
+ end
162
+
163
+ assert_redirected_to login_path
164
+ end
165
+
166
+ test "should not destroy comment not authorized" do
167
+ user_login
168
+ assert_difference('Comment.count', 0) do
169
+ delete :destroy, :id => @comment.to_param
170
+ end
171
+
172
+ assert_response(403)
173
+ end
174
+
175
+ test "should destroy comment" do
176
+ sign_in @user
177
+ assert_difference('Comment.count', -1) do
178
+ delete :destroy, :id => @comment.to_param
179
+ end
180
+
181
+ assert_redirected_to question_comments_path(@question.to_param)
182
+ end
183
+
184
+ end