diff options
-rw-r--r-- | app/controllers/holiday_controller.rb | 2 | ||||
-rw-r--r-- | app/models/holiday.rb | 5 | ||||
-rw-r--r-- | app/models/info_request.rb | 6 | ||||
-rw-r--r-- | spec/models/customstates.rb | 4 | ||||
-rw-r--r-- | spec/models/holiday_spec.rb | 4 |
5 files changed, 11 insertions, 10 deletions
diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb index 7f62aa26d..1f81830f9 100644 --- a/app/controllers/holiday_controller.rb +++ b/app/controllers/holiday_controller.rb @@ -14,7 +14,7 @@ class HolidayController < ApplicationController def due_date if params[:holiday] @request_date = Date.strptime(params[:holiday]) or raise "Invalid date" - @due_date = Holiday.due_date_from(@request_date, 20) + @due_date = Holiday.due_date_from_working_days(@request_date, 20) @skipped = Holiday.all( :conditions => [ 'day >= ? AND day <= ?', @request_date.strftime("%F"), @due_date.strftime("%F") diff --git a/app/models/holiday.rb b/app/models/holiday.rb index 490fdb8c7..1d70c12a3 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -32,9 +32,10 @@ class Holiday < ActiveRecord::Base date.wday == 0 || date.wday == 6 || holidays.include?(date) end - # Calculate the date on which a request made on a given date falls due. + # Calculate the date on which a request made on a given date falls due when + # days are given in working days # i.e. it is due by the end of that day. - def Holiday.due_date_from(start_date, working_days) + def Holiday.due_date_from_working_days(start_date, working_days) # convert date/times into dates start_date = start_date.to_date diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 2e16d0f58..b34f51df2 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -688,7 +688,7 @@ public # things, e.g. fees, not properly covered. def date_response_required_by days_later = MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20) - return Holiday.due_date_from(self.date_initial_request_last_sent_at, days_later) + return Holiday.due_date_from_working_days(self.date_initial_request_last_sent_at, days_later) end # This is a long stop - even with UK public interest test extensions, 40 # days is a very long time. @@ -698,10 +698,10 @@ public school_very_late_days_later = MySociety::Config.get('SPECIAL_REPLY_VERY_LATE_AFTER_DAYS', 60) 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) + return Holiday.due_date_from_working_days(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) + return Holiday.due_date_from_working_days(self.date_initial_request_last_sent_at, 40) end end diff --git a/spec/models/customstates.rb b/spec/models/customstates.rb index 3488e6730..bffbe86fb 100644 --- a/spec/models/customstates.rb +++ b/spec/models/customstates.rb @@ -13,7 +13,7 @@ module InfoRequestCustomStates return 'deadline_extended' if Time.now.strftime("%Y-%m-%d") < self.date_deadline_extended.strftime("%Y-%m-%d") return 'waiting_response_very_overdue' if - Time.now.strftime("%Y-%m-%d") > Holiday.due_date_from(self.date_deadline_extended, 15).strftime("%Y-%m-%d") + Time.now.strftime("%Y-%m-%d") > Holiday.due_date_from_working_days(self.date_deadline_extended, 15).strftime("%Y-%m-%d") return 'waiting_response_overdue' end return 'waiting_response_very_overdue' if @@ -27,7 +27,7 @@ module InfoRequestCustomStates # XXX shouldn't this be 15 days after the date the status was # changed to "deadline extended"? Or perhaps 15 days ater the # initial request due date? - return Holiday.due_date_from(self.date_response_required_by, 15) + return Holiday.due_date_from_working_days(self.date_response_required_by, 15) end module ClassMethods diff --git a/spec/models/holiday_spec.rb b/spec/models/holiday_spec.rb index 30beacb50..5d3f76d24 100644 --- a/spec/models/holiday_spec.rb +++ b/spec/models/holiday_spec.rb @@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Holiday, " when calculating due date" do def due_date(ymd) - return Holiday.due_date_from(Date.strptime(ymd), 20).strftime("%F") + return Holiday.due_date_from_working_days(Date.strptime(ymd), 20).strftime("%F") end context "in working days" do @@ -43,7 +43,7 @@ describe Holiday, " when calculating due date" do end it "handles Time objects" do - Holiday.due_date_from(Time.utc(2009, 03, 16, 12, 0, 0), 20).strftime('%F').should == '2009-04-16' + Holiday.due_date_from_working_days(Time.utc(2009, 03, 16, 12, 0, 0), 20).strftime('%F').should == '2009-04-16' end end |