diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 1f79b0ef1..b0223588e 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1759,6 +1759,48 @@ describe RequestController, "sending overdue request alerts" do chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/} chicken_mails.size.should == 1 end + + it 'should send alerts for requests where the last event forming the initial request is a followup + being sent following a request for clarification' do + chicken_request = info_requests(:naughty_chicken_request) + chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 60.days + chicken_request.outgoing_messages[0].save! + RequestMailer.alert_overdue_requests + chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/} + chicken_mails.size.should == 1 + + # Request is waiting clarification + chicken_request.set_described_state('waiting_clarification') + + # Followup message is sent + outgoing_message = OutgoingMessage.new(:status => 'ready', + :message_type => 'followup', + :info_request_id => chicken_request.id, + :body => 'Some text', + :what_doing => 'normal_sort') + outgoing_message.send_message + outgoing_message.save! + + chicken_request = InfoRequest.find(chicken_request.id) + + # Last event forming the request is now the followup + chicken_request.last_event_forming_initial_request.event_type.should == 'followup_sent' + + # This isn't overdue, so no email + RequestMailer.alert_overdue_requests + chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/} + chicken_mails.size.should == 1 + + # Make the followup older + outgoing_message.last_sent_at = Time.now() - 60.days + outgoing_message.save! + + # Now it should be alerted on + RequestMailer.alert_overdue_requests + chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/} + chicken_mails.size.should == 2 + end + end describe RequestController, "sending unclassified new response reminder alerts" do |