aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/request_controller_spec.rb
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-03-03 09:40:21 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-03-03 09:40:21 +1100
commit00c188d129696353c48a2598ec7c747b8a90d658 (patch)
tree02eada2c1ee95cbd09088b81f3026da4ce1d189a /spec/controllers/request_controller_spec.rb
parent260bd5bf263683919bac17ce8dfebd153a45e8aa (diff)
Add basic authentication to new action
Diffstat (limited to 'spec/controllers/request_controller_spec.rb')
-rw-r--r--spec/controllers/request_controller_spec.rb42
1 files changed, 26 insertions, 16 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 25ad1df5f..be9df90c4 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1241,6 +1241,32 @@ describe RequestController, "when viewing an individual response for reply/follo
end
+describe RequestController, "describe_state_requires_admin" do
+ context "logged in as owner of request" do
+ it "should set the state when classified as requires_admin" do
+ info_request = info_requests(:fancy_dog_request)
+ session[:user_id] = info_request.user_id
+
+ InfoRequest.should_receive(:find_by_url_title!).with("info_request").and_return(info_request)
+ info_request.should_receive(:set_described_state).with("requires_admin", nil, "Something weird happened")
+
+ post :describe_state_requires_admin, :message => "Something weird happened", :url_title => "info_request"
+ end
+ end
+
+ context "logged out" do
+ it "should redirect to the login page" do
+ info_request = info_requests(:fancy_dog_request)
+ InfoRequest.should_receive(:find_by_url_title!).with("info_request").and_return(info_request)
+ post :describe_state_requires_admin, :message => "Something weird happened", :url_title => "info_request"
+
+ # Ugh.
+ post_redirect = PostRedirect.get_last_post_redirect
+ response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
+ end
+ end
+end
+
describe RequestController, "when classifying an information request" do
describe 'if the request is external' do
@@ -1509,22 +1535,6 @@ describe RequestController, "when classifying an information request" do
mail.from_addrs.first.to_s.should == @request_owner.name_and_email
end
- it "should send an email with a message when classified as requires_admin" do
- post :describe_state_requires_admin, :message => "Something weird happened", :url_title => @dog_request.url_title
-
- @dog_request.reload
- @dog_request.awaiting_description.should == false
- @dog_request.described_state.should == 'requires_admin'
- @dog_request.get_last_response_event.calculated_state.should == 'requires_admin'
-
- deliveries = ActionMailer::Base.deliveries
- deliveries.size.should == 1
- mail = deliveries[0]
- mail.body.should =~ /as needing admin/
- mail.body.should =~ /Something weird happened/
- mail.from_addrs.first.to_s.should == @request_owner.name_and_email
- end
-
it 'should say it is showing advice as to what to do next' do
post_status('rejected')
flash[:notice].should match(/Here is what to do now/)