aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/admin_request_controller_spec.rb
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2011-08-09 21:09:10 +0100
committerRobin Houston <robin.houston@gmail.com>2011-08-09 21:09:10 +0100
commit7d1eb5df0c1bcc6a7a92755004faf85bc00496d4 (patch)
tree6f2cda5408b633662b865c1bc435cbb63b110ac8 /spec/controllers/admin_request_controller_spec.rb
parentb6860bea9d4569a52801d72734fa86849c232721 (diff)
parente6fda87211f3c525c17b0d8a2c039192a6c18bb6 (diff)
Merge branch 'master' into wdtk
Diffstat (limited to 'spec/controllers/admin_request_controller_spec.rb')
-rw-r--r--spec/controllers/admin_request_controller_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb
index d82e4a49c..1d9ebcdf3 100644
--- a/spec/controllers/admin_request_controller_spec.rb
+++ b/spec/controllers/admin_request_controller_spec.rb
@@ -39,3 +39,58 @@ describe AdminRequestController, "when administering requests" do
end
+describe AdminRequestController, "when administering the holding pen" do
+ integrate_views
+ fixtures :info_requests, :incoming_messages, :raw_emails, :users, :public_bodies, :public_body_translations
+ before(:each) do
+ basic_auth_login @request
+ load_raw_emails_data(raw_emails)
+ end
+
+ it "shows a rejection reason for an incoming message from an invalid address" do
+ ir = info_requests(:fancy_dog_request)
+ ir.allow_new_responses_from = 'authority_only'
+ ir.handle_rejected_responses = 'holding_pen'
+ ir.save!
+ receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "frob@nowhere.com")
+ get :show_raw_email, :id => InfoRequest.holding_pen_request.get_last_response.raw_email.id
+ response.should have_text(/Only the authority can reply to this request/)
+ end
+
+ it "allows redelivery even to a closed request" do
+ ir = info_requests(:fancy_dog_request)
+ ir.allow_new_responses_from = 'nobody'
+ ir.handle_rejected_responses = 'holding_pen'
+ ir.save!
+ InfoRequest.holding_pen_request.incoming_messages.length.should == 0
+ ir.incoming_messages.length.should == 1
+ receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "frob@nowhere.com")
+ InfoRequest.holding_pen_request.incoming_messages.length.should == 1
+ new_im = InfoRequest.holding_pen_request.incoming_messages[0]
+ ir.incoming_messages.length.should == 1
+ post :redeliver_incoming, :redeliver_incoming_message_id => new_im.id, :url_title => ir.url_title
+ ir = InfoRequest.find_by_url_title(ir.url_title)
+ ir.incoming_messages.length.should == 2
+ response.should redirect_to('http://test.host/admin/request/show/101')
+ InfoRequest.holding_pen_request.incoming_messages.length.should == 0
+ end
+
+ it "guesses a misdirected request" do
+ ir = info_requests(:fancy_dog_request)
+ ir.handle_rejected_responses = 'holding_pen'
+ ir.save!
+ mail_to = "request-#{ir.id}-asdfg@example.com"
+ receive_incoming_mail('incoming-request-plain.email', mail_to)
+ get :show_raw_email, :id => InfoRequest.holding_pen_request.get_last_response.raw_email.id
+ response.should have_text(/Could not identify the request/)
+ assigns[:info_requests][0].should == ir
+ end
+
+ it "destroys an incoming message" do
+ im = incoming_messages(:useless_incoming_message)
+ raw_email = im.raw_email.filepath
+ post :destroy_incoming, :incoming_message_id => im.id
+ assert_equal File.exists?(raw_email), false
+ end
+
+end