diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 20 | ||||
-rw-r--r-- | spec/factories/outgoing_messages.rb | 10 | ||||
-rw-r--r-- | spec/models/info_request_spec.rb | 11 |
3 files changed, 34 insertions, 7 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index f7c935af3..6c0f4573e 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1827,7 +1827,15 @@ describe RequestController, "when sending a followup message" do # make the followup session[:user_id] = users(:bob_smith_user).id - post :show_response, :outgoing_message => { :body => "What a useless response! You suck.", :what_doing => 'normal_sort' }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1 + + post :show_response, + :outgoing_message => { + :body => "What a useless response! You suck.", + :what_doing => 'normal_sort' + }, + :id => info_requests(:fancy_dog_request).id, + :incoming_message_id => incoming_messages(:useless_incoming_message), + :submitted_followup => 1 # check it worked deliveries = ActionMailer::Base.deliveries @@ -1982,7 +1990,15 @@ describe RequestController, "sending overdue request alerts" do :info_request_id => chicken_request.id, :body => 'Some text', :what_doing => 'normal_sort') - outgoing_message.send_message + + outgoing_message.sendable? + mail_message = OutgoingMailer.followup( + outgoing_message.info_request, + outgoing_message, + outgoing_message.incoming_message_followup + ).deliver + outgoing_message.record_email_delivery(mail_message.to_addrs.join(', '), mail_message.message_id) + outgoing_message.save! chicken_request = InfoRequest.find(chicken_request.id) diff --git a/spec/factories/outgoing_messages.rb b/spec/factories/outgoing_messages.rb index 3887d3f48..e11cbdfb9 100644 --- a/spec/factories/outgoing_messages.rb +++ b/spec/factories/outgoing_messages.rb @@ -10,7 +10,9 @@ FactoryGirl.define do body 'Some information please' what_doing 'normal_sort' end + end + factory :internal_review_request do ignore do status 'ready' @@ -18,6 +20,7 @@ FactoryGirl.define do body 'I want a review' what_doing 'internal_review' end + end # FIXME: This here because OutgoingMessage has an after_initialize, @@ -30,9 +33,14 @@ FactoryGirl.define do :message_type => message_type, :body => body, :what_doing => what_doing }) } + after_create do |outgoing_message| - outgoing_message.send_message + outgoing_message.sendable? + outgoing_message.record_email_delivery( + 'test@example.com', + 'ogm-14+537f69734b97c-1ebd@localhost') end + end end diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index afb8e0949..9ad616ea5 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -848,9 +848,11 @@ describe InfoRequest do context "a series of events on a request" do it "should have sensible events after the initial request has been made" do # An initial request is sent - # The logic that changes the status when a message is sent is mixed up - # in OutgoingMessage#send_message. So, rather than extract it (or call it) - # let's just duplicate what it does here for the time being. + # FIXME: The logic that changes the status when a message + # is sent is mixed up in + # OutgoingMessage#record_email_delivery. So, rather than + # extract it (or call it) let's just duplicate what it does + # here for the time being. request.log_event('sent', {}) request.set_described_state('waiting_response') @@ -919,7 +921,8 @@ describe InfoRequest do request.log_event("status_update", {}) request.set_described_state("waiting_response") # A normal follow up is sent - # This is normally done in OutgoingMessage#send_message + # This is normally done in + # OutgoingMessage#record_email_delivery request.log_event('followup_sent', {}) request.set_described_state('waiting_response') |