diff options
author | Francis Irving <francis@mysociety.org> | 2010-07-13 23:54:46 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-07-13 23:54:46 +0100 |
commit | 59395b3bdf19aed7bf5f77656afa6c31dad7e138 (patch) | |
tree | b6e4c9f9e5b4a9f792a550ce3af727ae32b1cba1 /spec/models/info_request_spec.rb | |
parent | 452ac41f05f655a9fd23c8df4796f26632c23050 (diff) | |
parent | da2c0aaf5f0d07baa3a355033a92d5dd295f2f13 (diff) |
Merge branch 'master' into francis-profile-photo
Conflicts:
app/views/user/show.rhtml
commonlib
spec/controllers/user_controller_spec.rb
Diffstat (limited to 'spec/models/info_request_spec.rb')
-rw-r--r-- | spec/models/info_request_spec.rb | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index b16ced344..63ab31c53 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -110,38 +110,107 @@ describe InfoRequest do it "should cope with indexing after item is deleted" do rebuild_xapian_index - verbose = false # delete event from underneath indexing; shouldn't cause error info_request_events(:useless_incoming_message_event).save! info_request_events(:useless_incoming_message_event).destroy - ActsAsXapian.update_index(true, verbose) + update_xapian_index end 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) 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 "isn't overdue on due date" do + it "has correct very overdue after date" do + @ir.date_very_overdue_after.strftime("%F").should == '2007-12-10' + 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 " do - Time.stub!(:now).and_return(Time.utc(2007, 11, 10)) + 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 very 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_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 |