aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb3
-rw-r--r--spec/controllers/request_controller_spec.rb92
2 files changed, 64 insertions, 31 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index c89137afb..d0c12dc28 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_controller.rb,v 1.153 2009-03-23 10:46:29 tony Exp $
+# $Id: request_controller.rb,v 1.154 2009-04-03 14:22:02 louise Exp $
class RequestController < ApplicationController
@@ -24,6 +24,7 @@ class RequestController < ApplicationController
@info_request_events = @info_request.info_request_events
@status = @info_request.calculate_status
@collapse_quotes = params[:unfold] ? false : true
+ @update_status = params[:update_status] ? true : false
@is_owning_user = !authenticated_user.nil? && (authenticated_user.id == @info_request.user_id || authenticated_user.owns_every_request?)
@events_needing_description = @info_request.events_needing_description
last_event = @events_needing_description[-1]
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index e37d5bf7a..856b4c804 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1,6 +1,11 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe RequestController, "when listing recent requests" do
+
+ before(:all) do
+ rebuild_xapian_index
+ end
+
it "should be successful" do
get :list, :view => 'recent'
response.should be_success
@@ -20,8 +25,9 @@ describe RequestController, "when listing recent requests" do
end
end
+
describe RequestController, "when showing one request" do
- integrate_views
+
fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
it "should be successful" do
@@ -43,39 +49,65 @@ describe RequestController, "when showing one request" do
get :show, :url_title => info_requests(:naughty_chicken_request).id
response.should redirect_to(:action => 'show', :url_title => info_requests(:naughty_chicken_request).url_title)
end
+
+ describe 'when handling an update_status parameter' do
+
+ before do
+ mock_request = mock_model(InfoRequest, :url_title => 'test_title',
+ :title => 'test title',
+ :null_object => true)
+ InfoRequest.stub!(:find_by_url_title).and_return(mock_request)
+ end
- it "should receive incoming messages, send email to creator, and show them" do
- get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
- size_before = assigns[:info_request_events].size
-
- ir = info_requests(:fancy_dog_request)
- receive_incoming_mail('incoming-request-plain.email', ir.incoming_email)
- deliveries = ActionMailer::Base.deliveries
- deliveries.size.should == 1
- mail = deliveries[0]
- mail.body.should =~ /You have a new response to the Freedom of Information request/
+ it 'should assign the "update status" flag to the view as true if the parameter is present' do
+ get :show, :url_title => 'test_title', :update_status => 1
+ assigns[:update_status].should be_true
+ end
- get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
- (assigns[:info_request_events].size - size_before).should == 1
+ it 'should assign the "update status" flag to the view as true if the parameter is present' do
+ get :show, :url_title => 'test_title'
+ assigns[:update_status].should be_false
+ end
+
end
- it "should download attachments" do
- get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
- response.content_type.should == "text/html"
- size_before = assigns[:info_request_events].size
-
- ir = info_requests(:fancy_dog_request)
- receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
-
- get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
- (assigns[:info_request_events].size - size_before).should == 1
-
- get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2
- response.content_type.should == "text/plain"
- response.should have_text(/Second hello/)
- get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3
- response.content_type.should == "text/plain"
- response.should have_text(/First hello/)
+ describe 'when handling incoming mail' do
+
+ integrate_views
+
+ it "should receive incoming messages, send email to creator, and show them" do
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ size_before = assigns[:info_request_events].size
+
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('incoming-request-plain.email', ir.incoming_email)
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ mail = deliveries[0]
+ mail.body.should =~ /You have a new response to the Freedom of Information request/
+
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ (assigns[:info_request_events].size - size_before).should == 1
+ end
+
+ it "should download attachments" do
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ response.content_type.should == "text/html"
+ size_before = assigns[:info_request_events].size
+
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
+
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ (assigns[:info_request_events].size - size_before).should == 1
+
+ get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2
+ response.content_type.should == "text/plain"
+ response.should have_text(/Second hello/)
+ get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3
+ response.content_type.should == "text/plain"
+ response.should have_text(/First hello/)
+ end
end
end