From b2684a2c3ec023f419eb92b30102f2308dbc01c2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 1 Aug 2013 19:21:46 +0100 Subject: Move outgoing message admin actions to their own controller. Eventually this should use standard RESTful routing. --- spec/controllers/admin_request_controller_spec.rb | 12 ------------ 1 file changed, 12 deletions(-) (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 b7b726507..ed9327f25 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -52,18 +52,6 @@ describe AdminRequestController, "when administering requests" do end - it "edits an outgoing message" do - get :edit_outgoing, :id => outgoing_messages(:useless_outgoing_message) - end - - it "saves edits to an outgoing_message" do - outgoing_messages(:useless_outgoing_message).body.should include("fancy dog") - post :update_outgoing, { :id => outgoing_messages(:useless_outgoing_message), :outgoing_message => { :body => "Why do you have such a delicious cat?" } } - request.flash[:notice].should include('successful') - ir = OutgoingMessage.find(outgoing_messages(:useless_outgoing_message).id) - ir.body.should include("delicious cat") - end - describe 'when fully destroying a request' do it 'expires the file cache for that request' do -- cgit v1.2.3 From 1887774daee72298174901d10b4e75492b9911d2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 8 Aug 2013 17:14:51 +0100 Subject: Move incoming message admin to its own controller. Make specs that depend on multiple controllers and models interacting integration specs. --- spec/controllers/admin_request_controller_spec.rb | 74 ----------------------- 1 file changed, 74 deletions(-) (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 ed9327f25..42b4bcbc1 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -81,55 +81,6 @@ describe AdminRequestController, "when administering the holding pen" do response.should contain "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(:controller=>'admin_request', :action=>'show', :id=>101) - InfoRequest.holding_pen_request.incoming_messages.length.should == 0 - end - - it "allows redelivery to more than one request" do - ir1 = info_requests(:fancy_dog_request) - ir1.allow_new_responses_from = 'nobody' - ir1.handle_rejected_responses = 'holding_pen' - ir1.save! - ir1.incoming_messages.length.should == 1 - ir2 = info_requests(:another_boring_request) - ir2.incoming_messages.length.should == 1 - - receive_incoming_mail('incoming-request-plain.email', ir1.incoming_email, "frob@nowhere.com") - InfoRequest.holding_pen_request.incoming_messages.length.should == 1 - - new_im = InfoRequest.holding_pen_request.incoming_messages[0] - post :redeliver_incoming, :redeliver_incoming_message_id => new_im.id, :url_title => "#{ir1.url_title},#{ir2.url_title}" - ir1.reload - ir1.incoming_messages.length.should == 2 - ir2.reload - ir2.incoming_messages.length.should == 2 - response.should redirect_to(:controller=>'admin_request', :action=>'show', :id=>ir2.id) - InfoRequest.holding_pen_request.incoming_messages.length.should == 0 - end - - it 'expires the file cache for the previous request' do - current_info_request = info_requests(:fancy_dog_request) - destination_info_request = info_requests(:naughty_chicken_request) - incoming_message = incoming_messages(:useless_incoming_message) - @controller.should_receive(:expire_for_request).with(current_info_request) - post :redeliver_incoming, :redeliver_incoming_message_id => incoming_message.id, - :url_title => destination_info_request.url_title - end - it "guesses a misdirected request" do ir = info_requests(:fancy_dog_request) ir.handle_rejected_responses = 'holding_pen' @@ -146,32 +97,7 @@ describe AdminRequestController, "when administering the holding pen" do assigns[:info_requests][0].should == ir end - describe 'when destroying an incoming message' do - before do - @im = incoming_messages(:useless_incoming_message) - @controller.stub!(:expire_for_request) - end - - it "destroys the raw email file" do - raw_email = @im.raw_email.filepath - assert_equal File.exists?(raw_email), true - post :destroy_incoming, :incoming_message_id => @im.id - assert_equal File.exists?(raw_email), false - end - - it 'asks the incoming message to fully destroy itself' do - IncomingMessage.stub!(:find).and_return(@im) - @im.should_receive(:fully_destroy) - post :destroy_incoming, :incoming_message_id => @im.id - end - - it 'expires the file cache for the associated info_request' do - @controller.should_receive(:expire_for_request).with(@im.info_request) - post :destroy_incoming, :incoming_message_id => @im.id - end - - end it "shows a suitable default 'your email has been hidden' message" do ir = info_requests(:fancy_dog_request) -- cgit v1.2.3 From bc743d9fc8c8f740f37b91cbe374c6ae20b10619 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 27 Aug 2013 16:13:02 +0100 Subject: Add public criteria for message event access methods get_last_response_event and get_last_outgoing_event are used in various places to determine which events to link to, use in queries etc. Restrict them to refer to the last publicly visible event of the relevant type, and rename them to make that clear. --- spec/controllers/admin_request_controller_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (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 42b4bcbc1..c374ff90d 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -77,7 +77,7 @@ describe AdminRequestController, "when administering the holding pen" do 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 + get :show_raw_email, :id => InfoRequest.holding_pen_request.get_last_public_response.raw_email.id response.should contain "Only the authority can reply to this request" end @@ -88,7 +88,8 @@ describe AdminRequestController, "when administering the holding pen" do ir.save! mail_to = "request-#{ir.id}-asdfg@example.com" receive_incoming_mail('incoming-request-plain.email', mail_to) - interesting_email = InfoRequest.holding_pen_request.get_last_response.raw_email.id + interesting_email = InfoRequest.holding_pen_request.get_last_public_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 -- cgit v1.2.3