commontator 0.4.1 → 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/README.md +35 -23
  2. data/app/assets/stylesheets/commontator/comments.css +1 -1
  3. data/app/assets/stylesheets/commontator/comments.css~ +0 -4
  4. data/app/controllers/commontator/application_controller.rb +4 -5
  5. data/app/controllers/commontator/application_controller.rb~ +5 -5
  6. data/app/controllers/commontator/comments_controller.rb +30 -30
  7. data/app/controllers/commontator/comments_controller.rb~ +31 -31
  8. data/app/controllers/commontator/subscriptions_controller.rb +8 -7
  9. data/app/controllers/commontator/subscriptions_controller.rb~ +6 -7
  10. data/app/controllers/commontator/threads_controller.rb +8 -9
  11. data/app/controllers/commontator/threads_controller.rb~ +9 -10
  12. data/app/helpers/commontator/comments_helper.rb~ +14 -24
  13. data/app/helpers/commontator/subscriptions_helper.rb~ +3 -3
  14. data/app/helpers/commontator/threads_helper.rb +0 -8
  15. data/app/helpers/commontator/threads_helper.rb~ +5 -5
  16. data/app/mailers/commontator/subscriptions_mailer.rb +8 -8
  17. data/app/mailers/commontator/subscriptions_mailer.rb~ +9 -10
  18. data/app/models/commontator/comment.rb +14 -6
  19. data/app/models/commontator/comment.rb~ +15 -12
  20. data/app/views/commontator/comments/_actions.html.erb +6 -5
  21. data/app/views/commontator/comments/_actions.html.erb~ +6 -5
  22. data/app/views/commontator/comments/_body.html.erb +2 -1
  23. data/app/views/commontator/comments/_body.html.erb~ +1 -2
  24. data/app/views/commontator/comments/_form.html.erb +8 -3
  25. data/app/views/commontator/comments/_form.html.erb~ +7 -4
  26. data/app/views/commontator/comments/_show.html.erb +11 -8
  27. data/app/views/commontator/comments/_show.html.erb~ +11 -8
  28. data/app/views/commontator/comments/_votes.html.erb +7 -6
  29. data/app/views/commontator/comments/create.js.erb +4 -2
  30. data/app/views/commontator/comments/delete.js.erb +5 -3
  31. data/app/views/commontator/comments/delete.js.erb~ +5 -3
  32. data/app/views/commontator/comments/update.js.erb +1 -1
  33. data/app/views/commontator/comments/update.js.erb~ +1 -1
  34. data/app/views/commontator/comments/vote.js.erb +2 -1
  35. data/app/views/commontator/shared/_thread.html.erb +17 -0
  36. data/app/views/commontator/shared/_thread.html.erb~ +16 -0
  37. data/app/views/commontator/shared/_thread_link.html.erb~ +16 -0
  38. data/app/views/commontator/subscriptions/_link.html.erb +3 -2
  39. data/app/views/commontator/subscriptions/subscribe.js.erb +2 -1
  40. data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +1 -1
  41. data/app/views/commontator/threads/_show.html.erb +18 -11
  42. data/app/views/commontator/threads/_show.html.erb~ +18 -11
  43. data/app/views/commontator/threads/show.js.erb +2 -1
  44. data/config/initializers/commontator.rb +14 -14
  45. data/db/migrate/0_install_commontator.rb +3 -3
  46. data/lib/commontator.rb +5 -6
  47. data/lib/commontator.rb~ +5 -6
  48. data/lib/commontator/acts_as_commontable.rb +2 -0
  49. data/lib/commontator/acts_as_commontator.rb +2 -0
  50. data/lib/commontator/controller_includes.rb +23 -0
  51. data/lib/commontator/controller_includes.rb~ +23 -0
  52. data/lib/commontator/shared_helper.rb +42 -0
  53. data/lib/commontator/shared_helper.rb~ +42 -0
  54. data/lib/commontator/shared_methods.rb~ +24 -0
  55. data/lib/commontator/version.rb +1 -1
  56. data/lib/commontator/version.rb~ +1 -1
  57. data/test/dummy/config/initializers/commontator.rb +15 -15
  58. data/test/dummy/db/development.sqlite3 +0 -0
  59. data/test/dummy/db/migrate/1_install_commontator.commontator.rb +3 -3
  60. data/test/dummy/db/schema.rb +3 -3
  61. data/test/dummy/log/development.log +64 -0
  62. metadata +10 -70
  63. data/app/assets/stylesheets/commontator/application.css~ +0 -88
  64. data/app/assets/stylesheets/commontator/threads.css~ +0 -13
  65. data/app/helpers/commontator/application_helper.rb~ +0 -11
  66. data/app/helpers/commontator/comments_helper.rb +0 -51
  67. data/app/helpers/commontator/commontable_helper.rb~ +0 -9
  68. data/app/helpers/commontator/commontator_helper.rb +0 -8
  69. data/app/helpers/commontator/commontator_helper.rb~ +0 -8
  70. data/app/helpers/commontator/subscriptions_helper.rb +0 -8
  71. data/app/mailers/commontator/subscription_mailer.rb~ +0 -38
  72. data/app/models/commontator/subscription.rb~ +0 -21
  73. data/app/models/commontator/thread.rb~ +0 -143
  74. data/app/views/commontator/comments/_votes.html.erb~ +0 -62
  75. data/app/views/commontator/comments/create.js.erb~ +0 -15
  76. data/app/views/commontator/comments/destroy.js.erb~ +0 -1
  77. data/app/views/commontator/comments/edit.html.erb~ +0 -6
  78. data/app/views/commontator/comments/edit.js.erb~ +0 -5
  79. data/app/views/commontator/comments/new.html.erb~ +0 -8
  80. data/app/views/commontator/comments/new.js.erb~ +0 -12
  81. data/app/views/commontator/comments/vote.js.erb~ +0 -5
  82. data/app/views/commontator/shared/_thread_link.html.erb +0 -13
  83. data/app/views/commontator/subscriptions/_index.html.erb~ +0 -16
  84. data/app/views/commontator/subscriptions/_link.html.erb~ +0 -15
  85. data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +0 -13
  86. data/app/views/commontator/subscriptions/create.js.erb~ +0 -5
  87. data/app/views/commontator/subscriptions/destroy.js.erb~ +0 -3
  88. data/app/views/commontator/subscriptions/index.html.erb~ +0 -16
  89. data/app/views/commontator/subscriptions/subscribe.js.erb~ +0 -5
  90. data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +0 -6
  91. data/app/views/commontator/threads/_actions.html.erb~ +0 -28
  92. data/app/views/commontator/threads/_link.html.erb~ +0 -14
  93. data/app/views/commontator/threads/close.js.erb~ +0 -5
  94. data/app/views/commontator/threads/show.html.erb~ +0 -3
  95. data/app/views/commontator/threads/show.js.erb~ +0 -6
  96. data/config/initializers/commontator.rb~ +0 -179
  97. data/config/routes.rb~ +0 -24
  98. data/db/migrate/0_install_commontator.rb~ +0 -48
  99. data/lib/commontator/acts_as_commontable.rb~ +0 -39
  100. data/lib/commontator/acts_as_commontator.rb~ +0 -28
  101. data/lib/commontator/commontable_config.rb~ +0 -13
  102. data/lib/commontator/commontator_config.rb~ +0 -13
  103. data/lib/commontator/routes.rb~ +0 -37
  104. data/lib/tasks/commontator_tasks.rake~ +0 -41
  105. data/test/dummy/config/initializers/commontator.rb~ +0 -179
  106. data/test/dummy/config/routes.rb~ +0 -3
  107. data/test/functional/comment_thread_subscriptions_controller_test.rb~ +0 -125
  108. data/test/functional/comments_controller_test.rb~ +0 -184
  109. data/test/functional/subscriptions_controller_test.rb~ +0 -122
  110. data/test/unit/comment_test.rb~ +0 -38
  111. data/test/unit/comment_thread_subscription_test.rb~ +0 -18
  112. data/test/unit/comment_thread_test.rb~ +0 -60
  113. data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +0 -7
  114. data/test/unit/helpers/comments_helper_test.rb~ +0 -7
  115. data/test/unit/helpers/subscriptions_helper_test.rb~ +0 -4
  116. data/test/unit/subscription_test.rb~ +0 -15
  117. data/test/unit/thread_test.rb~ +0 -57
@@ -1,37 +0,0 @@
1
- module ActionDispatch::Routing
2
- class Mapper
3
- def commontable
4
- namespace :commontator do
5
- resources :comment_commontable_threads, :only => [:show], :shallow => true do
6
- resources :comments, :except => [:index], :shallow => true
7
- put 'close', :on => :member
8
- put 'reopen', :on => :member
9
- get 'subscribe', :to => 'subscriptions#create',
10
- :as => 'subscribe',
11
- :on => :member
12
- get 'unsubscribe', :to => 'subscriptions#destroy',
13
- :as => 'unsubscribe',
14
- :on => :member
15
- end
16
- end
17
- end
18
-
19
- def commontator
20
- namespace :commontator do
21
- resources :subscriptions, :only => [:index], :shallow => true
22
- end
23
- end
24
-
25
- def commentable
26
- commontable
27
- end
28
-
29
- def commonter
30
- commontator
31
- end
32
-
33
- def commentator
34
- commontator
35
- end
36
- end
37
- end
@@ -1,41 +0,0 @@
1
- COPY_TASKS = ['assets/images', 'assets/stylesheets', 'views', 'mailers', 'helpers', 'controllers', 'models']
2
-
3
- namespace :commontator do
4
- namespace :install do
5
- desc "Copy initializers from commontator to application"
6
- task :initializers do
7
- Dir.glob(File.expand_path('../../../config/initializers/*.rb', __FILE__)) do |file|
8
- if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
9
- print "NOTE: Initializer #{File.basename(file)} from commontator has been skipped. Initializer with the same name already exists."
10
- else
11
- cp file, 'config/initializers', :verbose => false
12
- print "Copied initializer #{File.basename(file)} from commontator\n"
13
- end
14
- end
15
- end
16
- end
17
-
18
- namespace :copy do
19
- COPY_TASKS.each do |path|
20
- name = File.basename(path)
21
- desc "Copy #{name} from commontator to application"
22
- task name.to_sym do
23
- cp_r File.expand_path("../../../app/#{path}/commontator", __FILE__), "app/#{path}", :verbose => false
24
- print "Copied #{name} from commontator\n"
25
- end
26
- end
27
- end
28
-
29
- desc "Copy initializers and migrations from commontator to application"
30
- task :install do
31
- Rake::Task["commontator:install:initializers"].invoke
32
- Rake::Task["commontator:install:migrations"].invoke
33
- end
34
-
35
- desc "Copy assets, views, mailers, helpers, controllers and models from commontator to application"
36
- task :copy do
37
- COPY_TASKS.each do |path|
38
- Rake::Task["commontator:copy:#{File.basename(path)}"].invoke
39
- end
40
- end
41
- end
@@ -1,179 +0,0 @@
1
- # Change the settings below to suit your needs
2
- # All settings are initially set to their default values
3
- Commontator.configure do |config|
4
-
5
- # Engine Configuration
6
-
7
- # Method called on ApplicationController to return the current user
8
- # Default: 'current_user'
9
- config.current_user_method = 'current_user'
10
-
11
- # Proc that is called after any javascript runs (e.g. to clear flash)
12
- # It is passed the 'self' object from the view template, so you should be able to
13
- # access anything you normally could in a view template (by using, e.g. view.flash)
14
- # Should return a string containing JS to be appended to all Commontator JS responses
15
- # Default: lambda { |view| '$("#error_explanation").remove();' }
16
- config.javascript_proc = lambda { |view| '$("#error_explanation").remove();' }
17
-
18
-
19
- # Commontator (User model) Configuration
20
-
21
- # The name used if the commontator's name cannot be retrieved
22
- # Default: 'Anonymous'
23
- config.commontator_missing_name = 'Anonymous'
24
-
25
- # Whether the commontator's name is clickable in the comment view
26
- # Default: false
27
- config.commontator_name_clickable = false
28
-
29
- # The method that return the commontator's email address
30
- # Default: 'email'
31
- config.commontator_email_method = 'email'
32
-
33
- # The method that return the commontator's name
34
- # Default: ''
35
- config.commontator_name_method = ''
36
-
37
- # Method that returns true if the commontator is an admin for all threads
38
- # Admins can always delete other users' comments and close threads
39
- # Default: '' (no admins)
40
- config.is_admin_method = ''
41
-
42
-
43
- # Commontable (Commentable model) Configuration
44
-
45
- # What a comment is called in your application
46
- # Default: 'comment'
47
- config.comment_name = 'comment'
48
-
49
- # Verb used when creating comments (present)
50
- # Default: 'post'
51
- config.comment_create_verb_present = 'post'
52
-
53
- # Verb used when creating comments (past)
54
- # Default: 'posted'
55
- config.comment_create_verb_past = 'posted'
56
-
57
- # What a commontable is called in your application
58
- # If you have multiple commontable models,
59
- # you might want to pass this configuration value
60
- # as an argument to acts_as_commontable in each one
61
- # Default: 'commontable'
62
- config.commontable_name = 'commontable'
63
-
64
- # Proc that returns the commontable url that contains the thread
65
- # (defaults to the commontable show url)
66
- # Main application's routes can be accessed using main_app object
67
- # Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
68
- config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
69
-
70
- # Proc that returns the subscription email subject
71
- # Default:
72
- # lambda do |params|
73
- # "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
74
- # "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
75
- # end
76
- config.subscription_email_subject_proc = lambda do |params|
77
- "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
78
- "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
79
- end
80
-
81
- # The format of the timestamps used by Commontator
82
- # Default: '%b %d %Y, %I:%M %p'
83
- config.timestamp_format = '%b %d %Y, %I:%M %p'
84
-
85
- # Whether admins can edit other users' comments
86
- # Default: false
87
- config.admin_can_edit_comments = false
88
-
89
- # Whether users automatically subscribe to a thread when commenting
90
- # Default: false
91
- config.auto_subscribe_on_comment = false
92
-
93
- # Whether users can edit their own comments
94
- # Default: true
95
- config.can_edit_own_comments = true
96
-
97
- # Whether users can edit their own comments
98
- # after someone posted a newer comment
99
- # Default: false
100
- config.can_edit_old_comments = false
101
-
102
- # Whether users can delete their own comments
103
- # Default: false
104
- config.can_delete_own_comments = false
105
-
106
- # Whether users can delete their own comments
107
- # after someone posted a newer comment
108
- # Default: false
109
- config.can_delete_old_comments = false
110
-
111
- # Whether users can manually subscribe or unsubscribe to threads
112
- # Default: true
113
- config.can_subscribe_to_thread = true
114
-
115
- # Whether users can vote on other users' comments
116
- # Note: requires acts_as_votable gem installed
117
- # and configured for your application
118
- # Default: false
119
- config.comments_can_be_voted_on = false
120
-
121
- # Whether comments should be ordered by vote score
122
- # instead of by order posted
123
- # Default: false
124
- config.comments_ordered_by_votes = false
125
-
126
- # Whether users can read threads closed by admins
127
- # Default: true
128
- config.closed_threads_are_readable = true
129
-
130
- # Whether comments deleted by admins can be seen
131
- # (the content will still be hidden)
132
- # Default: true
133
- config.deleted_comments_are_visible = true
134
-
135
- # Method called on commontable to return its id
136
- # Default: 'id'
137
- config.commontable_id_method = 'id'
138
-
139
- # Method called on commontable and passed user as argument
140
- # If true, that user is a moderator for that particular commontable's thread
141
- # and is given admin-like capabilities for that thread only
142
- # Default: '' (no thread-specific moderators)
143
- config.can_edit_thread_method = ''
144
-
145
- # Method called on commontable and passed user as argument
146
- # If true, that user is allowed to read that commontable's thread
147
- # Default: '' (no read restrictions)
148
- config.can_read_thread_method = ''
149
-
150
- # Method called on commontable when a comment is created
151
- # Passed user, comment as arguments
152
- # Default: '' (no callback)
153
- config.comment_created_callback = ''
154
-
155
- # Method called on commontable when a comment is edited
156
- # Passed user, comment as arguments
157
- # Default: '' (no callback)
158
- config.comment_edited_callback = ''
159
-
160
- # Method called on commontable when a comment is deleted
161
- # Passed user, comment as arguments
162
- # Default: '' (no callback)
163
- config.comment_deleted_callback = ''
164
-
165
- # Method called on commontable when a thread is closed
166
- # Passed user as argument
167
- # Default: '' (no callback)
168
- config.thread_closed_callback = ''
169
-
170
- # Method called on commontable when a thread is subscribed to
171
- # Passed user as argument
172
- # Default: '' (no callback)
173
- config.subscribe_callback = ''
174
-
175
- # Method called on commontable when a thread is unsubscribed to
176
- # Passed user as argument
177
- # Default: '' (no callback)
178
- config.unsubscribe_callback = ''
179
- end
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- mount Commontator::Engine => "/commontator"
3
- end
@@ -1,125 +0,0 @@
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
@@ -1,184 +0,0 @@
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