aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb5
-rw-r--r--config/routes.rb1
-rw-r--r--spec/controllers/request_controller_spec.rb16
3 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 3d9559c8b..c382a55f1 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -504,6 +504,11 @@ class RequestController < ApplicationController
end
end
+ def describe_state_requires_admin
+ @info_request = InfoRequest.find(params[:id])
+ @info_request.set_described_state("requires_admin", nil, params[:message])
+ end
+
# Used for links from polymorphic URLs e.g. in Atom feeds - just redirect to
# proper URL for the message the event refers to
def show_request_event
diff --git a/config/routes.rb b/config/routes.rb
index 0a0736eaa..b7c2a4bfe 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -55,6 +55,7 @@ ActionController::Routing::Routes.draw do |map|
request.similar_request '/similar/request/:url_title', :action => 'similar'
request.describe_state '/request/:id/describe', :action => 'describe_state', :conditions => {:method => :post}
+ request.describe_state_requires_admin '/request/:id/describe/requires_admin', :action => 'describe_state_requires_admin'
request.show_response_no_followup '/request/:id/response', :action => 'show_response'
request.show_response '/request/:id/response/:incoming_message_id', :action => 'show_response'
request.get_attachment_as_html '/request/:id/response/:incoming_message_id/attach/html/:part/*file_name', :action => 'get_attachment_as_html'
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index fdde54eeb..6fcf43cab 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1509,6 +1509,22 @@ 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", :id => @dog_request.id
+
+ @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/)