@@ -0,0 +1,43 | |||||
|
1 | Return-Path: <jsmith@somenet.foo> | |||
|
2 | Received: from osiris ([127.0.0.1]) | |||
|
3 | by OSIRIS | |||
|
4 | with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200 | |||
|
5 | Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris> | |||
|
6 | From: "John Smith" <jsmith@somenet.foo> | |||
|
7 | To: <redmine@somenet.foo> | |||
|
8 | Subject: New ticket on a given project | |||
|
9 | Date: Sun, 22 Jun 2008 12:28:07 +0200 | |||
|
10 | MIME-Version: 1.0 | |||
|
11 | Content-Type: text/plain; | |||
|
12 | format=flowed; | |||
|
13 | charset="iso-8859-1"; | |||
|
14 | reply-type=original | |||
|
15 | Content-Transfer-Encoding: 7bit | |||
|
16 | X-Priority: 3 | |||
|
17 | X-MSMail-Priority: Normal | |||
|
18 | X-Mailer: Microsoft Outlook Express 6.00.2900.2869 | |||
|
19 | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 | |||
|
20 | ||||
|
21 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet | |||
|
22 | turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus | |||
|
23 | blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti | |||
|
24 | sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In | |||
|
25 | in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras | |||
|
26 | sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum | |||
|
27 | id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus | |||
|
28 | eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique | |||
|
29 | sed, mauris. Pellentesque habitant morbi tristique senectus et netus et | |||
|
30 | malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse | |||
|
31 | platea dictumst. | |||
|
32 | ||||
|
33 | Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque | |||
|
34 | sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem. | |||
|
35 | Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et, | |||
|
36 | dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed, | |||
|
37 | massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo | |||
|
38 | pulvinar dui, a gravida orci mi eget odio. Nunc a lacus. | |||
|
39 | ||||
|
40 | Projet: onlinestore | |||
|
41 | Tracker: Feature request | |||
|
42 | cat�gorie: Stock management | |||
|
43 | priorit�: Urgent |
@@ -17,6 +17,7 | |||||
17 |
|
17 | |||
18 | class MailHandler < ActionMailer::Base |
|
18 | class MailHandler < ActionMailer::Base | |
19 | include ActionView::Helpers::SanitizeHelper |
|
19 | include ActionView::Helpers::SanitizeHelper | |
|
20 | include Redmine::I18n | |||
20 |
|
21 | |||
21 | class UnauthorizedAction < StandardError; end |
|
22 | class UnauthorizedAction < StandardError; end | |
22 | class MissingInformation < StandardError; end |
|
23 | class MissingInformation < StandardError; end | |
@@ -217,8 +218,8 class MailHandler < ActionMailer::Base | |||||
217 | @keywords[attr] |
|
218 | @keywords[attr] | |
218 | else |
|
219 | else | |
219 | @keywords[attr] = begin |
|
220 | @keywords[attr] = begin | |
220 |
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body |
|
221 | if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && (v = extract_keyword!(plain_text_body, attr)) | |
221 |
|
|
222 | v | |
222 | elsif !@@handler_options[:issue][attr].blank? |
|
223 | elsif !@@handler_options[:issue][attr].blank? | |
223 | @@handler_options[:issue][attr] |
|
224 | @@handler_options[:issue][attr] | |
224 | end |
|
225 | end | |
@@ -226,6 +227,20 class MailHandler < ActionMailer::Base | |||||
226 | end |
|
227 | end | |
227 | end |
|
228 | end | |
228 |
|
229 | |||
|
230 | # Destructively extracts the value for +attr+ in +text+ | |||
|
231 | # Returns nil if no matching keyword found | |||
|
232 | def extract_keyword!(text, attr) | |||
|
233 | keys = [attr.to_s.humanize] | |||
|
234 | if attr.is_a?(Symbol) | |||
|
235 | keys << l("field_#{attr}", :default => '', :locale => user.language) if user | |||
|
236 | keys << l("field_#{attr}", :default => '', :locale => Setting.default_language) | |||
|
237 | end | |||
|
238 | keys.reject! {|k| k.blank?} | |||
|
239 | keys.collect! {|k| Regexp.escape(k)} | |||
|
240 | text.gsub!(/^(#{keys.join('|')})[ \t]*:[ \t]*(.+)\s*$/i, '') | |||
|
241 | $2 && $2.strip | |||
|
242 | end | |||
|
243 | ||||
229 | def target_project |
|
244 | def target_project | |
230 | # TODO: other ways to specify project: |
|
245 | # TODO: other ways to specify project: | |
231 | # * parse the email To field |
|
246 | # * parse the email To field |
@@ -229,6 +229,21 class MailHandlerTest < ActiveSupport::TestCase | |||||
229 | assert_equal false, submit_email('ticket_without_from_header.eml') |
|
229 | assert_equal false, submit_email('ticket_without_from_header.eml') | |
230 | end |
|
230 | end | |
231 |
|
231 | |||
|
232 | def test_add_issue_with_localized_attributes | |||
|
233 | User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr' | |||
|
234 | issue = submit_email('ticket_with_localized_attributes.eml', :allow_override => 'tracker,category,priority') | |||
|
235 | assert issue.is_a?(Issue) | |||
|
236 | assert !issue.new_record? | |||
|
237 | issue.reload | |||
|
238 | assert_equal 'New ticket on a given project', issue.subject | |||
|
239 | assert_equal User.find_by_login('jsmith'), issue.author | |||
|
240 | assert_equal Project.find(2), issue.project | |||
|
241 | assert_equal 'Feature request', issue.tracker.to_s | |||
|
242 | assert_equal 'Stock management', issue.category.to_s | |||
|
243 | assert_equal 'Urgent', issue.priority.to_s | |||
|
244 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') | |||
|
245 | end | |||
|
246 | ||||
232 | def test_add_issue_with_japanese_keywords |
|
247 | def test_add_issue_with_japanese_keywords | |
233 | tracker = Tracker.create!(:name => '開発') |
|
248 | tracker = Tracker.create!(:name => '開発') | |
234 | Project.find(1).trackers << tracker |
|
249 | Project.find(1).trackers << tracker |
General Comments 0
You need to be logged in to leave comments.
Login now