comments_controller_spec.rb
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'spec_helper'
describe CommentsController do
let(:app) { Fabricate(:app) }
let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) }
describe "POST /apps/:app_id/errs/:id/comments/create" do
render_views
before(:each) do
sign_in Fabricate(:admin)
end
context "successful comment creation" do
let(:problem) { Fabricate(:problem) }
let(:user) { Fabricate(:user) }
before(:each) do
post :create, :app_id => problem.app.id, :err_id => problem.id,
:comment => { :body => "One test comment", :user_id => user.id }
problem.reload
end
it "should create the comment" do
problem.comments.size.should == 1
end
it "should redirect to problem page" do
response.should redirect_to( app_err_path(problem.app, problem) )
end
end
end
describe "DELETE /apps/:app_id/errs/:id/comments/:id/destroy" do
render_views
before(:each) do
sign_in Fabricate(:admin)
end
context "successful comment deletion" do
let(:problem) { Fabricate(:problem_with_comments) }
let(:comment) { problem.reload.comments.first }
before(:each) do
delete :destroy, :app_id => problem.app.id, :err_id => problem.id, :id => comment.id.to_s
problem.reload
end
it "should delete the comment" do
problem.comments.detect{|c| c.id.to_s == comment.id }.should == nil
end
it "should redirect to problem page" do
response.should redirect_to( app_err_path(problem.app, problem) )
end
end
end
end