diff options
author | Mark Longair <mark@mysociety.org> | 2013-06-06 11:18:55 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-06-06 11:21:28 +0100 |
commit | e3bf8f35ad14f833ccc9d664b2c16683d5a22c28 (patch) | |
tree | a04a89119d433febf6cbb377d4cdb50bd95c442b | |
parent | 2f4c5ea991976ad9443431609f0274ea128353bb (diff) |
Cope with replying to a message with a missing or empty Subjecthotfix/0.11.0.5
-rw-r--r-- | app/models/info_request.rb | 2 | ||||
-rw-r--r-- | spec/models/info_request_spec.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index cf1af0e87..c549d6f5d 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -294,7 +294,7 @@ public end end def email_subject_followup(incoming_message = nil) - if incoming_message.nil? || !incoming_message.valid_to_reply_to? + if incoming_message.nil? || !incoming_message.valid_to_reply_to? || !incoming_message.subject 'Re: ' + self.email_subject_request else if incoming_message.subject.match(/^Re:/i) diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index b2f0a20fc..b32d8a04e 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -564,5 +564,17 @@ describe InfoRequest do end + describe 'when working out a subject for a followup emails' do + + it "should not be confused by an nil subject in the incoming message" do + ir = info_requests(:fancy_dog_request) + im = mock_model(IncomingMessage, + :subject => nil, + :valid_to_reply_to? => true) + subject = ir.email_subject_followup im + subject.should match(/^Re: Freedom of Information request.*fancy dog/) + end + + end end |