@@ -120,13 +120,15 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 | due_date = get_keyword(:due_date, :override => true) | |
|
124 | start_date = get_keyword(:start_date, :override => true) | |
|
123 | 125 | |
|
124 | 126 | # check permission |
|
125 | 127 | unless @@handler_options[:no_permission_check] |
|
126 | 128 | raise UnauthorizedAction unless user.allowed_to?(:add_issues, project) |
|
127 | 129 | end |
|
128 | 130 | |
|
129 | issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority) | |
|
131 | issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date) | |
|
130 | 132 | # check workflow |
|
131 | 133 | if status && issue.new_statuses_allowed_to(user).include?(status) |
|
132 | 134 | issue.status = status |
@@ -163,6 +165,8 class MailHandler < ActionMailer::Base | |||
|
163 | 165 | # Adds a note to an existing issue |
|
164 | 166 | def receive_issue_reply(issue_id) |
|
165 | 167 | status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) |
|
168 | due_date = get_keyword(:due_date, :override => true) | |
|
169 | start_date = get_keyword(:start_date, :override => true) | |
|
166 | 170 | |
|
167 | 171 | issue = Issue.find_by_id(issue_id) |
|
168 | 172 | return unless issue |
@@ -179,6 +183,9 class MailHandler < ActionMailer::Base | |||
|
179 | 183 | if status && issue.new_statuses_allowed_to(user).include?(status) |
|
180 | 184 | issue.status = status |
|
181 | 185 | end |
|
186 | issue.start_date = start_date if start_date | |
|
187 | issue.due_date = due_date if due_date | |
|
188 | ||
|
182 | 189 | issue.save! |
|
183 | 190 | logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info |
|
184 | 191 | journal |
@@ -245,7 +252,7 class MailHandler < ActionMailer::Base | |||
|
245 | 252 | @keywords[attr] |
|
246 | 253 | else |
|
247 | 254 | @keywords[attr] = begin |
|
248 | if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}[ \t]*:[ \t]*(.+)\s*$/i, '') | |
|
255 | if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr.to_s.humanize}[ \t]*:[ \t]*(.+)\s*$/i, '') | |
|
249 | 256 | $1.strip |
|
250 | 257 | elsif !@@handler_options[:issue][attr].blank? |
|
251 | 258 | @@handler_options[:issue][attr] |
@@ -51,4 +51,5 pulvinar dui, a gravida orci mi eget odio. Nunc a lacus. | |||
|
51 | 51 | |
|
52 | 52 | Project: onlinestore |
|
53 | 53 | Status: Resolved |
|
54 | ||
|
54 | due date: 2010-12-31 | |
|
55 | Start Date:2010-01-01 |
@@ -26,6 +26,9 Content-Transfer-Encoding: quoted-printable | |||
|
26 | 26 | This is reply |
|
27 | 27 | |
|
28 | 28 | Status: Resolved |
|
29 | due date: 2010-12-31 | |
|
30 | Start Date:2010-01-01 | |
|
31 | ||
|
29 | 32 | ------=_NextPart_000_0067_01C8D3CE.711F9CC0 |
|
30 | 33 | Content-Type: text/html; |
|
31 | 34 | charset="utf-8" |
@@ -55,6 +55,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
55 | 55 | assert_equal Project.find(2), issue.project |
|
56 | 56 | assert_equal IssueStatus.find_by_name('Resolved'), issue.status |
|
57 | 57 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') |
|
58 | assert_equal '2010-01-01', issue.start_date.to_s | |
|
59 | assert_equal '2010-12-31', issue.due_date.to_s | |
|
58 | 60 | # keywords should be removed from the email body |
|
59 | 61 | assert !issue.description.match(/^Project:/i) |
|
60 | 62 | assert !issue.description.match(/^Status:/i) |
@@ -243,7 +245,7 class MailHandlerTest < ActiveSupport::TestCase | |||
|
243 | 245 | assert_match /This is reply/, journal.notes |
|
244 | 246 | end |
|
245 | 247 | |
|
246 |
def test_add_issue_note_with_ |
|
|
248 | def test_add_issue_note_with_attribute_changes | |
|
247 | 249 | # This email contains: 'Status: Resolved' |
|
248 | 250 | journal = submit_email('ticket_reply_with_status.eml') |
|
249 | 251 | assert journal.is_a?(Journal) |
@@ -252,6 +254,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
252 | 254 | assert_equal Issue.find(2), journal.journalized |
|
253 | 255 | assert_match /This is reply/, journal.notes |
|
254 | 256 | assert_equal IssueStatus.find_by_name("Resolved"), issue.status |
|
257 | assert_equal '2010-01-01', issue.start_date.to_s | |
|
258 | assert_equal '2010-12-31', issue.due_date.to_s | |
|
255 | 259 | end |
|
256 | 260 | |
|
257 | 261 | def test_add_issue_note_should_send_email_notification |
General Comments 0
You need to be logged in to leave comments.
Login now