From f3627e2a3d1a9fa606fc71f66776d4b879b92323 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 21 Dec 2016 09:09:22 +0000 Subject: [PATCH] Prevent parent issue from being closed if a child issue is open (#10989). git-svn-id: http://svn.redmine.org/redmine/trunk@16108 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 10 +++++++++- config/locales/ar.yml | 1 + config/locales/az.yml | 1 + config/locales/bg.yml | 1 + config/locales/bs.yml | 1 + config/locales/ca.yml | 1 + config/locales/cs.yml | 1 + config/locales/da.yml | 1 + config/locales/de.yml | 1 + config/locales/el.yml | 1 + config/locales/en-GB.yml | 1 + config/locales/en.yml | 1 + config/locales/es-PA.yml | 1 + config/locales/es.yml | 1 + config/locales/et.yml | 1 + config/locales/eu.yml | 1 + config/locales/fa.yml | 1 + config/locales/fi.yml | 1 + config/locales/fr.yml | 1 + config/locales/gl.yml | 1 + config/locales/he.yml | 1 + config/locales/hr.yml | 1 + config/locales/hu.yml | 1 + config/locales/id.yml | 1 + config/locales/it.yml | 1 + config/locales/ja.yml | 1 + config/locales/ko.yml | 1 + config/locales/lt.yml | 1 + config/locales/lv.yml | 1 + config/locales/mk.yml | 1 + config/locales/mn.yml | 1 + config/locales/nl.yml | 1 + config/locales/no.yml | 1 + config/locales/pl.yml | 1 + config/locales/pt-BR.yml | 1 + config/locales/pt.yml | 1 + config/locales/ro.yml | 1 + config/locales/ru.yml | 1 + config/locales/sk.yml | 1 + config/locales/sl.yml | 1 + config/locales/sq.yml | 1 + config/locales/sr-YU.yml | 1 + config/locales/sr.yml | 1 + config/locales/sv.yml | 1 + config/locales/th.yml | 1 + config/locales/tr.yml | 1 + config/locales/uk.yml | 1 + config/locales/vi.yml | 1 + config/locales/zh-TW.yml | 1 + config/locales/zh.yml | 1 + test/unit/issue_subtasking_test.rb | 9 +++++++++ test/unit/issue_test.rb | 18 ++++++++++++++++++ 52 files changed, 85 insertions(+), 1 deletion(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index b515c4a74..65d0784ad 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -723,6 +723,9 @@ class Issue < ActiveRecord::Base @parent_issue.self_and_ancestors.any? {|a| a.relations_from.any? {|r| r.relation_type == IssueRelation::TYPE_PRECEDES && r.issue_to.would_reschedule?(self)}} ) errors.add :parent_issue_id, :invalid + elsif !closed? && @parent_issue.closed? + # cannot attach an open issue to a closed parent + errors.add :base, :open_issue_with_closed_parent elsif !new_record? # moving an existing issue if move_possible?(@parent_issue) @@ -945,9 +948,14 @@ class Issue < ActiveRecord::Base end statuses = statuses.compact.uniq.sort - if blocked? + if blocked? || descendants.open.any? + # cannot close a blocked issue or a parent with open subtasks statuses.reject!(&:is_closed?) end + if ancestors.open(false).any? + # cannot reopen a subtask of a closed parent + statuses.select!(&:is_closed?) + end statuses end diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 6f7c2053e..82f3e6ffe 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -130,6 +130,7 @@ ar: cant_link_an_issue_with_a_descendant: "لا يمكن ان تكون المشكلة مرتبطة بواحدة من المهام الفرعية" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: الرجاء التحديد diff --git a/config/locales/az.yml b/config/locales/az.yml index 669674f84..b13053e27 100644 --- a/config/locales/az.yml +++ b/config/locales/az.yml @@ -198,6 +198,7 @@ az: cant_link_an_issue_with_a_descendant: "Tapşırıq özünün alt tapşırığı ilə əlaqəli ola bilməz" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" support: array: diff --git a/config/locales/bg.yml b/config/locales/bg.yml index f319ed34e..6066cefab 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -132,6 +132,7 @@ bg: cant_link_an_issue_with_a_descendant: "Една задача не може да бъде свързвана към своя подзадача" earlier_than_minimum_start_date: "не може да бъде по-рано от %{date} поради предхождащи задачи" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Изберете diff --git a/config/locales/bs.yml b/config/locales/bs.yml index 2af3df2a0..c310630d4 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -142,6 +142,7 @@ bs: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Molimo odaberite diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 527cf712c..9eec91870 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -135,6 +135,7 @@ ca: cant_link_an_issue_with_a_descendant: "Un assumpte no es pot enllaçar a una de les seves subtasques" earlier_than_minimum_start_date: "no pot ser anterior a %{date} derivat a les peticions precedents" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: "Seleccionar" diff --git a/config/locales/cs.yml b/config/locales/cs.yml index e4fc7d06a..54fbd9df5 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -136,6 +136,7 @@ cs: cant_link_an_issue_with_a_descendant: "Úkol nemůže být spojen s jedním z jeho dílčích úkolů" earlier_than_minimum_start_date: "nemůže být dříve než %{date} kvůli předřazeným úkolům" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Prosím vyberte diff --git a/config/locales/da.yml b/config/locales/da.yml index 114828fc8..2e81c086e 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -143,6 +143,7 @@ da: cant_link_an_issue_with_a_descendant: "En sag kan ikke relateres til en af dens underopgaver" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" template: header: diff --git a/config/locales/de.yml b/config/locales/de.yml index df27a2eaa..9529b80b4 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -147,6 +147,7 @@ de: cant_link_an_issue_with_a_descendant: "Ein Ticket kann nicht mit einer Ihrer Unteraufgaben verlinkt werden" earlier_than_minimum_start_date: "kann wegen eines Vorgängertickets nicht vor %{date} liegen" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Bitte auswählen diff --git a/config/locales/el.yml b/config/locales/el.yml index 5ea82dfa3..6e662f94c 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -132,6 +132,7 @@ el: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Παρακαλώ επιλέξτε diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 7be82bc74..d1f8ba1e5 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -135,6 +135,7 @@ en-GB: cant_link_an_issue_with_a_descendant: "An issue cannot be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Please select diff --git a/config/locales/en.yml b/config/locales/en.yml index d5a854f19..89fdc8863 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -131,6 +131,7 @@ en: cant_link_an_issue_with_a_descendant: "An issue cannot be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Please select diff --git a/config/locales/es-PA.yml b/config/locales/es-PA.yml index e343621d5..7be3ca084 100644 --- a/config/locales/es-PA.yml +++ b/config/locales/es-PA.yml @@ -141,6 +141,7 @@ es-PA: cant_link_an_issue_with_a_descendant: "Esta incidencia no puede ser ligada a una de estas tareas" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" # Append your own errors here or at the model/attributes scope. diff --git a/config/locales/es.yml b/config/locales/es.yml index b3e4e1a40..90f4f2df7 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -139,6 +139,7 @@ es: cant_link_an_issue_with_a_descendant: "Esta petición no puede ser ligada a una de estas tareas" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" # Append your own errors here or at the model/attributes scope. diff --git a/config/locales/et.yml b/config/locales/et.yml index 2866eb635..525a6119b 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -148,6 +148,7 @@ et: cant_link_an_issue_with_a_descendant: "Teemat ei saa sidustada tema enda alamteemaga" earlier_than_minimum_start_date: "Tähtpäev ei saa olla varasem kui %{date} eelnevate teemade tähtpäevade tõttu" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: "Palun vali" diff --git a/config/locales/eu.yml b/config/locales/eu.yml index a763d62da..3142bafcd 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -133,6 +133,7 @@ eu: cant_link_an_issue_with_a_descendant: "Zeregin bat ezin da bere azpiataza batekin estekatu." earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Hautatu mesedez diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 442f98987..5226f2d35 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -131,6 +131,7 @@ fa: cant_link_an_issue_with_a_descendant: "یک مورد نمی‌تواند به یکی از زیر کارهایش پیوند بخورد" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: گزینش کنید diff --git a/config/locales/fi.yml b/config/locales/fi.yml index f193a67f7..16575e09e 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -156,6 +156,7 @@ fi: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Valitse, ole hyvä diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 757aa5b48..e23ab86da 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -151,6 +151,7 @@ fr: cant_link_an_issue_with_a_descendant: "Une demande ne peut pas être liée à l'une de ses sous-tâches" earlier_than_minimum_start_date: "ne peut pas être antérieure au %{date} à cause des demandes qui précèdent" not_a_regexp: "n'est pas une expression regulière valide" + open_issue_with_closed_parent: "Une demande ouverte ne peut pas être rattachée à une demande fermée" actionview_instancetag_blank_option: Choisir diff --git a/config/locales/gl.yml b/config/locales/gl.yml index ab0f4e488..de29a5fac 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -160,6 +160,7 @@ gl: cant_link_an_issue_with_a_descendant: "As peticións non poden estar ligadas coas súas subtarefas" earlier_than_minimum_start_date: "Non pode ser antes de %{date} por mor de peticións anteriores" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Por favor seleccione diff --git a/config/locales/he.yml b/config/locales/he.yml index b6ce6bb28..241b5f8f8 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -136,6 +136,7 @@ he: cant_link_an_issue_with_a_descendant: "לא ניתן לקשר נושא לתת־משימה שלו" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: בחר בבקשה diff --git a/config/locales/hr.yml b/config/locales/hr.yml index d81d995b3..6441b18c6 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -126,6 +126,7 @@ hr: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Molimo odaberite diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 2f08d4b4a..bb77d3a35 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -152,6 +152,7 @@ cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Kérem válasszon diff --git a/config/locales/id.yml b/config/locales/id.yml index a9b38916a..b14d7cdff 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -131,6 +131,7 @@ id: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Silakan pilih diff --git a/config/locales/it.yml b/config/locales/it.yml index ff4780bf3..923cd665a 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -136,6 +136,7 @@ it: cant_link_an_issue_with_a_descendant: "Una segnalazione non può essere collegata a una delle sue discendenti" earlier_than_minimum_start_date: "non può essere precedente a %{date} a causa di una precedente segnalazione" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Scegli diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 96f607bfc..279fbdd0f 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -152,6 +152,7 @@ ja: cant_link_an_issue_with_a_descendant: "親子関係にあるチケット間での関連の設定はできません" earlier_than_minimum_start_date: "を%{date}より前にすることはできません。先行するチケットがあります" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: 選んでください diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 0852d6d71..068bab9cd 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -178,6 +178,7 @@ ko: cant_link_an_issue_with_a_descendant: "일감은 하위 일감과 연결할 수 없습니다." earlier_than_minimum_start_date: "시작날짜 %{date}보다 앞선 시간으로 설정할 수 없습니다." not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: 선택하세요 diff --git a/config/locales/lt.yml b/config/locales/lt.yml index ea47e8e0f..0bd0c0bee 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -135,6 +135,7 @@ lt: cant_link_an_issue_with_a_descendant: "Darbas negali būti susietas su viena iš savo darbo dalių" earlier_than_minimum_start_date: "negali būti anksčiau už %{date} dėl ankstesnių darbų" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Prašom parinkti diff --git a/config/locales/lv.yml b/config/locales/lv.yml index d9d791bc5..3ef7047ff 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -125,6 +125,7 @@ lv: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Izvēlieties diff --git a/config/locales/mk.yml b/config/locales/mk.yml index a196680a1..3202236f9 100644 --- a/config/locales/mk.yml +++ b/config/locales/mk.yml @@ -132,6 +132,7 @@ mk: cant_link_an_issue_with_a_descendant: "Задача неможе да се поврзе со една од нејзините подзадачи" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Изберете diff --git a/config/locales/mn.yml b/config/locales/mn.yml index f9bce484f..b09244854 100644 --- a/config/locales/mn.yml +++ b/config/locales/mn.yml @@ -131,6 +131,7 @@ mn: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Сонгоно уу diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 5d36166b7..f3b0b9259 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -129,6 +129,7 @@ nl: cant_link_an_issue_with_a_descendant: "Een issue kan niet gelinked worden met een subtask" earlier_than_minimum_start_date: "kan niet eerder zijn dan %{date} wegens voorafgaande issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Selecteren diff --git a/config/locales/no.yml b/config/locales/no.yml index dfab229d8..1c8ba3b1a 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -120,6 +120,7 @@ cant_link_an_issue_with_a_descendant: "En sak kan ikke kobles mot en av sine undersaker" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Vennligst velg diff --git a/config/locales/pl.yml b/config/locales/pl.yml index a1a595e20..9e5ec9573 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -139,6 +139,7 @@ pl: cant_link_an_issue_with_a_descendant: "Zagadnienie nie może zostać powiązane z jednym z własnych podzagadnień" earlier_than_minimum_start_date: "nie może być wcześniej niż %{date} z powodu poprzedających zagadnień" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" support: array: diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 640d6e15a..e0524b8e1 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -151,6 +151,7 @@ pt-BR: cant_link_an_issue_with_a_descendant: "Uma tarefa não pode ser relaciona a uma de suas subtarefas" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Selecione diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 71f809c0a..e7da736e2 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -140,6 +140,7 @@ pt: cant_link_an_issue_with_a_descendant: "Não é possível ligar uma tarefa a uma sub-tarefa que lhe é pertencente" earlier_than_minimum_start_date: "não pode ser antes de %{date} devido a tarefas precedentes" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Selecione diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 36bd8dd55..1378762a0 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -126,6 +126,7 @@ ro: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Selectați diff --git a/config/locales/ru.yml b/config/locales/ru.yml index cbf591bdc..1a54014b3 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -208,6 +208,7 @@ ru: cant_link_an_issue_with_a_descendant: "Задача не может быть связана со своей подзадачей" earlier_than_minimum_start_date: "не может быть раньше %{date} из-за предыдущих задач" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" support: array: diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 770dac2a2..c0ac4ae58 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -130,6 +130,7 @@ sk: cant_link_an_issue_with_a_descendant: "Nemožno prepojiť úlohu s niektorou z podúloh" earlier_than_minimum_start_date: "nemôže byť skorší ako %{date} z dôvodu nadväznosti na predchádzajúce úlohy" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Vyberte diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 33b4a3dd3..4b9859967 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -130,6 +130,7 @@ sl: cant_link_an_issue_with_a_descendant: "Zahtevek ne more biti povezan s svojo podnalogo" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Prosimo izberite diff --git a/config/locales/sq.yml b/config/locales/sq.yml index ece8e293d..127a6d107 100644 --- a/config/locales/sq.yml +++ b/config/locales/sq.yml @@ -131,6 +131,7 @@ sq: cant_link_an_issue_with_a_descendant: "Nje ceshtje nuk mund te lidhet me nenceshtje" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Zgjidhni diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml index a4bef20d7..1e3a0d4c5 100644 --- a/config/locales/sr-YU.yml +++ b/config/locales/sr-YU.yml @@ -134,6 +134,7 @@ sr-YU: cant_link_an_issue_with_a_descendant: "Problem ne može biti povezan sa jednim od svojih podzadataka" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Molim odaberite diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 9ebe19144..e4140d5ee 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -132,6 +132,7 @@ sr: cant_link_an_issue_with_a_descendant: "Проблем не може бити повезан са једним од својих подзадатака" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Молим одаберите diff --git a/config/locales/sv.yml b/config/locales/sv.yml index b472e2d97..b4280641d 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -136,6 +136,7 @@ sv: cant_link_an_issue_with_a_descendant: "Ett ärende kan inte länkas till ett av dess underärenden" earlier_than_minimum_start_date: "kan inte vara tidigare än% {datum} på grund av föregående ärenden" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" direction: ltr date: diff --git a/config/locales/th.yml b/config/locales/th.yml index bf1d5837d..98d0233db 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -129,6 +129,7 @@ th: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: กรุณาเลือก diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 43b8b642d..2d7ce1b98 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -145,6 +145,7 @@ tr: cant_link_an_issue_with_a_descendant: "Bir iş, alt işlerinden birine bağlanamaz" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" models: actionview_instancetag_blank_option: Lütfen Seçin diff --git a/config/locales/uk.yml b/config/locales/uk.yml index dc19b8993..8d342afd0 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -129,6 +129,7 @@ uk: cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: Оберіть diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 9161940e7..94e1a1a5c 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -146,6 +146,7 @@ vi: cant_link_an_issue_with_a_descendant: "Một vấn đề không thể liên kết tới một trong số những tác vụ con của nó" earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" direction: ltr date: diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index ccaed9f65..09b4d2f6b 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -188,6 +188,7 @@ cant_link_an_issue_with_a_descendant: "議題無法被連結至自己的子任務" earlier_than_minimum_start_date: "不能早於 %{date} 因為有前置議題" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" # You can define own errors for models or model attributes. # The values :model, :attribute and :value are always available for interpolation. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index fefc55f8b..9334743d6 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -135,6 +135,7 @@ zh: cant_link_an_issue_with_a_descendant: "问题不能关联到它的子任务" earlier_than_minimum_start_date: "不能早于 %{date} 由于有前置问题" not_a_regexp: "is not a valid regular expression" + open_issue_with_closed_parent: "An open issue cannot be attached to a closed parent task" actionview_instancetag_blank_option: 请选择 diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb index e878601b1..2ddfb49c6 100644 --- a/test/unit/issue_subtasking_test.rb +++ b/test/unit/issue_subtasking_test.rb @@ -330,4 +330,13 @@ class IssueSubtaskingTest < ActiveSupport::TestCase parent.generate_child!(:estimated_hours => 7) assert_equal 12, parent.reload.total_estimated_hours end + + def test_open_issue_with_closed_parent_should_not_validate + parent = Issue.generate!(:status_id => 5) + child = Issue.generate! + + child.parent_issue_id = parent.id + assert !child.save + assert_include I18n.t("activerecord.errors.messages.open_issue_with_closed_parent"), child.errors.full_messages + end end diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 844ed5934..235e2e7f7 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -1941,6 +1941,24 @@ class IssueTest < ActiveSupport::TestCase assert !closed_statuses.empty? end + def test_parent_issues_with_open_subtask_dont_allow_closed_statuses + parent = Issue.generate! + child = Issue.generate!(:parent_issue_id => parent.id) + + allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002)) + assert allowed_statuses.any? + assert_equal [], allowed_statuses.select(&:is_closed?) + end + + def test_parent_issues_with_closed_subtask_allow_closed_statuses + parent = Issue.generate! + child = Issue.generate!(:parent_issue_id => parent.id, :status_id => 5) + + allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002)) + assert allowed_statuses.any? + assert allowed_statuses.select(&:is_closed?).any? + end + def test_reschedule_an_issue_without_dates with_settings :non_working_week_days => [] do issue = Issue.new(:start_date => nil, :due_date => nil) -- 2.39.5