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