OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix mail handler attrs
Oliver Güntherfc7c5e3a4263
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rbindex 3525d0d6ba2..9951bbfb90f 100644--- a/app/models/mail_handler.rb+++ b/app/models/mail_handler.rb@@ -355,7 +355,10 @@ class MailHandler < ActionMailer::Baseenddef human_attr_translations(attr)- keys = [attr.to_s.humanize]+ keys = [+ attr.to_s,+ attr.to_s.humanize+ ][user&.language, Setting.default_language].compact_blank.each do |lang|keys << all_attribute_translations(lang)[attr]diff --git a/docs/installation-and-operations/configuration/incoming-emails/README.md b/docs/installation-and-operations/configuration/incoming-emails/README.mdindex 6b3f9db7fb1..24be6702afe 100644--- a/docs/installation-and-operations/configuration/incoming-emails/README.md+++ b/docs/installation-and-operations/configuration/incoming-emails/README.md@@ -180,21 +180,22 @@ OR set it as fixed variable with `project=identifier`.The subject of the work package that shall be created is derived from the subject of the email. The body of the email gets parsed and all lines that contain recognized keys are removed. What is left will become the description.-Other available keys for the email are:--| Key | Description | Example |-|-----------------|-------------------------------------------------------|----------------------------------|-| Project | sets the project. Use the project identifier | Project:test\_project |-| Accountable | sets the accountable, via user email or login | Accountable:[email protected] |-| Assignee | sets the assignee. Use the email or login of the user | Assignee:[email protected] |-| Type | sets the type | type:Milestone |-| Version | sets the version | version:v4.1.0 |-| Start date | sets the start date | start date:2015-02-28 |-| Due date | sets the finish date | |-| Estimated hours | sets the estimated hours. Use a number | Estimated hours:10.5 |-| Remaining hours | sets the remaining hours. Use a number | Remaining hours:2.5 |-| Status | sets the status | Status:closed |-| priority | sets the priority | priority:High |+Other available keys for the email are as follows. You can always use the internal **Key** or the **Name** of the attribute. The name will depend on the system's default language or the selected language of the user identified through the email address.++| Key | Name (EN) | Description | Example |+| --------------- | --------------- | ----------------------------------------------------- | -------------------------------- |+| project | Project | sets the project. Use the project identifier | project:test\_project |+| responsible | Accountable | sets the accountable, via user email or login | responsible:[email protected] |+| assigned_to | Assignee | sets the assignee. Use the email or login of the user | assignee:[email protected] |+| type | Type | sets the type | type:Milestone |+| version | Version | sets the version | version:v4.1.0 |+| start_date | Start date | sets the start date | start_date:2015-02-28 |+| due_date | Due date | sets the finish date | due:_date:2015-02-28 |+| estimated_hours | Estimated hours | sets the estimated hours. Use a number | estimated_hours:10.5 |+| remaining_hours | Remaining hours | sets the remaining hours. Use a number | remaining_hours:2.5 |+| status | Status | sets the status | status:closed |+| priority | Priority | sets the priority | priority:High |+| category | Category | sets the category from the project's categories | category:Testing |If you want to set a custom field just use the name as it is displayed in your browser, e.g. `Custom field:new value`diff --git a/lib_static/redmine/i18n.rb b/lib_static/redmine/i18n.rbindex 68a150f5871..a8e0e980deb 100644--- a/lib_static/redmine/i18n.rb+++ b/lib_static/redmine/i18n.rb@@ -245,7 +245,7 @@ module Redminegeneral_attributes = ::I18n.t("attributes", locale:)::I18n.t("activerecord.attributes",locale:).inject(general_attributes) do |attr_t, model_t|- attr_t.merge(model_t.last || {})+ attr_t.reverse_merge(model_t.last || {})endend@cached_attribute_translations[locale]diff --git a/spec/fixtures/mail_handler/wp_with_attribute_keys.eml b/spec/fixtures/mail_handler/wp_with_attribute_keys.emlnew file mode 100644index 00000000000..f58d843f670--- /dev/null+++ b/spec/fixtures/mail_handler/wp_with_attribute_keys.eml@@ -0,0 +1,31 @@+Return-Path: <[email protected]>+Received: from osiris ([127.0.0.1])+ by OSIRIS+ with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200+Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>+From: "John Smith" <[email protected]>+To: <[email protected]>+Subject: New ticket with full attributes+Date: Sun, 22 Jun 2008 12:28:07 +0200+MIME-Version: 1.0+Content-Type: text/plain; charset=utf-8+Content-Transfer-Encoding: 7bit+X-Priority: 3+X-MSMail-Priority: Normal+X-Mailer: Microsoft Outlook Express 6.00.2900.2869+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869++project: onlinestore+type: Feature request+status: Resolved+category: Stock management+version: alpha+priority: Urgent+assigned_to: [email protected]+responsible: [email protected]+start_date: 2025-01-01+due_date: 2025-12-31+estimated_hours: 20+remaining_hours: 10.5++Some description herediff --git a/spec/fixtures/mail_handler/wp_with_attributes_i18n_de.eml b/spec/fixtures/mail_handler/wp_with_attributes_i18n_de.emlnew file mode 100644index 00000000000..c97f948c037--- /dev/null+++ b/spec/fixtures/mail_handler/wp_with_attributes_i18n_de.eml@@ -0,0 +1,31 @@+Return-Path: <[email protected]>+Received: from osiris ([127.0.0.1])+ by OSIRIS+ with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200+Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>+From: "John Smith" <[email protected]>+To: <[email protected]>+Subject: Neues Arbeitspaket+Date: Sun, 22 Jun 2008 12:28:07 +0200+MIME-Version: 1.0+Content-Type: text/plain; charset=utf-8+Content-Transfer-Encoding: 7bit+X-Priority: 3+X-MSMail-Priority: Normal+X-Mailer: Microsoft Outlook Express 6.00.2900.2869+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869++Project: onlinestore+Typ: Feature request+Status: Resolved+Kategorie: Stock management+Version: alpha+Priorität: Urgent+Zugewiesen an: [email protected]+Verantwortlich: [email protected]+Anfangstermin: 2025-01-01+Endtermin: 2025-12-31+Aufwand: 20+Verbleibender Aufwand: 10.5++Beschreibung würde hier stehen.diff --git a/spec/models/mail_handler_spec.rb b/spec/models/mail_handler_spec.rbindex eb4b177667e..aa64bbe4882 100644--- a/spec/models/mail_handler_spec.rb+++ b/spec/models/mail_handler_spec.rb@@ -272,6 +272,9 @@ RSpec.describe MailHandler doshared_context "with a new work package with attributes with additional spaces" dolet(:permissions) { %i[add_work_packages assign_versions work_package_assigned] }+ let(:role) do+ create(:project_role, permissions:)+ endlet!(:user) docreate(:user,mail: "[email protected]",@@ -294,6 +297,21 @@ RSpec.describe MailHandler dolet!(:high_priority) docreate(:priority_high)end+ let!(:version) { create(:version, name: "alpha", project:) }+ let!(:original_status) do+ create(:default_status)+ end+ let!(:resolved_status) do+ create(:status,+ name: "Resolved") do |status|+ create(:workflow,+ old_status: original_status,+ new_status: status,+ role:,+ type: feature_type)+ end+ end+let(:submit_options) { {} }subject do@@ -1171,6 +1189,57 @@ RSpec.describe MailHandler do.to eql "This is a html-only email."endend++ context "for a wp with attribute keys" do+ include_context "with a new work package with attributes with additional spaces"+ it_behaves_like "work package created"++ subject do+ submit_email("wp_with_attribute_keys.eml", allow_override: ["category"])+ end++ it "sets the description" do+ expect(subject.description).to eq("Some description here")+ expect(subject.subject).to eq("New ticket with full attributes")+ expect(subject.type).to eq(feature_type)+ expect(subject.status).to eq(resolved_status)+ expect(subject.version).to eq(version)+ expect(subject.priority).to eq(urgent_priority)+ expect(subject.assigned_to).to eq(user)+ expect(subject.responsible).to eq(user)+ expect(subject.start_date).to eq(Date.parse("2025-01-01"))+ expect(subject.due_date).to eq(Date.parse("2025-12-31"))+ expect(subject.estimated_hours).to eq(20)+ expect(subject.remaining_hours).to eq(10.5)+ expect(subject.category).to eq(stock_category)+ end++ context "with the user having a german locale" do+ before do+ user.update!(language: "de")+ end++ subject do+ submit_email("wp_with_attributes_i18n_de.eml", allow_override: ["category"])+ end++ it "sets the description" do+ expect(subject.description).to eq("Beschreibung würde hier stehen.")+ expect(subject.subject).to eq("Neues Arbeitspaket")+ expect(subject.type).to eq(feature_type)+ expect(subject.status).to eq(resolved_status)+ expect(subject.version).to eq(version)+ expect(subject.priority).to eq(urgent_priority)+ expect(subject.assigned_to).to eq(user)+ expect(subject.responsible).to eq(user)+ expect(subject.start_date).to eq(Date.parse("2025-01-01"))+ expect(subject.due_date).to eq(Date.parse("2025-12-31"))+ expect(subject.estimated_hours).to eq(20)+ expect(subject.remaining_hours).to eq(10.5)+ expect(subject.category).to eq(stock_category)+ end+ end+ endendcontext "when sending a reply to work package mail" do