Commit 558db3ae authored by jplang's avatar jplang

Prevent parent issue from being closed if a child issue is open (#10989).

git-svn-id: https://svn.redmine.org/redmine/trunk@16108 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 0b52bb2e
......@@ -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
......
......@@ -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: الرجاء التحديد
......
......@@ -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:
......
......@@ -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: Изберете
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -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: Παρακαλώ επιλέξτε
......
......@@ -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
......
......@@ -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
......
......@@ -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.
......
......@@ -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.
......
......@@ -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"
......
......@@ -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
......
......@@ -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: گزینش کنید
......
......@@ -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ä
......
......@@ -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
......
......@@ -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
......
......@@ -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: בחר בבקשה
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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: 選んでください
......
......@@ -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: 선택하세요
......
......@@ -135,6 +135,7 @@ lt:
cant_link_an_issue_with_a_descendant: "Darbas negali būti susietas su viena savo darbo dalių"
earlier_than_minimum_start_date: "negali būti anksčiau %{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
......
......@@ -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
......
......@@ -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: Изберете
......
......@@ -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: Сонгоно уу
......
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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: Молим одаберите
......
......@@ -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} 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:
......
......@@ -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: กรุณาเลือก
......
......@@ -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
......
......@@ -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: Оберіть
......
......@@ -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:
......
......@@ -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.
......
......@@ -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: 请选择
......
......@@ -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
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment