]> source.dussan.org Git - redmine.git/commitdiff
Merged r13593 (#17705).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Nov 2014 10:42:59 +0000 (10:42 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Nov 2014 10:42:59 +0000 (10:42 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13634 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mail_handler.rb
test/unit/mail_handler_test.rb

index 4aaa21c982350634041e8232682952fa54033284..6fcfcdb24574b9ee458636e8076e04977848e6aa 100644 (file)
@@ -145,7 +145,7 @@ class MailHandler < ActionMailer::Base
   private
 
   MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
-  ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
+  ISSUE_REPLY_SUBJECT_RE = %r{\[(?:[^\]]*\s+)?#(\d+)\]}
   MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
 
   def dispatch
index 1a34690311964d42b593357d70df853605038676..514666025263cb2be619b27b0e127e85c70d88d0 100644 (file)
@@ -680,6 +680,30 @@ class MailHandlerTest < ActiveSupport::TestCase
     assert_equal 'Feature request', journal.issue.tracker.name
   end
 
+  def test_update_issue_should_accept_issue_id_after_space_inside_brackets
+    journal = submit_email('ticket_reply_with_status.eml') do |email|
+      assert email.sub!(/^Subject:.*$/, "Subject: Re: [Feature request #2] Add ingredients categories")
+    end
+    assert journal.is_a?(Journal)
+    assert_equal Issue.find(2), journal.journalized
+  end
+
+  def test_update_issue_should_accept_issue_id_inside_brackets
+    journal = submit_email('ticket_reply_with_status.eml') do |email|
+      assert email.sub!(/^Subject:.*$/, "Subject: Re: [#2] Add ingredients categories")
+    end
+    assert journal.is_a?(Journal)
+    assert_equal Issue.find(2), journal.journalized
+  end
+
+  def test_update_issue_should_ignore_bogus_issue_ids_in_subject
+    journal = submit_email('ticket_reply_with_status.eml') do |email|
+      assert email.sub!(/^Subject:.*$/, "Subject: Re: [12345#1][bogus#1][Feature request #2] Add ingredients categories")
+    end
+    assert journal.is_a?(Journal)
+    assert_equal Issue.find(2), journal.journalized
+  end
+
   def test_update_issue_with_attribute_changes
     # This email contains: 'Status: Resolved'
     journal = submit_email('ticket_reply_with_status.eml')