aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-03-13 17:13:57 +0000
committerLouise Crow <louise.crow@gmail.com>2014-03-13 17:13:57 +0000
commit983b59d9006e62cfdb5890f46cccecf08e5d7cd4 (patch)
tree7b14c7cedece69ec38ab80f9176e1f9727c4188a /spec/controllers
parentbda8a8f7f18cc0635d4a6fa5e96cccb4bb48e8c5 (diff)
parent61f57d7e50f97eee34b220a3eed515408dea37d0 (diff)
Merge branch 'rails-3-develop' of ssh://git.mysociety.org/data/git/public/alaveteli into rails-3-develop
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/comment_controller_spec.rb32
1 files changed, 23 insertions, 9 deletions
diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb
index c03615ce2..5e250f689 100644
--- a/spec/controllers/comment_controller_spec.rb
+++ b/spec/controllers/comment_controller_spec.rb
@@ -53,16 +53,30 @@ describe CommentController, "when commenting on a request" do
response.should render_template('new')
end
-
+
it "should not allow comments if comments are not allowed" do
- session[:user_id] = users(:silly_name_user).id
-
- expect {
- post :new, :url_title => info_requests(:spam_1_request).url_title,
- :comment => { :body => "I demand to be heard!" },
- :type => 'request', :submitted_comment => 1, :preview => 0
- }.to raise_error("Comments are not allowed on this request")
-
+ session[:user_id] = users(:silly_name_user).id
+ info_request = info_requests(:spam_1_request)
+
+ post :new, :url_title => info_request.url_title,
+ :comment => { :body => "I demand to be heard!" },
+ :type => 'request', :submitted_comment => 1, :preview => 0
+
+ response.should redirect_to(show_request_path(info_request.url_title))
+ flash[:notice].should == 'Comments are not allowed on this request'
+ end
+
+ it "should not allow comments from banned users" do
+ User.any_instance.stub(:ban_text).and_return('Banned from commenting')
+
+ user = users(:silly_name_user)
+ session[:user_id] = user.id
+
+ post :new, :url_title => info_requests(:fancy_dog_request).url_title,
+ :comment => { :body => comments(:silly_comment).body },
+ :type => 'request', :submitted_comment => 1, :preview => 0
+
+ response.should render_template('user/banned')
end
describe 'when commenting on an external request' do