commontator 4.10.3 → 4.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -6
- data/app/models/commontator/subscription.rb +4 -2
- data/app/models/commontator/subscription.rb~ +23 -0
- data/app/views/commontator/comments/_votes.html.erb +8 -8
- data/config/locales/{commontator/en.yml → en.yml} +0 -0
- data/lib/commontator/engine.rb +0 -3
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +3 -0
- data/spec/controllers/commontator/comments_controller_spec.rb +566 -0
- data/spec/controllers/commontator/comments_controller_spec.rb~ +565 -0
- data/spec/controllers/commontator/subscriptions_controller_spec.rb +102 -0
- data/spec/controllers/commontator/subscriptions_controller_spec.rb~ +101 -0
- data/spec/controllers/commontator/threads_controller_spec.rb +130 -0
- data/spec/controllers/commontator/threads_controller_spec.rb~ +130 -0
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/README.md~ +3 -0
- data/spec/dummy/Rakefile +1 -0
- data/spec/dummy/Rakefile~ +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +1 -0
- data/spec/dummy/app/assets/javascripts/application.js~ +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css~ +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/controllers/application_controller.rb~ +3 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb +12 -6
- data/spec/dummy/app/controllers/dummy_models_controller.rb~ +34 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -3
- data/spec/dummy/app/helpers/application_helper.rb~ +15 -0
- data/spec/dummy/app/models/dummy_model.rb +1 -0
- data/spec/dummy/app/models/dummy_model.rb~ +3 -0
- data/spec/dummy/app/models/dummy_user.rb +2 -1
- data/spec/dummy/app/models/dummy_user.rb~ +13 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb~ +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb~ +14 -0
- data/spec/dummy/config.ru +1 -0
- data/spec/dummy/config.ru~ +4 -0
- data/spec/dummy/config/application.rb +1 -0
- data/spec/dummy/config/application.rb~ +26 -0
- data/spec/dummy/config/boot.rb +1 -0
- data/spec/dummy/config/boot.rb~ +5 -0
- data/spec/dummy/config/database.yml +1 -0
- data/spec/dummy/config/database.yml~ +25 -0
- data/spec/dummy/config/environment.rb +1 -0
- data/spec/dummy/config/environment.rb~ +5 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/development.rb~ +31 -0
- data/spec/dummy/config/environments/production.rb +1 -0
- data/spec/dummy/config/environments/production.rb~ +82 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/environments/test.rb~ +40 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb~ +7 -0
- data/spec/dummy/config/initializers/commontator.rb +1 -0
- data/spec/dummy/config/initializers/commontator.rb~ +14 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb~ +4 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb~ +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb~ +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb~ +12 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb~ +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb~ +14 -0
- data/spec/dummy/config/routes.rb +2 -1
- data/spec/dummy/config/routes.rb~ +7 -0
- data/spec/dummy/db/migrate/1_create_dummy_models.rb +1 -0
- data/spec/dummy/db/migrate/1_create_dummy_models.rb~ +7 -0
- data/spec/dummy/db/migrate/2_create_dummy_users.rb +1 -0
- data/spec/dummy/db/migrate/2_create_dummy_users.rb~ +7 -0
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +1 -0
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb~ +27 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +33 -119
- data/spec/dummy/log/test.log +33394 -31595
- data/spec/dummy/public/404.html +1 -0
- data/spec/dummy/public/404.html~ +26 -0
- data/spec/dummy/public/422.html +1 -0
- data/spec/dummy/public/422.html~ +26 -0
- data/spec/dummy/public/500.html +1 -0
- data/spec/dummy/public/500.html~ +25 -0
- data/spec/dummy/script/rails +1 -0
- data/spec/dummy/script/rails~ +6 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{72b63dddbc5c995f79af8e3c94904fd9 → 02d4b791eb831cf2057bf4703a1218d1} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{a77b1a9223d168112e1705c29220116f → 0f196a1a50363b0a076ec6e1ee5417f6} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{afa63eb365bdf4f42584b17ac9176b9d → a3fb9025f90ff05a6fd4afc7ded2692c} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{a473b3873e554893372a53d71f5e9879 → c69ee3cc5796188d873574179290a6ef} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{f721383d531f067d82b071e14aed7a92 → e1f674c11941d62aac1764ef3a7134e4} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{d2244ccef8e05bb993f75715af0344cc → e85565206c3e5fdf9dfeb367c85557b1} +0 -0
- data/spec/helpers/commontator/application_helper_spec.rb +10 -0
- data/spec/helpers/commontator/application_helper_spec.rb~ +9 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb +16 -15
- data/spec/lib/commontator/acts_as_commontable_spec.rb~ +25 -0
- data/spec/lib/commontator/acts_as_commontator_spec.rb +17 -16
- data/spec/lib/commontator/acts_as_commontator_spec.rb~ +52 -0
- data/spec/lib/commontator/commontable_config_spec.rb +9 -8
- data/spec/lib/commontator/commontable_config_spec.rb~ +29 -0
- data/spec/lib/commontator/commontator_config_spec.rb +9 -8
- data/spec/lib/commontator/commontator_config_spec.rb~ +29 -0
- data/spec/lib/commontator/controller_includes_spec.rb +10 -7
- data/spec/lib/commontator/controller_includes_spec.rb~ +18 -0
- data/spec/lib/commontator/shared_helper_spec.rb +14 -9
- data/spec/lib/commontator/shared_helper_spec.rb~ +22 -0
- data/spec/lib/commontator_spec.rb +7 -6
- data/spec/lib/commontator_spec.rb~ +26 -0
- data/spec/mailers/commontator/subscriptions_mailer_spec.rb +30 -0
- data/spec/{app/mailers/commontator/subscriptions_mailer_spec.rb → mailers/commontator/subscriptions_mailer_spec.rb~} +12 -12
- data/spec/models/commontator/comment_spec.rb +82 -0
- data/spec/models/commontator/comment_spec.rb~ +82 -0
- data/spec/{app/models → models}/commontator/subscription_spec.rb +14 -13
- data/spec/models/commontator/subscription_spec.rb~ +38 -0
- data/spec/models/commontator/thread_spec.rb +122 -0
- data/spec/{app/models/commontator/thread_spec.rb → models/commontator/thread_spec.rb~} +52 -50
- data/spec/rails_helper.rb +71 -0
- data/spec/rails_helper.rb~ +74 -0
- data/spec/spec_helper.rb +77 -27
- data/spec/spec_helper.rb~ +86 -0
- metadata +184 -78
- data/spec/app/controllers/commontator/comments_controller_spec.rb +0 -582
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +0 -99
- data/spec/app/controllers/commontator/threads_controller_spec.rb +0 -127
- data/spec/app/helpers/commontator/application_helper_spec.rb +0 -9
- data/spec/app/models/commontator/comment_spec.rb +0 -73
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
@@ -1,582 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'acts_as_votable'
|
3
|
-
|
4
|
-
module Commontator
|
5
|
-
describe CommentsController do
|
6
|
-
before do
|
7
|
-
setup_controller_spec
|
8
|
-
@comment = Comment.new
|
9
|
-
@comment.thread = @thread
|
10
|
-
@comment.creator = @user
|
11
|
-
@comment.body = 'Something'
|
12
|
-
@comment.save!
|
13
|
-
@comment.is_votable?.must_equal true
|
14
|
-
end
|
15
|
-
|
16
|
-
it "won't get new unless authorized" do
|
17
|
-
get :new, :thread_id => @thread.id, :use_route => :commontator
|
18
|
-
assert_response 403
|
19
|
-
|
20
|
-
sign_in @user
|
21
|
-
get :new, :thread_id => @thread.id, :use_route => :commontator
|
22
|
-
assert_response 403
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'must get new if authorized' do
|
26
|
-
sign_in @user
|
27
|
-
|
28
|
-
@user.can_read = true
|
29
|
-
get :new, :thread_id => @thread.id, :use_route => :commontator
|
30
|
-
assert_redirected_to @thread
|
31
|
-
assigns(:comment).errors.must_be_empty
|
32
|
-
|
33
|
-
@user.can_read = false
|
34
|
-
@user.can_edit = true
|
35
|
-
get :new, :thread_id => @thread.id, :use_route => :commontator
|
36
|
-
assert_redirected_to @thread
|
37
|
-
assigns(:comment).errors.must_be_empty
|
38
|
-
|
39
|
-
@user.can_edit = false
|
40
|
-
@user.is_admin = true
|
41
|
-
get :new, :thread_id => @thread.id, :use_route => :commontator
|
42
|
-
assert_redirected_to @thread
|
43
|
-
assigns(:comment).errors.must_be_empty
|
44
|
-
end
|
45
|
-
|
46
|
-
it "won't create unless authorized" do
|
47
|
-
attributes = Hash.new
|
48
|
-
attributes[:body] = 'Something else'
|
49
|
-
|
50
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
51
|
-
assert_response 403
|
52
|
-
|
53
|
-
sign_in @user
|
54
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
55
|
-
assert_response 403
|
56
|
-
|
57
|
-
@user.can_read = true
|
58
|
-
@user.can_edit = true
|
59
|
-
@user.is_admin = true
|
60
|
-
@thread.close.must_equal true
|
61
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
62
|
-
assert_response 403
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'must create if authorized' do
|
66
|
-
sign_in @user
|
67
|
-
attributes = Hash.new
|
68
|
-
|
69
|
-
attributes[:body] = 'Something else'
|
70
|
-
@user.can_read = true
|
71
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
72
|
-
assert_redirected_to @thread
|
73
|
-
assigns(:comment).errors.must_be_empty
|
74
|
-
assigns(:comment).body.must_equal 'Something else'
|
75
|
-
assigns(:comment).creator.must_equal @user
|
76
|
-
assigns(:comment).editor.must_be_nil
|
77
|
-
assigns(:comment).thread.must_equal @thread
|
78
|
-
|
79
|
-
attributes[:body] = 'Another thing'
|
80
|
-
@user.can_read = false
|
81
|
-
@user.can_edit = true
|
82
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
83
|
-
assert_redirected_to @thread
|
84
|
-
assigns(:comment).errors.must_be_empty
|
85
|
-
assigns(:comment).body.must_equal 'Another thing'
|
86
|
-
assigns(:comment).creator.must_equal @user
|
87
|
-
assigns(:comment).editor.must_be_nil
|
88
|
-
assigns(:comment).thread.must_equal @thread
|
89
|
-
|
90
|
-
attributes[:body] = 'And this too'
|
91
|
-
@user.can_edit = false
|
92
|
-
@user.is_admin = true
|
93
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
94
|
-
assert_redirected_to @thread
|
95
|
-
assigns(:comment).errors.must_be_empty
|
96
|
-
assigns(:comment).body.must_equal 'And this too'
|
97
|
-
assigns(:comment).creator.must_equal @user
|
98
|
-
assigns(:comment).editor.must_be_nil
|
99
|
-
assigns(:comment).thread.must_equal @thread
|
100
|
-
end
|
101
|
-
|
102
|
-
it "won't create if double posting" do
|
103
|
-
sign_in @user
|
104
|
-
@user.can_read = true
|
105
|
-
attributes = Hash.new
|
106
|
-
|
107
|
-
attributes[:body] = 'Something'
|
108
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
109
|
-
assert_redirected_to @thread
|
110
|
-
assigns(:comment).errors.wont_be_empty
|
111
|
-
|
112
|
-
attributes[:body] = 'Something else'
|
113
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
114
|
-
assert_redirected_to @thread
|
115
|
-
assigns(:comment).errors.must_be_empty
|
116
|
-
assigns(:comment).body.must_equal 'Something else'
|
117
|
-
assigns(:comment).creator.must_equal @user
|
118
|
-
assigns(:comment).editor.must_be_nil
|
119
|
-
assigns(:comment).thread.must_equal @thread
|
120
|
-
|
121
|
-
attributes[:body] = 'Something else'
|
122
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
123
|
-
assert_redirected_to @thread
|
124
|
-
assigns(:comment).errors.wont_be_empty
|
125
|
-
end
|
126
|
-
|
127
|
-
it "won't edit unless authorized" do
|
128
|
-
get :edit, :id => @comment.id, :use_route => :commontator
|
129
|
-
assert_response 403
|
130
|
-
|
131
|
-
sign_in @user
|
132
|
-
get :edit, :id => @comment.id, :use_route => :commontator
|
133
|
-
assert_response 403
|
134
|
-
|
135
|
-
user2 = DummyUser.create
|
136
|
-
user2.can_read = true
|
137
|
-
user2.can_edit = true
|
138
|
-
user2.is_admin = true
|
139
|
-
sign_in user2
|
140
|
-
get :edit, :id => @comment.id, :use_route => :commontator
|
141
|
-
assert_response 403
|
142
|
-
|
143
|
-
@user.can_read = true
|
144
|
-
@user.can_edit = true
|
145
|
-
@user.is_admin = true
|
146
|
-
sign_in @user
|
147
|
-
comment2 = Comment.new
|
148
|
-
comment2.thread = @thread
|
149
|
-
comment2.creator = @user
|
150
|
-
comment2.body = 'Something else'
|
151
|
-
comment2.save!
|
152
|
-
get :edit, :id => @comment.id, :use_route => :commontator
|
153
|
-
assert_response 403
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'must edit if authorized' do
|
157
|
-
sign_in @user
|
158
|
-
|
159
|
-
@user.can_read = true
|
160
|
-
get :edit, :id => @comment.id, :use_route => :commontator
|
161
|
-
assert_redirected_to @thread
|
162
|
-
assigns(:comment).errors.must_be_empty
|
163
|
-
|
164
|
-
@user.can_read = false
|
165
|
-
@user.can_edit = true
|
166
|
-
get :edit, :id => @comment.id, :use_route => :commontator
|
167
|
-
assert_redirected_to @thread
|
168
|
-
assigns(:comment).errors.must_be_empty
|
169
|
-
|
170
|
-
@user.can_edit = false
|
171
|
-
@user.is_admin = true
|
172
|
-
get :edit, :id => @comment.id, :use_route => :commontator
|
173
|
-
assert_redirected_to @thread
|
174
|
-
assigns(:comment).errors.must_be_empty
|
175
|
-
end
|
176
|
-
|
177
|
-
it "won't update unless authorized" do
|
178
|
-
attributes = Hash.new
|
179
|
-
attributes[:body] = 'Something else'
|
180
|
-
|
181
|
-
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
182
|
-
assert_response 403
|
183
|
-
@comment.reload
|
184
|
-
@comment.body.must_equal 'Something'
|
185
|
-
@comment.editor.must_be_nil
|
186
|
-
|
187
|
-
sign_in @user
|
188
|
-
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
189
|
-
assert_response 403
|
190
|
-
@comment.reload
|
191
|
-
@comment.body.must_equal 'Something'
|
192
|
-
@comment.editor.must_be_nil
|
193
|
-
|
194
|
-
user2 = DummyUser.create
|
195
|
-
user2.can_read = true
|
196
|
-
user2.can_edit = true
|
197
|
-
user2.is_admin = true
|
198
|
-
sign_in user2
|
199
|
-
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
200
|
-
assert_response 403
|
201
|
-
@comment.reload
|
202
|
-
@comment.body.must_equal 'Something'
|
203
|
-
@comment.editor.must_be_nil
|
204
|
-
|
205
|
-
@user.can_read = true
|
206
|
-
@user.can_edit = true
|
207
|
-
@user.is_admin = true
|
208
|
-
sign_in @user
|
209
|
-
comment2 = Comment.new
|
210
|
-
comment2.thread = @thread
|
211
|
-
comment2.creator = @user
|
212
|
-
comment2.body = 'Something else'
|
213
|
-
comment2.save!
|
214
|
-
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
215
|
-
@comment.reload
|
216
|
-
@comment.body.must_equal 'Something'
|
217
|
-
@comment.editor.must_be_nil
|
218
|
-
end
|
219
|
-
|
220
|
-
it 'must update if authorized' do
|
221
|
-
sign_in @user
|
222
|
-
attributes = Hash.new
|
223
|
-
attributes[:body] = 'Something else'
|
224
|
-
|
225
|
-
@user.can_read = true
|
226
|
-
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
227
|
-
assert_redirected_to @thread
|
228
|
-
assigns(:comment).errors.must_be_empty
|
229
|
-
assigns(:comment).editor.must_equal @user
|
230
|
-
|
231
|
-
@user.can_read = false
|
232
|
-
@user.can_edit = true
|
233
|
-
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
234
|
-
assert_redirected_to @thread
|
235
|
-
assigns(:comment).errors.must_be_empty
|
236
|
-
assigns(:comment).editor.must_equal @user
|
237
|
-
|
238
|
-
@user.can_edit = false
|
239
|
-
@user.is_admin = true
|
240
|
-
put :update, :id => @comment.id, :comment => attributes, :use_route => :commontator
|
241
|
-
assert_redirected_to @thread
|
242
|
-
assigns(:comment).errors.must_be_empty
|
243
|
-
assigns(:comment).editor.must_equal @user
|
244
|
-
end
|
245
|
-
|
246
|
-
it "won't delete unless authorized and not deleted" do
|
247
|
-
put :delete, :id => @comment.id, :use_route => :commontator
|
248
|
-
assert_response 403
|
249
|
-
@comment.reload
|
250
|
-
@comment.is_deleted?.must_equal false
|
251
|
-
|
252
|
-
sign_in @user
|
253
|
-
|
254
|
-
put :delete, :id => @comment.id, :use_route => :commontator
|
255
|
-
assert_response 403
|
256
|
-
@comment.reload
|
257
|
-
@comment.is_deleted?.must_equal false
|
258
|
-
|
259
|
-
@user.can_read = true
|
260
|
-
@comment.delete_by(@user).must_equal true
|
261
|
-
put :delete, :id => @comment.id, :use_route => :commontator
|
262
|
-
assert_redirected_to @thread
|
263
|
-
assigns(:comment).errors.wont_be_empty
|
264
|
-
|
265
|
-
comment2 = Comment.new
|
266
|
-
comment2.thread = @thread
|
267
|
-
comment2.creator = @user
|
268
|
-
comment2.body = 'Something else'
|
269
|
-
comment2.save!
|
270
|
-
@comment.undelete_by(@user).must_equal true
|
271
|
-
put :delete, :id => @comment.id, :use_route => :commontator
|
272
|
-
assert_response 403
|
273
|
-
@comment.reload
|
274
|
-
@comment.is_deleted?.must_equal false
|
275
|
-
end
|
276
|
-
|
277
|
-
it 'must delete if authorized and not deleted' do
|
278
|
-
sign_in @user
|
279
|
-
|
280
|
-
@user.can_read = true
|
281
|
-
put :delete, :id => @comment.id, :use_route => :commontator
|
282
|
-
assert_redirected_to @thread
|
283
|
-
assigns(:comment).errors.must_be_empty
|
284
|
-
assigns(:comment).is_deleted?.must_equal true
|
285
|
-
assigns(:comment).editor.must_equal @user
|
286
|
-
|
287
|
-
user2 = DummyUser.create
|
288
|
-
sign_in user2
|
289
|
-
comment2 = Comment.new
|
290
|
-
comment2.thread = @thread
|
291
|
-
comment2.creator = @user
|
292
|
-
comment2.body = 'Something else'
|
293
|
-
comment2.save!
|
294
|
-
|
295
|
-
assigns(:comment).undelete_by(@user).must_equal true
|
296
|
-
user2.can_edit = true
|
297
|
-
put :delete, :id => @comment.id, :use_route => :commontator
|
298
|
-
assert_redirected_to @thread
|
299
|
-
assigns(:comment).errors.must_be_empty
|
300
|
-
assigns(:comment).is_deleted?.must_equal true
|
301
|
-
assigns(:comment).editor.must_equal user2
|
302
|
-
|
303
|
-
assigns(:comment).undelete_by(@user).must_equal true
|
304
|
-
user2.can_edit = false
|
305
|
-
user2.is_admin = true
|
306
|
-
put :delete, :id => @comment.id, :use_route => :commontator
|
307
|
-
assert_redirected_to @thread
|
308
|
-
assigns(:comment).errors.must_be_empty
|
309
|
-
assigns(:comment).is_deleted?.must_equal true
|
310
|
-
assigns(:comment).editor.must_equal user2
|
311
|
-
end
|
312
|
-
|
313
|
-
it "won't undelete unless authorized and deleted" do
|
314
|
-
@comment.delete_by(@user).must_equal true
|
315
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
316
|
-
assert_response 403
|
317
|
-
@comment.reload
|
318
|
-
@comment.is_deleted?.must_equal true
|
319
|
-
|
320
|
-
sign_in @user
|
321
|
-
|
322
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
323
|
-
assert_response 403
|
324
|
-
@comment.reload
|
325
|
-
@comment.is_deleted?.must_equal true
|
326
|
-
|
327
|
-
@user.can_read = true
|
328
|
-
@comment.undelete_by(@user).must_equal true
|
329
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
330
|
-
assert_redirected_to @thread
|
331
|
-
assigns(:comment).errors.wont_be_empty
|
332
|
-
|
333
|
-
user2 = DummyUser.create
|
334
|
-
user2.can_read = true
|
335
|
-
user2.can_edit = true
|
336
|
-
user2.is_admin = true
|
337
|
-
@comment.delete_by(user2).must_equal true
|
338
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
339
|
-
assert_response 403
|
340
|
-
@comment.reload
|
341
|
-
@comment.is_deleted?.must_equal true
|
342
|
-
|
343
|
-
comment2 = Comment.new
|
344
|
-
comment2.thread = @thread
|
345
|
-
comment2.creator = @user
|
346
|
-
comment2.body = 'Something else'
|
347
|
-
comment2.save!
|
348
|
-
@comment.undelete_by(@user).must_equal true
|
349
|
-
@comment.delete_by(@user).must_equal true
|
350
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
351
|
-
assert_response 403
|
352
|
-
@comment.reload
|
353
|
-
@comment.is_deleted?.must_equal true
|
354
|
-
end
|
355
|
-
|
356
|
-
it 'must undelete if authorized and deleted' do
|
357
|
-
sign_in @user
|
358
|
-
|
359
|
-
@comment.delete_by(@user).must_equal true
|
360
|
-
@user.can_read = true
|
361
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
362
|
-
assert_redirected_to @thread
|
363
|
-
assigns(:comment).errors.must_be_empty
|
364
|
-
assigns(:comment).is_deleted?.must_equal false
|
365
|
-
|
366
|
-
user2 = DummyUser.create
|
367
|
-
sign_in user2
|
368
|
-
comment2 = Comment.new
|
369
|
-
comment2.thread = @thread
|
370
|
-
comment2.creator = @user
|
371
|
-
comment2.body = 'Something else'
|
372
|
-
comment2.save!
|
373
|
-
|
374
|
-
assigns(:comment).delete_by(@user).must_equal true
|
375
|
-
user2.can_edit = true
|
376
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
377
|
-
assert_redirected_to @thread
|
378
|
-
assigns(:comment).errors.must_be_empty
|
379
|
-
assigns(:comment).is_deleted?.must_equal false
|
380
|
-
|
381
|
-
assigns(:comment).delete_by(@user).must_equal true
|
382
|
-
user2.can_edit = false
|
383
|
-
user2.is_admin = true
|
384
|
-
put :undelete, :id => @comment.id, :use_route => :commontator
|
385
|
-
assert_redirected_to @thread
|
386
|
-
assigns(:comment).errors.must_be_empty
|
387
|
-
assigns(:comment).is_deleted?.must_equal false
|
388
|
-
end
|
389
|
-
|
390
|
-
it "won't upvote unless authorized" do
|
391
|
-
put :upvote, :id => @comment.id, :use_route => :commontator
|
392
|
-
assert_response 403
|
393
|
-
@comment.reload
|
394
|
-
@comment.get_upvotes.must_be_empty
|
395
|
-
@comment.get_downvotes.must_be_empty
|
396
|
-
|
397
|
-
sign_in @user
|
398
|
-
@user.can_read = true
|
399
|
-
put :upvote, :id => @comment.id, :use_route => :commontator
|
400
|
-
assert_response 403
|
401
|
-
@comment.reload
|
402
|
-
@comment.get_upvotes.must_be_empty
|
403
|
-
@comment.get_downvotes.must_be_empty
|
404
|
-
|
405
|
-
user2 = DummyUser.create
|
406
|
-
sign_in user2
|
407
|
-
put :upvote, :id => @comment.id, :use_route => :commontator
|
408
|
-
assert_response 403
|
409
|
-
@comment.reload
|
410
|
-
@comment.get_upvotes.must_be_empty
|
411
|
-
@comment.get_downvotes.must_be_empty
|
412
|
-
end
|
413
|
-
|
414
|
-
it 'must upvote if authorized' do
|
415
|
-
user2 = DummyUser.create
|
416
|
-
user2.can_read = true
|
417
|
-
sign_in user2
|
418
|
-
|
419
|
-
put :upvote, :id => @comment.id, :use_route => :commontator
|
420
|
-
assert_redirected_to @thread
|
421
|
-
assigns(:comment).get_upvotes.count.must_equal 1
|
422
|
-
assigns(:comment).get_downvotes.must_be_empty
|
423
|
-
|
424
|
-
put :upvote, :id => @comment.id, :use_route => :commontator
|
425
|
-
assert_redirected_to @thread
|
426
|
-
assigns(:comment).get_upvotes.count.must_equal 1
|
427
|
-
assigns(:comment).get_downvotes.must_be_empty
|
428
|
-
|
429
|
-
@comment.downvote_from(user2).must_equal true
|
430
|
-
|
431
|
-
put :upvote, :id => @comment.id, :use_route => :commontator
|
432
|
-
assert_redirected_to @thread
|
433
|
-
assigns(:comment).get_upvotes.count.must_equal 1
|
434
|
-
assigns(:comment).get_downvotes.must_be_empty
|
435
|
-
end
|
436
|
-
|
437
|
-
it "won't downvote unless authorized" do
|
438
|
-
put :downvote, :id => @comment.id, :use_route => :commontator
|
439
|
-
assert_response 403
|
440
|
-
@comment.reload
|
441
|
-
@comment.get_upvotes.must_be_empty
|
442
|
-
@comment.get_downvotes.must_be_empty
|
443
|
-
|
444
|
-
sign_in @user
|
445
|
-
@user.can_read = true
|
446
|
-
put :downvote, :id => @comment.id, :use_route => :commontator
|
447
|
-
assert_response 403
|
448
|
-
@comment.reload
|
449
|
-
@comment.get_upvotes.must_be_empty
|
450
|
-
@comment.get_downvotes.must_be_empty
|
451
|
-
|
452
|
-
user2 = DummyUser.create
|
453
|
-
sign_in user2
|
454
|
-
put :downvote, :id => @comment.id, :use_route => :commontator
|
455
|
-
assert_response 403
|
456
|
-
@comment.reload
|
457
|
-
@comment.get_upvotes.must_be_empty
|
458
|
-
@comment.get_downvotes.must_be_empty
|
459
|
-
end
|
460
|
-
|
461
|
-
it 'must downvote if authorized' do
|
462
|
-
user2 = DummyUser.create
|
463
|
-
user2.can_read = true
|
464
|
-
sign_in user2
|
465
|
-
|
466
|
-
put :downvote, :id => @comment.id, :use_route => :commontator
|
467
|
-
assert_redirected_to @thread
|
468
|
-
assigns(:comment).get_upvotes.must_be_empty
|
469
|
-
assigns(:comment).get_downvotes.count.must_equal 1
|
470
|
-
|
471
|
-
put :downvote, :id => @comment.id, :use_route => :commontator
|
472
|
-
assert_redirected_to @thread
|
473
|
-
assigns(:comment).get_upvotes.must_be_empty
|
474
|
-
assigns(:comment).get_downvotes.count.must_equal 1
|
475
|
-
|
476
|
-
@comment.upvote_from(user2).must_equal true
|
477
|
-
|
478
|
-
put :downvote, :id => @comment.id, :use_route => :commontator
|
479
|
-
assert_redirected_to @thread
|
480
|
-
assigns(:comment).get_upvotes.must_be_empty
|
481
|
-
assigns(:comment).get_downvotes.count.must_equal 1
|
482
|
-
end
|
483
|
-
|
484
|
-
it "won't unvote unless authorized" do
|
485
|
-
@comment.upvote_from(@user).must_equal true
|
486
|
-
|
487
|
-
put :unvote, :id => @comment.id, :use_route => :commontator
|
488
|
-
assert_response 403
|
489
|
-
@comment.reload
|
490
|
-
@comment.get_upvotes.count.must_equal 1
|
491
|
-
@comment.get_downvotes.must_be_empty
|
492
|
-
|
493
|
-
sign_in @user
|
494
|
-
@user.can_read = true
|
495
|
-
put :unvote, :id => @comment.id, :use_route => :commontator
|
496
|
-
assert_response 403
|
497
|
-
@comment.reload
|
498
|
-
@comment.get_upvotes.count.must_equal 1
|
499
|
-
@comment.get_downvotes.must_be_empty
|
500
|
-
|
501
|
-
user2 = DummyUser.create
|
502
|
-
sign_in user2
|
503
|
-
put :unvote, :id => @comment.id, :use_route => :commontator
|
504
|
-
assert_response 403
|
505
|
-
@comment.reload
|
506
|
-
@comment.get_upvotes.count.must_equal 1
|
507
|
-
@comment.get_downvotes.must_be_empty
|
508
|
-
end
|
509
|
-
|
510
|
-
it 'must unvote if authorized' do
|
511
|
-
user2 = DummyUser.create
|
512
|
-
user2.can_read = true
|
513
|
-
sign_in user2
|
514
|
-
|
515
|
-
@comment.upvote_from(user2).must_equal true
|
516
|
-
put :unvote, :id => @comment.id, :use_route => :commontator
|
517
|
-
assert_redirected_to @thread
|
518
|
-
assigns(:comment).get_upvotes.must_be_empty
|
519
|
-
assigns(:comment).get_downvotes.must_be_empty
|
520
|
-
|
521
|
-
put :unvote, :id => @comment.id, :use_route => :commontator
|
522
|
-
assert_redirected_to @thread
|
523
|
-
assigns(:comment).get_upvotes.must_be_empty
|
524
|
-
assigns(:comment).get_downvotes.must_be_empty
|
525
|
-
|
526
|
-
@comment.downvote_from(user2).must_equal true
|
527
|
-
put :unvote, :id => @comment.id, :use_route => :commontator
|
528
|
-
assert_redirected_to @thread
|
529
|
-
assigns(:comment).get_upvotes.must_be_empty
|
530
|
-
assigns(:comment).get_downvotes.must_be_empty
|
531
|
-
end
|
532
|
-
|
533
|
-
it "won't send mail if recipients empty" do
|
534
|
-
if defined?(Subscription::SubscriptionsMailer)
|
535
|
-
Subscription::SubscriptionsMailer.__send__(:initialize)
|
536
|
-
else
|
537
|
-
Subscription::SubscriptionsMailer = MiniTest::Mock.new
|
538
|
-
end
|
539
|
-
|
540
|
-
user2 = DummyUser.create
|
541
|
-
user2.can_read = true
|
542
|
-
|
543
|
-
email = MiniTest::Mock.new.expect(:deliver, nil)
|
544
|
-
Subscription::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
|
545
|
-
|
546
|
-
@user.can_read = true
|
547
|
-
sign_in @user
|
548
|
-
|
549
|
-
attributes = { :body => 'Something else' }
|
550
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
551
|
-
assigns(:comment).errors.must_be_empty
|
552
|
-
|
553
|
-
proc { Subscription::SubscriptionsMailer.verify }.must_raise(MockExpectationError)
|
554
|
-
proc { email.verify }.must_raise(MockExpectationError)
|
555
|
-
end
|
556
|
-
|
557
|
-
it 'must send mail if recipients not empty' do
|
558
|
-
if defined?(Subscription::SubscriptionsMailer)
|
559
|
-
Subscription::SubscriptionsMailer.__send__(:initialize)
|
560
|
-
else
|
561
|
-
Subscription::SubscriptionsMailer = MiniTest::Mock.new
|
562
|
-
end
|
563
|
-
|
564
|
-
user2 = DummyUser.create
|
565
|
-
user2.can_read = true
|
566
|
-
@thread.subscribe(user2)
|
567
|
-
|
568
|
-
email = MiniTest::Mock.new.expect(:deliver, nil)
|
569
|
-
Subscription::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
|
570
|
-
|
571
|
-
@user.can_read = true
|
572
|
-
sign_in @user
|
573
|
-
|
574
|
-
attributes = { :body => 'Something else' }
|
575
|
-
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
576
|
-
assigns(:comment).errors.must_be_empty
|
577
|
-
|
578
|
-
Subscription::SubscriptionsMailer.verify
|
579
|
-
email.verify
|
580
|
-
end
|
581
|
-
end
|
582
|
-
end
|