rc_rails 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/.gitignore +7 -0
  2. data/CHANGELOG +355 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock.development +117 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +71 -0
  7. data/Rakefile +33 -0
  8. data/Todo.txt +1 -0
  9. data/lib/rc_rails.rb +9 -0
  10. data/lib/resources_controller/actions.rb +147 -0
  11. data/lib/resources_controller/active_record/saved.rb +15 -0
  12. data/lib/resources_controller/helper.rb +123 -0
  13. data/lib/resources_controller/include_actions.rb +37 -0
  14. data/lib/resources_controller/named_route_helper.rb +154 -0
  15. data/lib/resources_controller/railtie.rb +14 -0
  16. data/lib/resources_controller/request_path_introspection.rb +83 -0
  17. data/lib/resources_controller/resource_methods.rb +32 -0
  18. data/lib/resources_controller/singleton_actions.rb +21 -0
  19. data/lib/resources_controller/specification.rb +119 -0
  20. data/lib/resources_controller/version.rb +3 -0
  21. data/lib/resources_controller.rb +849 -0
  22. data/resources_controller.gemspec +29 -0
  23. data/spec/app/database.yml +5 -0
  24. data/spec/app/views/accounts/show.html.erb +0 -0
  25. data/spec/app/views/addresses/edit.html.erb +0 -0
  26. data/spec/app/views/addresses/index.html.erb +0 -0
  27. data/spec/app/views/addresses/new.html.erb +0 -0
  28. data/spec/app/views/addresses/show.html.erb +0 -0
  29. data/spec/app/views/admin/forums/create.html.erb +0 -0
  30. data/spec/app/views/admin/forums/destroy.html.erb +0 -0
  31. data/spec/app/views/admin/forums/edit.html.erb +0 -0
  32. data/spec/app/views/admin/forums/index.html.erb +0 -0
  33. data/spec/app/views/admin/forums/new.html.erb +0 -0
  34. data/spec/app/views/admin/forums/show.html.erb +0 -0
  35. data/spec/app/views/admin/forums/update.html.erb +0 -0
  36. data/spec/app/views/comments/edit.html.erb +0 -0
  37. data/spec/app/views/comments/index.html.erb +0 -0
  38. data/spec/app/views/comments/new.html.erb +0 -0
  39. data/spec/app/views/comments/show.html.erb +0 -0
  40. data/spec/app/views/forum_posts/edit.html.erb +0 -0
  41. data/spec/app/views/forum_posts/index.html.erb +0 -0
  42. data/spec/app/views/forum_posts/new.html.erb +0 -0
  43. data/spec/app/views/forum_posts/show.html.erb +0 -0
  44. data/spec/app/views/forums/create.html.erb +0 -0
  45. data/spec/app/views/forums/destroy.html.erb +0 -0
  46. data/spec/app/views/forums/edit.html.erb +0 -0
  47. data/spec/app/views/forums/index.html.erb +0 -0
  48. data/spec/app/views/forums/new.html.erb +0 -0
  49. data/spec/app/views/forums/show.html.erb +0 -0
  50. data/spec/app/views/forums/update.html.erb +0 -0
  51. data/spec/app/views/infos/edit.html.erb +0 -0
  52. data/spec/app/views/infos/show.html.erb +0 -0
  53. data/spec/app/views/interests/index.html.erb +0 -0
  54. data/spec/app/views/interests/show.html.erb +0 -0
  55. data/spec/app/views/owners/edit.html.erb +0 -0
  56. data/spec/app/views/owners/new.html.erb +0 -0
  57. data/spec/app/views/owners/show.html.erb +0 -0
  58. data/spec/app/views/tags/index.html.erb +0 -0
  59. data/spec/app/views/tags/new.html.erb +0 -0
  60. data/spec/app/views/tags/show.html.erb +0 -0
  61. data/spec/app/views/users/edit.html.erb +0 -0
  62. data/spec/app/views/users/index.html.erb +0 -0
  63. data/spec/app/views/users/show.html.erb +0 -0
  64. data/spec/app.rb +315 -0
  65. data/spec/controllers/accounts_controller_spec.rb +77 -0
  66. data/spec/controllers/addresses_controller_spec.rb +346 -0
  67. data/spec/controllers/admin_forums_controller_spec.rb +638 -0
  68. data/spec/controllers/comments_controller_spec.rb +380 -0
  69. data/spec/controllers/comments_controller_with_models_spec.rb +202 -0
  70. data/spec/controllers/forum_posts_controller_spec.rb +426 -0
  71. data/spec/controllers/forums_controller_spec.rb +694 -0
  72. data/spec/controllers/infos_controller_spec.rb +71 -0
  73. data/spec/controllers/interests_controller_via_forum_spec.rb +80 -0
  74. data/spec/controllers/interests_controller_via_user_spec.rb +114 -0
  75. data/spec/controllers/owners_controller_spec.rb +277 -0
  76. data/spec/controllers/resource_saved_spec.rb +47 -0
  77. data/spec/controllers/resource_service_in_forums_controller_spec.rb +37 -0
  78. data/spec/controllers/resource_service_in_infos_controller_spec.rb +36 -0
  79. data/spec/controllers/resource_service_in_interests_controller_via_forum_spec.rb +51 -0
  80. data/spec/controllers/tags_controller_spec.rb +83 -0
  81. data/spec/controllers/tags_controller_via_account_info_spec.rb +131 -0
  82. data/spec/controllers/tags_controller_via_forum_post_comment_spec.rb +144 -0
  83. data/spec/controllers/tags_controller_via_forum_post_spec.rb +133 -0
  84. data/spec/controllers/tags_controller_via_forum_spec.rb +173 -0
  85. data/spec/controllers/tags_controller_via_user_address_spec.rb +130 -0
  86. data/spec/controllers/users_controller_spec.rb +248 -0
  87. data/spec/lib/action_view_helper_spec.rb +143 -0
  88. data/spec/lib/bug_0001_spec.rb +22 -0
  89. data/spec/lib/include_actions_spec.rb +35 -0
  90. data/spec/lib/load_enclosing_resources_spec.rb +245 -0
  91. data/spec/lib/request_path_introspection_spec.rb +130 -0
  92. data/spec/lib/resource_methods_spec.rb +204 -0
  93. data/spec/lib/resources_controller_spec.rb +57 -0
  94. data/spec/models/comment_saved_spec.rb +24 -0
  95. data/spec/rspec_generator_task.rb +105 -0
  96. data/spec/spec_helper.rb +17 -0
  97. data/spec/verify_rcov.rb +52 -0
  98. metadata +193 -0
@@ -0,0 +1,380 @@
1
+ require 'spec_helper'
2
+
3
+ module CommentsSpecHelper
4
+ def setup_mocks
5
+ @forum = mock('Forum')
6
+ @forum_posts = mock('Assoc: forum_posts')
7
+ @forum.stub!(:posts).and_return(@forum_posts)
8
+ @forum.stub!(:to_param).and_return("3")
9
+
10
+ @post = mock('Post')
11
+ @post_comments = mock('Assoc: post_comments')
12
+ @post.stub!(:comments).and_return(@post_comments)
13
+ @post.stub!(:to_param).and_return("2")
14
+
15
+ Forum.stub!(:find).and_return(@forum)
16
+ @forum_posts.stub!(:find).and_return(@post)
17
+ end
18
+ end
19
+
20
+ describe CommentsController do
21
+ describe "Routing shortcuts for Comments (forums/3/posts/2/comments/1) should map" do
22
+ include CommentsSpecHelper
23
+
24
+ before(:each) do
25
+ setup_mocks
26
+ @comment = mock('Comment')
27
+ @comment.stub!(:to_param).and_return("1")
28
+ @post_comments.stub!(:find).and_return(@comment)
29
+ get :show, :forum_id => "3", :post_id => "2", :id => "1"
30
+ end
31
+
32
+ it "resources_path to /forums/3/posts/2/comments" do
33
+ controller.resources_path.should == '/forums/3/posts/2/comments'
34
+ end
35
+
36
+ it "resource_path to /forums/3/posts/2/comments/1" do
37
+ controller.resource_path.should == '/forums/3/posts/2/comments/1'
38
+ end
39
+
40
+ it "resource_path(9) to /forums/3/posts/2/comments/9" do
41
+ controller.resource_path(9).should == '/forums/3/posts/2/comments/9'
42
+ end
43
+
44
+ it "edit_resource_path to /forums/3/posts/2/comments/1/edit" do
45
+ controller.edit_resource_path.should == '/forums/3/posts/2/comments/1/edit'
46
+ end
47
+
48
+ it "edit_resource_path(9) to /forums/3/posts/2/comments/9/edit" do
49
+ controller.edit_resource_path(9).should == '/forums/3/posts/2/comments/9/edit'
50
+ end
51
+
52
+ it "new_resource_path to /forums/3/posts/2/comments/new" do
53
+ controller.new_resource_path.should == '/forums/3/posts/2/comments/new'
54
+ end
55
+
56
+ it "resource_tags_path to /forums/3/posts/2/comments/1/tags" do
57
+ controller.resource_tags_path.should == "/forums/3/posts/2/comments/1/tags"
58
+ end
59
+
60
+ it "resource_tags_path(9) to /forums/3/posts/2/comments/9/tags" do
61
+ controller.resource_tags_path(9).should == "/forums/3/posts/2/comments/9/tags"
62
+ end
63
+
64
+ it "resource_tag_path(5) to /forums/3/posts/2/comments/1/tags/5" do
65
+ controller.resource_tag_path(5).should == "/forums/3/posts/2/comments/1/tags/5"
66
+ end
67
+
68
+ it "resource_tag_path(9,5) to /forums/3/posts/2/comments/9/tags/5" do
69
+ controller.resource_tag_path(9,5).should == "/forums/3/posts/2/comments/9/tags/5"
70
+ end
71
+ end
72
+
73
+ describe "resource_service in CommentsController" do
74
+
75
+ before(:each) do
76
+ @forum = Forum.create
77
+ @post = Post.create :forum_id => @forum.id
78
+ @comment = Comment.create :post_id => @post.id, :user => User.create
79
+ @other_post = Post.create :forum_id => @forum.id
80
+ @other_comment = Comment.create :post_id => @other_post.id
81
+
82
+ get :index, :forum_id => @forum.id, :post_id => @post.id
83
+ @resource_service = controller.send :resource_service
84
+ end
85
+
86
+ it "should build new comment with @post foreign key with new" do
87
+ resource = @resource_service.new
88
+ resource.should be_kind_of(Comment)
89
+ resource.post_id.should == @post.id
90
+ end
91
+
92
+ it "should find @comment with find(@comment.id)" do
93
+ resource = @resource_service.find(@comment.id)
94
+ resource.should == @comment
95
+ end
96
+
97
+ it "should raise RecordNotFound with find(@other_post.id)" do
98
+ lambda{ @resource_service.find(@other_comment.id) }.should raise_error(ActiveRecord::RecordNotFound)
99
+ end
100
+
101
+ it "should find only comments belonging to @post with find(:all)" do
102
+ resources = @resource_service.find(:all)
103
+ resources.should be == Comment.find(:all, :conditions => "post_id = #{@post.id}")
104
+ end
105
+ end
106
+
107
+ describe "Requesting /forums/3/posts/2/comments (testing the before filters)" do
108
+ include CommentsSpecHelper
109
+
110
+ before(:each) do
111
+ setup_mocks
112
+ @comments = mock('Comments')
113
+ @post_comments.stub!(:all).and_return(@comments)
114
+ end
115
+
116
+ def do_get
117
+ get :index, :forum_id => '3', :post_id => '2'
118
+ end
119
+
120
+ it "should find the forum" do
121
+ Forum.should_receive(:find).with('3').and_return(@forum)
122
+ do_get
123
+ end
124
+
125
+ it "should assign the found forum for the view" do
126
+ do_get
127
+ assigns[:forum].should == @forum
128
+ end
129
+
130
+ it "should find the post" do
131
+ @forum.should_receive(:posts).and_return(@forum_posts)
132
+ @forum_posts.should_receive(:find).with('2').and_return(@post)
133
+ do_get
134
+ end
135
+
136
+ it "should assign the found post for the view" do
137
+ do_get
138
+ assigns[:post].should == @post
139
+ end
140
+
141
+ it "should assign the post_comments association as the comments resource_service" do
142
+ @post.should_receive(:comments).and_return(@post_comments)
143
+ do_get
144
+ @controller.resource_service.should == @post_comments
145
+ end
146
+ end
147
+
148
+ describe "Requesting /forums/3/posts/2/comments using GET" do
149
+ include CommentsSpecHelper
150
+
151
+ before(:each) do
152
+ setup_mocks
153
+ @comments = mock('Comments')
154
+ @post_comments.stub!(:all).and_return(@comments)
155
+ end
156
+
157
+ def do_get
158
+ get :index, :forum_id => '3', :post_id => '2'
159
+ end
160
+
161
+ it "should be successful" do
162
+ do_get
163
+ response.should be_success
164
+ end
165
+
166
+ it "should render index.rhtml" do
167
+ do_get
168
+ response.should render_template(:index)
169
+ end
170
+
171
+ it "should find comments in post" do
172
+ @post_comments.should_receive(:all).and_return(@comments)
173
+ do_get
174
+ end
175
+
176
+ it "should assign the found comments for the view" do
177
+ do_get
178
+ assigns[:comments].should == @comments
179
+ end
180
+ end
181
+
182
+ describe "Requesting /forums/3/posts/3/comments/1 using GET" do
183
+ include CommentsSpecHelper
184
+
185
+ before(:each) do
186
+ setup_mocks
187
+ @comment = mock('a post')
188
+ @post_comments.stub!(:find).and_return(@comment)
189
+ end
190
+
191
+ def do_get
192
+ get :show, :id => "1", :forum_id => '3', :post_id => '2'
193
+ end
194
+
195
+ it "should be successful" do
196
+ do_get
197
+ response.should be_success
198
+ end
199
+
200
+ it "should render show.rhtml" do
201
+ do_get
202
+ response.should render_template(:show)
203
+ end
204
+
205
+ it "should find the comment requested" do
206
+ @post_comments.should_receive(:find).with("1").and_return(@comment)
207
+ do_get
208
+ end
209
+
210
+ it "should assign the found comment for the view" do
211
+ do_get
212
+ assigns[:comment].should == @comment
213
+ end
214
+ end
215
+
216
+ describe "Requesting /forums/3/posts/3/comments/new using GET" do
217
+ include CommentsSpecHelper
218
+
219
+ before(:each) do
220
+ setup_mocks
221
+ @comment = mock('new Comment')
222
+ @post_comments.stub!(:build).and_return(@comment)
223
+ end
224
+
225
+ def do_get
226
+ get :new, :forum_id => '3', :post_id => '2'
227
+ end
228
+
229
+ it "should be successful" do
230
+ do_get
231
+ response.should be_success
232
+ end
233
+
234
+ it "should render new.rhtml" do
235
+ do_get
236
+ response.should render_template(:new)
237
+ end
238
+
239
+ it "should build a new comment" do
240
+ @post_comments.should_receive(:build).and_return(@comment)
241
+ do_get
242
+ end
243
+
244
+ it "should not save the new comment" do
245
+ @comment.should_not_receive(:save)
246
+ do_get
247
+ end
248
+
249
+ it "should assign the new comment for the view" do
250
+ do_get
251
+ assigns[:post].should == @post
252
+ end
253
+ end
254
+
255
+ describe "Requesting /forums/3/posts/3/comments/1/edit using GET" do
256
+ include CommentsSpecHelper
257
+
258
+ before(:each) do
259
+ setup_mocks
260
+ @comment = mock('Comment')
261
+ @post_comments.stub!(:find).and_return(@comment)
262
+ end
263
+
264
+ def do_get
265
+ get :edit, :id => "1", :forum_id => '3', :post_id => '2'
266
+ end
267
+
268
+ it "should be successful" do
269
+ do_get
270
+ response.should be_success
271
+ end
272
+
273
+ it "should render edit.rhtml" do
274
+ do_get
275
+ response.should render_template(:edit)
276
+ end
277
+
278
+ it "should find the comment requested" do
279
+ @post_comments.should_receive(:find).with("1").and_return(@comment)
280
+ do_get
281
+ end
282
+
283
+ it "should assign the found comment for the view" do
284
+ do_get
285
+ assigns(:comment).should == @comment
286
+ end
287
+ end
288
+
289
+ describe "Requesting /forums/3/posts/3/comments using POST" do
290
+ include CommentsSpecHelper
291
+
292
+ before(:each) do
293
+ setup_mocks
294
+ @comment = mock('Comment')
295
+ @comment.stub!(:save).and_return(true)
296
+ @comment.stub!(:to_param).and_return("1")
297
+ @post_comments.stub!(:build).and_return(@comment)
298
+ end
299
+
300
+ def do_post
301
+ post :create, :comment => {:name => 'Comment'}, :forum_id => '3', :post_id => '2'
302
+ end
303
+
304
+ it "should build a new comment" do
305
+ @post_comments.should_receive(:build).with({'name' => 'Comment'}).and_return(@comment)
306
+ do_post
307
+ end
308
+
309
+ it "should redirect to the new comment" do
310
+ do_post
311
+ response.should be_redirect
312
+ response.redirect_url.should == "http://test.host/forums/3/posts/2/comments/1"
313
+ end
314
+ end
315
+
316
+ describe "Requesting /forums/3/posts/3/comments/1 using PUT" do
317
+ include CommentsSpecHelper
318
+
319
+ before(:each) do
320
+ setup_mocks
321
+ @comment = mock('Comment').as_null_object
322
+ @comment.stub!(:to_param).and_return("1")
323
+ @post_comments.stub!(:find).and_return(@comment)
324
+ end
325
+
326
+ def do_update
327
+ put :update, :id => "1", :forum_id => '3', :post_id => '2'
328
+ end
329
+
330
+ it "should find the comment requested" do
331
+ @post_comments.should_receive(:find).with("1").and_return(@comment)
332
+ do_update
333
+ end
334
+
335
+ it "should update the found comment" do
336
+ @comment.should_receive(:update_attributes).and_return(true)
337
+ do_update
338
+ end
339
+
340
+ it "should assign the found comment for the view" do
341
+ do_update
342
+ assigns(:comment).should == @comment
343
+ end
344
+
345
+ it "should redirect to the comment" do
346
+ do_update
347
+ response.should be_redirect
348
+ response.redirect_url.should == "http://test.host/forums/3/posts/2/comments/1"
349
+ end
350
+ end
351
+
352
+
353
+ describe "Requesting /forums/3/posts/3/comments/1 using DELETE" do
354
+ include CommentsSpecHelper
355
+
356
+ before(:each) do
357
+ setup_mocks
358
+ @comment = mock('Comment', :id => '1').as_null_object
359
+ @post_comments.stub!(:find).and_return(@comment)
360
+ @post_comments.stub!(:destroy)
361
+ end
362
+
363
+ def do_delete
364
+ delete :destroy, :id => "1", :forum_id => '3', :post_id => '2'
365
+ end
366
+
367
+ it "should find and destroy the comment requested" do
368
+ @post_comments.should_receive(:find).with("1").and_return(@comment)
369
+ @post_comments.should_receive(:destroy).with("1")
370
+ do_delete
371
+ assigns['comment'].should == @comment
372
+ end
373
+
374
+ it "should redirect to the comments list" do
375
+ do_delete
376
+ response.should be_redirect
377
+ response.redirect_url.should == "http://test.host/forums/3/posts/2/comments"
378
+ end
379
+ end
380
+ end
@@ -0,0 +1,202 @@
1
+ require 'spec_helper'
2
+
3
+ describe CommentsController, "without stubs" do
4
+ before do
5
+ @user = User.create!
6
+ @forum = Forum.create!
7
+ @post = Post.create! :forum => @forum
8
+ @comment = Comment.create! :user => @user, :post => @post
9
+ end
10
+
11
+ describe "responding to GET index" do
12
+ def do_get
13
+ get :index, :forum_id => @forum.id, :post_id => @post.id
14
+ end
15
+
16
+ it "should expose all comments as @comments" do
17
+ do_get
18
+ assigns[:comments].should == [@comment]
19
+ end
20
+
21
+ describe "with mime type of xml" do
22
+ it "should render all comments as xml" do
23
+ request.env["HTTP_ACCEPT"] = "application/xml"
24
+ do_get
25
+ response.body.should == [@comment].to_xml
26
+ end
27
+ end
28
+ end
29
+
30
+ describe "responding to GET show" do
31
+ def do_get
32
+ get :show, :id => @comment.id, :forum_id => @forum.id, :post_id => @post.id
33
+ end
34
+
35
+ it "should expose the requested comment as @comment" do
36
+ do_get
37
+ assigns[:comment].should == @comment
38
+ end
39
+
40
+ describe "with mime type of xml" do
41
+ it "should render the requested comment as xml" do
42
+ request.env["HTTP_ACCEPT"] = "application/xml"
43
+ do_get
44
+ response.body.should == @comment.to_xml
45
+ end
46
+ end
47
+ end
48
+
49
+ describe "responding to GET new" do
50
+ def do_get
51
+ get :new, :forum_id => @forum.id, :post_id => @post.id
52
+ end
53
+
54
+ it "should expose a new comment as @comment" do
55
+ do_get
56
+ assigns[:comment].should be_new_record
57
+ assigns[:comment].post.should == @post
58
+ end
59
+ end
60
+
61
+ describe "responding to GET edit" do
62
+ def do_get
63
+ get :edit, :id => @comment.id, :forum_id => @forum.id, :post_id => @post.id
64
+ end
65
+
66
+ it "should expose the requested comment as @comment" do
67
+ do_get
68
+ assigns[:comment].should == @comment
69
+ end
70
+ end
71
+
72
+ describe "responding to POST create" do
73
+ describe "with valid params" do
74
+ def do_post
75
+ post :create, :forum_id => @forum.id, :post_id => @post.id, :comment => {:user_id => @user.id}
76
+ end
77
+
78
+ it "should create a comment" do
79
+ lambda { do_post }.should change(Comment, :count).by(1)
80
+ end
81
+
82
+ it "should expose the newly created comment as @comment" do
83
+ do_post
84
+ assigns(:comment).should == Comment.find(:first, :order => 'id DESC')
85
+ end
86
+
87
+ it "should be resource_saved?" do
88
+ do_post
89
+ @controller.should be_resource_saved
90
+ end
91
+
92
+ it "should redirect to the created comment" do
93
+ do_post
94
+ response.should redirect_to(forum_post_comment_url(@forum, @post, Comment.find(:first, :order => 'id DESC')))
95
+ end
96
+ end
97
+
98
+ describe "with invalid params" do
99
+ def do_post
100
+ post :create, :forum_id => @forum.id, :post_id => @post.id, :comment => {:user_id => ''}
101
+ end
102
+
103
+ it "should not create a comment" do
104
+ lambda { do_post }.should_not change(Comment, :count)
105
+ end
106
+
107
+ it "should expose a newly created but unsaved comment as @comment" do
108
+ do_post
109
+ assigns(:comment).should be_new_record
110
+ assigns(:comment).post.should == @post
111
+ end
112
+
113
+ it "should not be resource_saved?" do
114
+ do_post
115
+ @controller.should_not be_resource_saved
116
+ end
117
+
118
+ it "should re-render the 'new' template" do
119
+ do_post
120
+ response.should render_template('new')
121
+ end
122
+ end
123
+ end
124
+
125
+ describe "responding to PUT udpate" do
126
+ describe "with valid params" do
127
+ before do
128
+ @new_user = User.create!
129
+ end
130
+
131
+ def do_put
132
+ put :update, :id => @comment.id, :forum_id => @forum.id, :post_id => @post.id, :comment => {:user_id => @new_user.id}
133
+ end
134
+
135
+ it "should update the requested comment" do
136
+ do_put
137
+ Comment.find(@comment.id).user_id.should == @new_user.id
138
+ end
139
+
140
+ it "should not contain errors on comment" do
141
+ do_put
142
+ @comment.errors.should be_empty
143
+ end
144
+
145
+ it "should be resource_saved?" do
146
+ do_put
147
+ @controller.should be_resource_saved
148
+ end
149
+
150
+ it "should expose the requested comment as @comment" do
151
+ do_put
152
+ assigns[:comment].should == @comment
153
+ end
154
+
155
+ it "should redirect to the comment" do
156
+ do_put
157
+ response.should redirect_to(forum_post_comment_url(@forum, @post, @comment))
158
+ end
159
+ end
160
+
161
+ describe "with invalid params" do
162
+ def do_put
163
+ put :update, :id => @comment.id, :forum_id => @forum.id, :post_id => @post.id, :comment => {:user_id => ''}
164
+ end
165
+
166
+ it "should fail to update the requested comment" do
167
+ do_put
168
+ Comment.find(@comment.id).user_id.should == @user.id
169
+ end
170
+
171
+ it "should not be resource_saved?" do
172
+ do_put
173
+ @controller.should_not be_resource_saved
174
+ end
175
+
176
+ it "should expose the requested comment as @comment" do
177
+ do_put
178
+ assigns[:comment].should == @comment
179
+ end
180
+
181
+ it "should re-render the 'edit' template" do
182
+ do_put
183
+ response.should render_template('edit')
184
+ end
185
+ end
186
+ end
187
+
188
+ describe "responding to DELETE destroy" do
189
+ def do_delete
190
+ delete :destroy, :id => @comment.id, :forum_id => @forum.id, :post_id => @post.id
191
+ end
192
+
193
+ it "should delete the requested comment" do
194
+ lambda { do_delete }.should change(Comment, :count).by(-1)
195
+ end
196
+
197
+ it "should redirect to the comments list" do
198
+ do_delete
199
+ response.should redirect_to(forum_post_comments_url(@forum, @post))
200
+ end
201
+ end
202
+ end