@@ -120,6 +120,7 class MailHandler < ActionMailer::Base | |||
|
120 | 120 | category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category))) |
|
121 | 121 | priority = (get_keyword(:priority) && IssuePriority.find_by_name(get_keyword(:priority))) |
|
122 | 122 | status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) |
|
123 | assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true))) | |
|
123 | 124 | due_date = get_keyword(:due_date, :override => true) |
|
124 | 125 | start_date = get_keyword(:start_date, :override => true) |
|
125 | 126 | |
@@ -128,7 +129,7 class MailHandler < ActionMailer::Base | |||
|
128 | 129 | raise UnauthorizedAction unless user.allowed_to?(:add_issues, project) |
|
129 | 130 | end |
|
130 | 131 | |
|
131 | issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date) | |
|
132 | issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date, :assigned_to => assigned_to) | |
|
132 | 133 | # check workflow |
|
133 | 134 | if status && issue.new_statuses_allowed_to(user).include?(status) |
|
134 | 135 | issue.status = status |
@@ -167,6 +168,7 class MailHandler < ActionMailer::Base | |||
|
167 | 168 | status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) |
|
168 | 169 | due_date = get_keyword(:due_date, :override => true) |
|
169 | 170 | start_date = get_keyword(:start_date, :override => true) |
|
171 | assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true))) | |
|
170 | 172 | |
|
171 | 173 | issue = Issue.find_by_id(issue_id) |
|
172 | 174 | return unless issue |
@@ -185,6 +187,7 class MailHandler < ActionMailer::Base | |||
|
185 | 187 | end |
|
186 | 188 | issue.start_date = start_date if start_date |
|
187 | 189 | issue.due_date = due_date if due_date |
|
190 | issue.assigned_to = assigned_to if assigned_to | |
|
188 | 191 | |
|
189 | 192 | issue.save! |
|
190 | 193 | logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info |
@@ -320,4 +323,14 class MailHandler < ActionMailer::Base | |||
|
320 | 323 | end |
|
321 | 324 | body.strip |
|
322 | 325 | end |
|
326 | ||
|
327 | def find_user_from_keyword(keyword) | |
|
328 | user ||= User.find_by_mail(keyword) | |
|
329 | user ||= User.find_by_login(keyword) | |
|
330 | if user.nil? && keyword.match(/ /) | |
|
331 | firstname, lastname = *(keyword.split) # "First Last Throwaway" | |
|
332 | user ||= User.find_by_firstname_and_lastname(firstname, lastname) | |
|
333 | end | |
|
334 | user | |
|
335 | end | |
|
323 | 336 | end |
@@ -53,3 +53,5 Project: onlinestore | |||
|
53 | 53 | Status: Resolved |
|
54 | 54 | due date: 2010-12-31 |
|
55 | 55 | Start Date:2010-01-01 |
|
56 | Assigned to: John Smith | |
|
57 |
@@ -28,6 +28,7 This is reply | |||
|
28 | 28 | Status: Resolved |
|
29 | 29 | due date: 2010-12-31 |
|
30 | 30 | Start Date:2010-01-01 |
|
31 | Assigned to: jsmith@somenet.foo | |
|
31 | 32 | |
|
32 | 33 | ------=_NextPart_000_0067_01C8D3CE.711F9CC0 |
|
33 | 34 | Content-Type: text/html; |
@@ -57,6 +57,7 class MailHandlerTest < ActiveSupport::TestCase | |||
|
57 | 57 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') |
|
58 | 58 | assert_equal '2010-01-01', issue.start_date.to_s |
|
59 | 59 | assert_equal '2010-12-31', issue.due_date.to_s |
|
60 | assert_equal User.find_by_login('jsmith'), issue.assigned_to | |
|
60 | 61 | # keywords should be removed from the email body |
|
61 | 62 | assert !issue.description.match(/^Project:/i) |
|
62 | 63 | assert !issue.description.match(/^Status:/i) |
@@ -256,6 +257,7 class MailHandlerTest < ActiveSupport::TestCase | |||
|
256 | 257 | assert_equal IssueStatus.find_by_name("Resolved"), issue.status |
|
257 | 258 | assert_equal '2010-01-01', issue.start_date.to_s |
|
258 | 259 | assert_equal '2010-12-31', issue.due_date.to_s |
|
260 | assert_equal User.find_by_login('jsmith'), issue.assigned_to | |
|
259 | 261 | end |
|
260 | 262 | |
|
261 | 263 | def test_add_issue_note_should_send_email_notification |
General Comments 0
You need to be logged in to leave comments.
Login now