diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-10-23 14:28:38 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-10-23 15:31:30 +0100 |
commit | 1b1dbc393a5f596e791b99d6e8e0c0eea06c8f87 (patch) | |
tree | 81aa93a682cbfe4718281dc95fb73bca057f075a | |
parent | 9e40cd6e0926e8b2197a19c337ae9ea8b974ac77 (diff) |
Add spec - currently failing due to typo.
-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 |