From 1708f4a4c3f27e5bbbbb5818623dc1eb6688d2f0 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 3 Aug 2011 15:11:28 +0100 Subject: Log the reason why an incoming mail is routed to the holding pen, and display it to administrators. Closes #107. --- spec/controllers/admin_request_controller_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec/controllers/admin_request_controller_spec.rb') diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index d82e4a49c..0b12fa97a 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -39,3 +39,22 @@ 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 + +end -- cgit v1.2.3 From 99548c87d201871a150e395c334e07149651996a Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 8 Aug 2011 11:54:27 +0100 Subject: Guess holding pen emails based on having a correct hash and an incorrect id. Closes #117 --- spec/controllers/admin_request_controller_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spec/controllers/admin_request_controller_spec.rb') diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 0b12fa97a..04e412e76 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -57,4 +57,15 @@ describe AdminRequestController, "when administering the holding pen" do response.should have_text(/Only the authority can reply to this request/) 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 + end -- cgit v1.2.3 From 8d079ca778e2905a61c947648d924cb6c4f79724 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 8 Aug 2011 13:27:06 +0100 Subject: Fix dependency problem when deleting incoming messages. Closes #115 --- spec/controllers/admin_request_controller_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spec/controllers/admin_request_controller_spec.rb') diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 04e412e76..eab9db4af 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -68,4 +68,11 @@ describe AdminRequestController, "when administering the holding pen" do 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 -- cgit v1.2.3 From e6fda87211f3c525c17b0d8a2c039192a6c18bb6 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 8 Aug 2011 16:36:38 +0100 Subject: allow admin to redeliver emails to closed requests. Fixes #116 --- spec/controllers/admin_request_controller_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec/controllers/admin_request_controller_spec.rb') diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index eab9db4af..1d9ebcdf3 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -57,6 +57,24 @@ describe AdminRequestController, "when administering the holding pen" do 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' -- cgit v1.2.3 From 6e57ba619e11ee76a29eda12e7cfef1f9aefba8e Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 10 Aug 2011 16:19:48 +0100 Subject: Fix up missing fixtures (causing failures dependent on order the tests were funr). Also tidy up raw_email setup code to match everywhere. --- spec/controllers/admin_request_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/admin_request_controller_spec.rb') diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 1d9ebcdf3..ee0acb637 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AdminRequestController, "when administering requests" do integrate_views - fixtures :info_requests, :outgoing_messages, :users, :info_request_events + fixtures :info_requests, :outgoing_messages, :users, :info_request_events, :public_bodies, :public_body_translations before { basic_auth_login @request } it "shows the index/list page" do -- cgit v1.2.3 From 10e7ce5610731c073553072724c6ef7e44236781 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Thu, 11 Aug 2011 10:09:29 +0100 Subject: Show the rejected reason for the incoming message in question, not the most recent rejected reason for the info request in question. Fixes #129. --- spec/controllers/admin_request_controller_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'spec/controllers/admin_request_controller_spec.rb') diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index ee0acb637..423c2fb49 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -78,10 +78,15 @@ describe AdminRequestController, "when administering the holding pen" do it "guesses a misdirected request" do ir = info_requests(:fancy_dog_request) ir.handle_rejected_responses = 'holding_pen' + ir.allow_new_responses_from = 'authority_only' 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 + interesting_email = InfoRequest.holding_pen_request.get_last_response.raw_email.id + # now we add another message to the queue, which we're not interested in + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "") + InfoRequest.holding_pen_request.incoming_messages.length.should == 2 + get :show_raw_email, :id => interesting_email response.should have_text(/Could not identify the request/) assigns[:info_requests][0].should == ir end -- cgit v1.2.3