aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/info_request.rb12
-rw-r--r--spec/models/info_request_spec.rb56
2 files changed, 63 insertions, 5 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index ca5a79b65..e199c682c 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -593,7 +593,13 @@ public
# days is a very long time.
def date_very_overdue_after
last_sent = last_event_forming_initial_request
- return Holiday.due_date_from(self.date_initial_request_last_sent_at, 40)
+ if self.public_body.is_school?
+ # schools have 60 working days maximum (even over a long holiday)
+ return Holiday.due_date_from(self.date_initial_request_last_sent_at, 60)
+ else
+ # public interest test ICO guidance gives 40 working maximum
+ return Holiday.due_date_from(self.date_initial_request_last_sent_at, 40)
+ end
end
# Where the initial request is sent to
@@ -723,9 +729,9 @@ public
elsif status == 'waiting_response'
"Awaiting response."
elsif status == 'waiting_response_overdue'
- "Response overdue."
+ "Response delayed."
elsif status == 'waiting_response_very_overdue'
- "Response long overdue."
+ "Long overdue."
elsif status == 'not_held'
"Information not held."
elsif status == 'rejected'
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index 91b42a52b..63ab31c53 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -120,7 +120,7 @@ describe InfoRequest do
end
describe "when calculating the status" do
- fixtures :info_requests, :info_request_events, :holidays
+ fixtures :info_requests, :info_request_events, :holidays, :public_bodies
before do
@ir = info_requests(:naughty_chicken_request)
@@ -158,7 +158,59 @@ describe InfoRequest do
@ir.calculate_status.should == 'waiting_response_very_overdue'
end
end
-
+
+ describe "when calculating the status for a school" do
+ fixtures :info_requests, :info_request_events, :holidays, :public_bodies
+
+ before do
+ @ir = info_requests(:naughty_chicken_request)
+ @ir.public_body.tag_string = "school"
+ @ir.public_body.is_school?.should == true
+ end
+
+ it "has expected sent date" do
+ @ir.last_event_forming_initial_request.outgoing_message.last_sent_at.strftime("%F").should == '2007-10-14'
+ end
+
+ it "has correct due date" do
+ @ir.date_response_required_by.strftime("%F").should == '2007-11-09'
+ end
+
+ it "has correct very overdue after date" do
+ @ir.date_very_overdue_after.strftime("%F").should == '2008-01-11' # 60 working days for schools
+ end
+
+ it "isn't overdue on due date (20 working days after request sent)" do
+ Time.stub!(:now).and_return(Time.utc(2007, 11, 9, 23, 59))
+ @ir.calculate_status.should == 'waiting_response'
+ end
+
+ it "is overdue a day after due date (20 working days after request sent)" do
+ Time.stub!(:now).and_return(Time.utc(2007, 11, 10, 00, 01))
+ @ir.calculate_status.should == 'waiting_response_overdue'
+ end
+
+ it "is still overdue 40 working days after request sent" do
+ Time.stub!(:now).and_return(Time.utc(2007, 12, 10, 23, 59))
+ @ir.calculate_status.should == 'waiting_response_overdue'
+ end
+
+ it "is still overdue the day after 40 working days after request sent" do
+ Time.stub!(:now).and_return(Time.utc(2007, 12, 11, 00, 01))
+ @ir.calculate_status.should == 'waiting_response_overdue'
+ end
+
+ it "is still overdue 60 working days after request sent" do
+ Time.stub!(:now).and_return(Time.utc(2008, 01, 11, 23, 59))
+ @ir.calculate_status.should == 'waiting_response_overdue'
+ end
+
+ it "is very overdue the day after 60 working days after request sent" do
+ Time.stub!(:now).and_return(Time.utc(2008, 01, 12, 00, 01))
+ @ir.calculate_status.should == 'waiting_response_very_overdue'
+ end
+ end
+
describe 'when asked if a user is the owning user for this request' do
before do