From d56e7022dd036db8b2ac82273bec8e90e3ef0b09 Mon Sep 17 00:00:00 2001 From: redacted Date: Wed, 20 Oct 2021 12:42:09 +0200 Subject: =?UTF-8?q?Add=20partial=5Fderived=20option=20for=20issue=20dates?= =?UTF-8?q?=0AThis=20implements=20the=20suggestions=20from=20feature=20#34?= =?UTF-8?q?609.=0AWith=20this=20parent=20issues=20can=20have=20start=20dat?= =?UTF-8?q?es=20earlier=20than=20child=20issue=0Aand=20due=20dates=20later?= =?UTF-8?q?=20than=20child=20issues=20but=20not=20the=20other=20way=20arou?= =?UTF-8?q?nd.?= --- app/helpers/settings_helper.rb | 1 + app/models/issue.rb | 21 +++++++++++++++++++++ config/locales/de.yml | 3 +++ config/locales/en-GB.yml | 3 +++ config/locales/en.yml | 3 +++ 5 files changed, 31 insertions(+) diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index c3b8e7a25..abf4ae0fc 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -185,6 +185,7 @@ module SettingsHelper def parent_issue_dates_options options = [ [:label_parent_task_attributes_derived, 'derived'], + [:label_parent_task_attributes_partially_derived, 'partially_derived'], [:label_parent_task_attributes_independent, 'independent'] ] diff --git a/app/models/issue.rb b/app/models/issue.rb index 55962f0fe..733158efb 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -745,6 +745,14 @@ class Issue < ActiveRecord::Base errors.add :due_date, :greater_than_start_date end + if dates_partially_derived? && start_date && start_date_changed? && start_date > children.minimum(:start_date) + errors.add :start_date, :later_than_minimum_start_date, :date => format_date(children.minimum(:start_date)) + end + + if dates_partially_derived? && due_date && due_date_changed? && due_date < children.maximum(:due_date) + errors.add :due_date, :earlier_than_maximum_due_date, :date => format_date(children.maximum(:due_date)) + end + if start_date && start_date_changed? && soonest_start && start_date < soonest_start errors.add :start_date, :earlier_than_minimum_start_date, :date => format_date(soonest_start) end @@ -1412,6 +1420,10 @@ class Issue < ActiveRecord::Base !leaf? && Setting.parent_issue_dates == 'derived' end + def dates_partially_derived? + !leaf? && Setting.parent_issue_dates == 'partially_derived' + end + def priority_derived? !leaf? && Setting.parent_issue_priority == 'derived' end @@ -1829,6 +1841,15 @@ class Issue < ActiveRecord::Base end end + if p.dates_partially_derived? + # start/due dates = lowest/highest dates of children or own date + p.start_date = [p.children.minimum(:start_date), p.start_date].compact.min + p.due_date = [p.children.maximum(:due_date),p.due_date].compact.max + if p.start_date && p.due_date && p.due_date < p.start_date + p.start_date, p.due_date = p.due_date, p.start_date + end + end + if p.done_ratio_derived? # done ratio = average ratio of children weighted with their total estimated hours unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio diff --git a/config/locales/de.yml b/config/locales/de.yml index 1bb53c4d0..da933c255 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -146,6 +146,8 @@ de: circular_dependency: "Diese Beziehung würde eine zyklische Abhängigkeit erzeugen" cant_link_an_issue_with_a_descendant: "Ein Ticket kann nicht mit einem seiner untergeordneten Tickets verlinkt werden" earlier_than_minimum_start_date: "kann wegen eines Vorgängertickets nicht vor %{date} liegen" + later_than_minimum_start_date: "kann wegen eines Untertickets nicht nach %{date} liegen" + earlier_than_maximum_due_date: "kann wegen eines Untertickets nicht vor %{date} liegen" not_a_regexp: "ist kein gültiger regulärer Ausdruck" open_issue_with_closed_parent: "Ein offenes Ticket kann nicht an ein geschlossenes übergeordnetes Ticket angehängt werden" must_contain_uppercase: "muss Großbuchstaben (A-Z) enthalten" @@ -1173,6 +1175,7 @@ de: field_remote_ip: IP-Adresse label_parent_task_attributes: Eigenschaften übergeordneter Tickets label_parent_task_attributes_derived: Abgeleitet von untergeordneten Tickets + label_parent_task_attributes_partially_derived: Teilweise abgeleitet von untergeordneten Tickets label_parent_task_attributes_independent: Unabhängig von untergeordneten Tickets label_time_entries_visibility_all: Alle Zeitaufwände label_time_entries_visibility_own: Nur eigene Aufwände diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 453e86fa7..e170c8cdb 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -134,6 +134,8 @@ en-GB: circular_dependency: "This relation would create a circular dependency" 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" + later_than_minimum_start_date: "cannot be later than %{date} because of child issues" + earlier_than_maximum_due_date: "cannot be earlier than %{date} because of child 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" must_contain_uppercase: "must contain uppercase letters (A-Z)" @@ -1132,6 +1134,7 @@ en-GB: field_time_entries_visibility: Time logs visibility setting_password_max_age: Require password change after label_parent_task_attributes: Parent tasks attributes + label_parent_task_attributes_partially_derived: Partially calculated from subtasks label_parent_task_attributes_derived: Calculated from subtasks label_parent_task_attributes_independent: Independent of subtasks label_time_entries_visibility_all: All time entries diff --git a/config/locales/en.yml b/config/locales/en.yml index 8fd84ff13..61feec4aa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -130,6 +130,8 @@ en: circular_dependency: "This relation would create a circular dependency" 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" + earlier_than_maximum_due_date: "cannot be earlier than %{date} because of child issues" + later_than_minimum_start_date: "cannot be later than %{date} because of child 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" must_contain_uppercase: "must contain uppercase letters (A-Z)" @@ -1064,6 +1066,7 @@ en: label_blank_value: blank label_parent_task_attributes: Parent tasks attributes label_parent_task_attributes_derived: Calculated from subtasks + label_parent_task_attributes_partially_derived: Partially calculated from subtasks label_parent_task_attributes_independent: Independent of subtasks label_time_entries_visibility_all: All time entries label_time_entries_visibility_own: Time entries created by the user -- 2.30.2 From bf96dfa31a9ccea6b194bd48c1ef79548ce3e957 Mon Sep 17 00:00:00 2001 From: redacted Date: Thu, 21 Oct 2021 15:45:34 +0200 Subject: =?UTF-8?q?Add=20partial=5Fderived=20option=20for=20issue=20done?= =?UTF-8?q?=5Fratio=20and=20priority=0AThis=20implements=20the=20second=20?= =?UTF-8?q?suggestion=20from=20feature=20#34609.=0AWith=20this=20parent=20?= =?UTF-8?q?issues=20can=20have=20priorities=20higher=20than=20child=20issu?= =?UTF-8?q?es=0Aand=20done=5Fratios=20lower=20than=20child=20issues=20but?= =?UTF-8?q?=20not=20the=20other=20way=20around.?= --- app/helpers/settings_helper.rb | 2 + app/models/issue.rb | 70 +++++++++++++++++++++++++++++++--- config/locales/de.yml | 2 + config/locales/en-GB.yml | 2 + config/locales/en.yml | 2 + 5 files changed, 72 insertions(+), 6 deletions(-) diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index abf4ae0fc..04e357840 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -195,6 +195,7 @@ module SettingsHelper def parent_issue_priority_options options = [ [:label_parent_task_attributes_derived, 'derived'], + [:label_parent_task_attributes_partially_derived, 'partially_derived'], [:label_parent_task_attributes_independent, 'independent'] ] @@ -204,6 +205,7 @@ module SettingsHelper def parent_issue_done_ratio_options options = [ [:label_parent_task_attributes_derived, 'derived'], + [:label_parent_task_attributes_partially_derived, 'partially_derived'], [:label_parent_task_attributes_independent, 'independent'] ] diff --git a/app/models/issue.rb b/app/models/issue.rb index 733158efb..de1cdb011 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -765,6 +765,44 @@ class Issue < ActiveRecord::Base end end + if priority_partially_derived? && priority_id && priority_id_changed? + #Get derived priority from children and reject if own priority is lower + children_priority_position = children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position") + own_priority_position = IssuePriority.find_by_id(priority_id).position + if children_priority_position && children_priority_position > own_priority_position + own_priority_name = IssuePriority.find_by_position(own_priority_position).name + children_priority_name = IssuePriority.find_by_position(children_priority_position) + errors.add :priority, :priority_lower_than_children, :own_priority => own_priority_name, :priority => children_priority_name + end + end + + if done_ratio_partially_derived? && done_ratio && done_ratio_changed? + #get derived done_ratio from children and reject if own done_ratio is higher + children_done_ratio = 100 #set comparison to max in case we can't determine a child done ratio below. + chld=children.to_a + if chld.any? + chld_with_total_estimated_hours = chld.select {|c| c.total_estimated_hours.to_f > 0.0} + if chld_with_total_estimated_hours.any? + average= chld_with_total_estimated_hours.sum(&:total_estimated_hours).to_d / chld_with_total_estimated_hours.count + else + average = 1.0.to_d + end + done = children.sum do |c| + estimated = (c.total_estimated_hours || 0.0).to_d + estimated = average unless estimated > 0.0 + ratio = c.closed? ? 100 : (c.done_ratio || 0) + estimated * ratio + end + progress = done / (average * chld.count) + children_done_ratio = progress.floor + end + + own_done_ratio = done_ratio + if children_done_ratio && children_done_ratio < own_done_ratio + errors.add :done_ratio, :done_ratio_higher_than_children, :done_ratio => children_done_ratio + end + end + # Checks that the issue can not be added/moved to a disabled tracker if project && (tracker_id_changed? || project_id_changed?) if tracker && !project.trackers.include?(tracker) @@ -1428,10 +1466,18 @@ class Issue < ActiveRecord::Base !leaf? && Setting.parent_issue_priority == 'derived' end + def priority_partially_derived? + !leaf? && Setting.parent_issue_priority == 'partially_derived' + end + def done_ratio_derived? !leaf? && Setting.parent_issue_done_ratio == 'derived' end + def done_ratio_partially_derived? + !leaf? && Setting.parent_issue_done_ratio == 'partially_derived' + end + def <=>(issue) if issue.nil? -1 @@ -1821,12 +1867,18 @@ class Issue < ActiveRecord::Base def recalculate_attributes_for(issue_id) if issue_id && p = Issue.find_by_id(issue_id) - if p.priority_derived? - # priority = highest priority of open children + if p.priority_derived? || p.priority_partially_derived? + # priority = highest priority of open children (or higher if partially derived) # priority is left unchanged if all children are closed and there's no default priority defined if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position") - p.priority = IssuePriority.find_by_position(priority_position) + if p.priority_partially_derived? + #like priority_derived, but priority can be higher than highest childs priority + #TODO: use priority derived or set whichever is higher + p.priority = IssuePriority.find_by_position(priority_position) + else + p.priority = IssuePriority.find_by_position(priority_position) + end elsif default_priority = IssuePriority.default p.priority = default_priority end @@ -1850,8 +1902,8 @@ class Issue < ActiveRecord::Base end end - if p.done_ratio_derived? - # done ratio = average ratio of children weighted with their total estimated hours + if p.done_ratio_derived? || p.done_ratio_partially_derived? + # done ratio = average ratio of children weighted with their total estimated hours (or lower if partially derived) unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio children = p.children.to_a if children.any? @@ -1870,7 +1922,13 @@ class Issue < ActiveRecord::Base estimated * ratio end progress = done / (average * children.count) - p.done_ratio = progress.floor + if done_ratio_partially_derived? + #done ratio like done_ratio_derived, but parent done ratio can be lower than calculated done ratio + #TODO: use done_ratio derived or set, whichever is lower + p.done_ratio = [progress.floor, p.done_ratio].compact.min + else + p.done_ratio = progress.floor + end end end end diff --git a/config/locales/de.yml b/config/locales/de.yml index 9b488045d..9b86231d5 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -148,6 +148,8 @@ de: earlier_than_minimum_start_date: "kann wegen eines Vorgängertickets nicht vor %{date} liegen" later_than_minimum_start_date: "kann wegen eines Untertickets nicht nach %{date} liegen" earlier_than_maximum_due_date: "kann wegen eines Untertickets nicht vor %{date} liegen" + priority_lower_than_children: "(%{own_priority}) kann nicht niedriger sein als die höchste Priorität eines Untertickets (%{priority})" + done_ratio_higher_than_children: "kann nicht höher sein, als der Ticketfortschritt der Untertickets (%{done_ratio})" not_a_regexp: "ist kein gültiger regulärer Ausdruck" open_issue_with_closed_parent: "Ein offenes Ticket kann nicht an ein geschlossenes übergeordnetes Ticket angehängt werden" must_contain_uppercase: "muss Großbuchstaben (A-Z) enthalten" diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index bb211fc8e..5bdb2ae16 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -136,6 +136,8 @@ en-GB: earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" later_than_minimum_start_date: "cannot be later than %{date} because of child issues" earlier_than_maximum_due_date: "cannot be earlier than %{date} because of child issues" + priority_lower_than_children: "(%{own_priority}) cannot be lower than maximum priority derived from children (%{priority})" + done_ratio_higher_than_children: "cannot be higher than done ratio derived from children (%{done_ratio})" 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" must_contain_uppercase: "must contain uppercase letters (A-Z)" diff --git a/config/locales/en.yml b/config/locales/en.yml index 0e0c9255d..4c2ed945a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -132,6 +132,8 @@ en: earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues" earlier_than_maximum_due_date: "cannot be earlier than %{date} because of child issues" later_than_minimum_start_date: "cannot be later than %{date} because of child issues" + priority_lower_than_children: "(%{own_priority}) cannot be lower than maximum priority derived from children (%{priority})" + done_ratio_higher_than_children: "cannot be higher than done ratio derived from children (%{done_ratio})" 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" must_contain_uppercase: "must contain uppercase letters (A-Z)" -- 2.30.2 From 46379e34628a9be0a45b5ae46c7e083c77848fb3 Mon Sep 17 00:00:00 2001 From: redacted Date: Thu, 21 Oct 2021 15:54:48 +0200 Subject: Fix priority update for partially derived case --- app/models/issue.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index de1cdb011..5b1fc9622 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1875,7 +1875,7 @@ class Issue < ActiveRecord::Base if p.priority_partially_derived? #like priority_derived, but priority can be higher than highest childs priority #TODO: use priority derived or set whichever is higher - p.priority = IssuePriority.find_by_position(priority_position) + p.priority = IssuePriority.find_by_position([p.priority.position, priority_position].compact.max) else p.priority = IssuePriority.find_by_position(priority_position) end -- 2.30.2 From 205b307ebbfd67f73af9eec7bc07ba14fb0241db Mon Sep 17 00:00:00 2001 From: redacted Date: Thu, 21 Oct 2021 18:46:40 +0200 Subject: fix missing reschedule in partially derived issue dates --- app/models/issue.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index 5b1fc9622..05e56dbca 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1399,7 +1399,7 @@ class Issue < ActiveRecord::Base relations_to.reload if reload dates = relations_to.collect{|relation| relation.successor_soonest_start} p = @parent_issue || parent - if p && Setting.parent_issue_dates == 'derived' + if p && (Setting.parent_issue_dates == 'derived' || Setting.parent_issue_dates == 'partially_derived') dates << p.soonest_start end @soonest_start = dates.compact.max @@ -1417,11 +1417,10 @@ class Issue < ActiveRecord::Base end # Reschedules the issue on the given date or the next working day and saves the record. - # If the issue is a parent task, this is done by rescheduling its subtasks. + # If the issue is a parent task, this is done by rescheduling its subtasks if derived. def reschedule_on!(date, journal=nil) return if date.nil? - - if leaf? || !dates_derived? + if leaf? || !(dates_derived? || dates_partially_derived?) if start_date.nil? || start_date != date if start_date && start_date > date # Issue can not be moved earlier than its soonest start date @@ -1451,6 +1450,18 @@ class Issue < ActiveRecord::Base leaf.reschedule_on!(date) end end + # if we are partially_derived and have moved the children, we also should move the parent + # we can not do this before, as the parent can not moved as long as the children are still sitting there + if dates_partially_derived? && start_date < date + reschedule_on(date) + begin + save + rescue ActiveRecord::StaleObjectError + reload + reschedule_on(date) + save + end + end end end -- 2.30.2 From 5f64c3388959568a95cba8e98612abfdebaf3846 Mon Sep 17 00:00:00 2001 From: redacted Date: Thu, 21 Oct 2021 21:20:31 +0200 Subject: =?UTF-8?q?Update=20locales=20for=20partial=20derived=20dates=0Aby?= =?UTF-8?q?=20running=20rake=20locales:update?= --- 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/el.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 + 46 files changed, 46 insertions(+) diff --git a/config/locales/ar.yml b/config/locales/ar.yml index f1ec0a857..2e5a1587a 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1440,3 +1440,4 @@ ar: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/az.yml b/config/locales/az.yml index 3f8e93ccd..17bf676ce 100644 --- a/config/locales/az.yml +++ b/config/locales/az.yml @@ -1532,3 +1532,4 @@ az: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/bg.yml b/config/locales/bg.yml index e6817cbfc..4eb9469dd 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -1396,3 +1396,4 @@ bg: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/bs.yml b/config/locales/bs.yml index c714b06c2..5f0759404 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -1453,3 +1453,4 @@ bs: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 6fefeb2e9..43e900d8b 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1430,3 +1430,4 @@ ca: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 6e80b45b6..782c87ec9 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -1428,3 +1428,4 @@ cs: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/da.yml b/config/locales/da.yml index baefb1341..426d416ce 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1457,3 +1457,4 @@ da: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/el.yml b/config/locales/el.yml index 7f09c58b9..28f4bedcb 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -1440,3 +1440,4 @@ el: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/es-PA.yml b/config/locales/es-PA.yml index 787b5fb55..cf0895a13 100644 --- a/config/locales/es-PA.yml +++ b/config/locales/es-PA.yml @@ -1470,3 +1470,4 @@ es-PA: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/es.yml b/config/locales/es.yml index be0209252..9d8bffa9d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1507,3 +1507,4 @@ es: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/et.yml b/config/locales/et.yml index 660b7c34f..7db3d3daa 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -1445,3 +1445,4 @@ et: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/eu.yml b/config/locales/eu.yml index 39f71e69e..50237a1f2 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -1441,3 +1441,4 @@ eu: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 587a3b5b1..d8a0a59af 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -1414,3 +1414,4 @@ fa: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 4ccb3c6fc..3672f82f2 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1461,3 +1461,4 @@ fi: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/fr.yml b/config/locales/fr.yml index bc88cce70..7902fceee 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1421,3 +1421,4 @@ fr: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 387037771..6f9114891 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1447,3 +1447,4 @@ gl: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/he.yml b/config/locales/he.yml index 6aefcaa82..6c5d13c60 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -1445,3 +1445,4 @@ he: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/hr.yml b/config/locales/hr.yml index 040e13712..7fff3c1f8 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -1437,3 +1437,4 @@ hr: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 8f5c1ac15..ba4a3fcbe 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -1459,3 +1459,4 @@ text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/id.yml b/config/locales/id.yml index f32d77687..866cdc512 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -1442,3 +1442,4 @@ id: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/it.yml b/config/locales/it.yml index c665df514..ff3765d29 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1433,3 +1433,4 @@ it: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 4104adea2..4b664ceb5 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1404,3 +1404,4 @@ ja: text_all_migrations_have_been_run: すべてのデータベースマイグレーションが実行済 text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 39c632e36..58203be81 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -1478,3 +1478,4 @@ ko: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/lt.yml b/config/locales/lt.yml index d9c8e7e31..da4dc305d 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -1407,3 +1407,4 @@ lt: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/lv.yml b/config/locales/lv.yml index 9fda12506..c3a6cc299 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -1434,3 +1434,4 @@ lv: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/mk.yml b/config/locales/mk.yml index dee16263c..170441fbc 100644 --- a/config/locales/mk.yml +++ b/config/locales/mk.yml @@ -1440,3 +1440,4 @@ mk: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/mn.yml b/config/locales/mn.yml index c0fdcaaba..84492f362 100644 --- a/config/locales/mn.yml +++ b/config/locales/mn.yml @@ -1440,3 +1440,4 @@ mn: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 59513aeb9..41adea536 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1415,3 +1415,4 @@ nl: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/no.yml b/config/locales/no.yml index 5e4a69d7a..9a3c12a9f 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -1430,3 +1430,4 @@ text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/pl.yml b/config/locales/pl.yml index e5e5040eb..cc6b8f532 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1453,3 +1453,4 @@ pl: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index db6610af6..dcd406b7f 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1445,3 +1445,4 @@ pt-BR: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 1dd6b5c50..88d5cdd68 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -1433,3 +1433,4 @@ pt: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/ro.yml b/config/locales/ro.yml index ff6f31168..e9af35d62 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -1435,3 +1435,4 @@ ro: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 0cc3ecb5d..0caa4d97a 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1513,3 +1513,4 @@ ru: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/sk.yml b/config/locales/sk.yml index af56ae3d1..71e89607d 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -1429,3 +1429,4 @@ sk: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 463d76541..5bf92ff5e 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -1440,3 +1440,4 @@ sl: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/sq.yml b/config/locales/sq.yml index eb2cf1987..2d418024c 100644 --- a/config/locales/sq.yml +++ b/config/locales/sq.yml @@ -1436,3 +1436,4 @@ sq: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml index 71b452035..907050489 100644 --- a/config/locales/sr-YU.yml +++ b/config/locales/sr-YU.yml @@ -1442,3 +1442,4 @@ sr-YU: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 72d23aacc..092e10ff2 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -1441,3 +1441,4 @@ sr: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/sv.yml b/config/locales/sv.yml index c5b67999c..00a4fcbee 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1473,3 +1473,4 @@ sv: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/th.yml b/config/locales/th.yml index b0e253b5e..574bc367c 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -1436,3 +1436,4 @@ th: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 8d39a8780..0a84d7882 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1447,3 +1447,4 @@ tr: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 015df400b..fa114ec2a 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1428,3 +1428,4 @@ uk: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 490505021..927176f65 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1492,3 +1492,4 @@ vi: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 4769dad41..8a345c5b0 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -1465,3 +1465,4 @@ text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7299ec620..b1037855d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1395,3 +1395,4 @@ zh: text_setting_config_change: You can configure the behaviour in config/configuration.yml. Please restart the application after editing it. label_bulk_edit: Bulk edit + label_parent_task_attributes_partially_derived: Partially calculated from subtasks -- 2.30.2 From 3c4fe7f27100b25b8f03f550290ebef9c9ad9696 Mon Sep 17 00:00:00 2001 From: redacted Date: Tue, 2 Nov 2021 17:54:34 +0100 Subject: Add tests for partially derived dates --- test/unit/issue_subtasking_test.rb | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb index 04f8aa301..2c31bc564 100644 --- a/test/unit/issue_subtasking_test.rb +++ b/test/unit/issue_subtasking_test.rb @@ -61,6 +61,32 @@ class IssueSubtaskingTest < ActiveSupport::TestCase end end +##new + def test_parent_dates_should_be_lowest_start_and_highest_due_dates_with_parent_issue_dates_set_to_partially_derived_if_child_dates_outside_parent_range + with_settings :parent_issue_dates => 'partially_derived' do + parent = Issue.generate!(:start_date => '2010-05-01', :due_date => '2010-05-20') + parent.generate_child!(:start_date => '2010-01-25', :due_date => '2010-02-15') + parent.generate_child!( :due_date => '2010-02-13') + parent.generate_child!(:start_date => '2010-02-01', :due_date => '2010-10-22') + parent.reload + assert_equal Date.parse('2010-01-25'), parent.start_date + assert_equal Date.parse('2010-10-22'), parent.due_date + end + end + +##new + def test_parent_dates_should_not_change_with_parent_issue_dates_set_to_partially_derived_if_child_dates_inside_parent_range + with_settings :parent_issue_dates => 'partially_derived' do + parent = Issue.generate!(:start_date => '2010-01-01', :due_date => '2010-12-20') + parent.generate_child!(:start_date => '2010-01-25', :due_date => '2010-02-15') + parent.generate_child!( :due_date => '2010-02-13') + parent.generate_child!(:start_date => '2010-02-01', :due_date => '2010-10-22') + parent.reload + assert_equal Date.parse('2010-01-01'), parent.start_date + assert_equal Date.parse('2010-12-20'), parent.due_date + end + end + def test_reschuling_a_parent_should_reschedule_subtasks_with_parent_issue_dates_set_to_derived with_settings :parent_issue_dates => 'derived' do parent = Issue.generate! @@ -76,6 +102,38 @@ class IssueSubtaskingTest < ActiveSupport::TestCase end end +##new + def test_reschuling_a_parent_should_reschedule_subtasks_with_parent_issue_dates_set_to_partially_derived_if_child_dates_outside_parent_range + with_settings :parent_issue_dates => 'partially_derived' do + parent = Issue.generate!(:start_date => '2010-01-01', :due_date => '2010-12-20') + c1 = parent.generate_child!(:start_date => '2010-05-12', :due_date => '2010-05-18') + c2 = parent.generate_child!(:start_date => '2010-06-03', :due_date => '2010-06-10') + parent.reload.reschedule_on!(Date.parse('2010-06-02')) + c1.reload + assert_equal [Date.parse('2010-06-02'), Date.parse('2010-06-08')], [c1.start_date, c1.due_date] + c2.reload + assert_equal [Date.parse('2010-06-03'), Date.parse('2010-06-10')], [c2.start_date, c2.due_date] # no change + parent.reload + assert_equal [Date.parse('2010-06-02'), Date.parse('2011-05-19')], [parent.start_date, parent.due_date] + end + end + +##new + def test_reschuling_a_parent_should_not_reschedule_subtasks_with_parent_issue_dates_set_to_partially_derived_if_child_dates_inside_parent_range + with_settings :parent_issue_dates => 'partially_derived' do + parent = Issue.generate!(:start_date => '2010-01-01', :due_date => '2010-12-20') + c1 = parent.generate_child!(:start_date => '2010-05-12', :due_date => '2010-05-18') + c2 = parent.generate_child!(:start_date => '2010-06-03', :due_date => '2010-06-10') + parent.reload.reschedule_on!(Date.parse('2010-05-02')) + c1.reload + assert_equal [Date.parse('2010-05-12'), Date.parse('2010-05-18')], [c1.start_date, c1.due_date]# no change + c2.reload + assert_equal [Date.parse('2010-06-03'), Date.parse('2010-06-10')], [c2.start_date, c2.due_date] # no change + parent.reload + assert_equal [Date.parse('2010-05-03'), Date.parse('2011-04-19')], [parent.start_date, parent.due_date] + end + end + def test_parent_priority_should_be_read_only_with_parent_issue_priority_set_to_derived with_settings :parent_issue_priority => 'derived' do issue = Issue.generate_with_child! @@ -294,6 +352,16 @@ class IssueSubtaskingTest < ActiveSupport::TestCase end end end +###new + def test_parent_dates_should_be_editable_with_parent_issue_dates_set_to_partially_derived + with_settings :parent_issue_dates => 'partially_derived' do + issue = Issue.generate_with_child! + user = User.find(1) + %w(start_date due_date).each do |attribute| + assert issue.safe_attribute?(attribute, user) + end + end + end def test_parent_dates_should_not_be_updated_with_parent_issue_dates_set_to_independent with_settings :parent_issue_dates => 'independent' do -- 2.30.2 From 597d93994de7ba228ead9b6722a444a97978ee2a Mon Sep 17 00:00:00 2001 From: redacted Date: Tue, 2 Nov 2021 22:27:14 +0100 Subject: Full set of tests for all partially derived fields --- test/unit/issue_subtasking_test.rb | 98 +++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb index 2c31bc564..8839370fc 100644 --- a/test/unit/issue_subtasking_test.rb +++ b/test/unit/issue_subtasking_test.rb @@ -391,6 +391,14 @@ class IssueSubtaskingTest < ActiveSupport::TestCase assert issue.safe_attribute?('priority_id', user) end end +#new + def test_parent_priority_should_be_editable_with_parent_issue_priority_set_to_partially_derived + with_settings :parent_issue_priority => 'partially_derived' do + issue = Issue.generate_with_child! + user = User.find(1) + assert issue.safe_attribute?('priority_id', user) + end + end def test_parent_priority_should_not_be_updated_with_parent_issue_priority_set_to_independent with_settings :parent_issue_priority => 'independent' do @@ -399,6 +407,24 @@ class IssueSubtaskingTest < ActiveSupport::TestCase assert_equal 'Normal', parent.reload.priority.name end end +#new + def test_parent_priority_should_not_be_updated_with_parent_issue_priority_set_to_partially_derived_if_childs_priority_lower + with_settings :parent_issue_priority => 'partially_derived' do + parent = Issue.generate!(:priority => IssuePriority.find_by_name('Urgent')) + child1 = parent.generate_child!(:priority => IssuePriority.find_by_name('High')) + child2 = parent.generate_child!(:priority => IssuePriority.find_by_name('Low')) + assert_equal 'Urgent', parent.reload.priority.name + end + end +#new + def test_parent_priority_should_be_updated_with_parent_issue_priority_set_to_partially_derived_if_childs_priority_higher + with_settings :parent_issue_priority => 'partially_derived' do + parent = Issue.generate!(:priority => IssuePriority.find_by_name('Normal')) + child1 = parent.generate_child!(:priority => IssuePriority.find_by_name('Low')) + child2 = parent.generate_child!(:priority => IssuePriority.find_by_name('High')) + assert_equal 'High', parent.reload.priority.name + end + end def test_parent_done_ratio_should_be_editable_with_parent_issue_done_ratio_set_to_independent with_settings :parent_issue_done_ratio => 'independent' do @@ -407,6 +433,14 @@ class IssueSubtaskingTest < ActiveSupport::TestCase assert issue.safe_attribute?('done_ratio', user) end end +#new + def test_parent_done_ratio_should_be_editable_with_parent_issue_done_ratio_set_to_partially_derived + with_settings :parent_issue_done_ratio => 'partially_derived' do + issue = Issue.generate_with_child! + user = User.find(1) + assert issue.safe_attribute?('done_ratio', user) + end + end def test_parent_done_ratio_should_not_be_updated_with_parent_issue_done_ratio_set_to_independent with_settings :parent_issue_done_ratio => 'independent' do @@ -415,18 +449,78 @@ class IssueSubtaskingTest < ActiveSupport::TestCase assert_equal 0, parent.reload.done_ratio end end +#new + def test_parent_done_ratio_should_not_be_updated_with_parent_issue_done_ratio_set_to_partially_derived_if_childs_done_ratio_higher + with_settings :parent_issue_done_ratio => 'partially_derived' do + parent = Issue.generate!(:done_ratio => 40) + child1 = parent.generate_child!(:done_ratio => 50) + child2 = parent.generate_child!(:done_ratio => 60) + assert_equal 40, parent.reload.done_ratio + end + end +#new + def test_parent_done_ratio_should_be_updated_with_parent_issue_done_ratio_set_to_partially_derived_if_childs_done_ratio_lower + with_settings :parent_issue_done_ratio => 'partially_derived' do + parent = Issue.generate!(:done_ratio => 50) + child1 = parent.generate_child!(:done_ratio => 70) #set the higher one first, otherwise parent will get 10 + child2 = parent.generate_child!(:done_ratio => 10) + assert_equal 40, parent.reload.done_ratio + parent = Issue.generate!(:done_ratio => 50) + child1 = parent.generate_child!(:done_ratio => 80) + child2 = parent.generate_child!() + assert_equal 40, parent.reload.done_ratio + end + end + +#new + def test_setting_parent_due_dates_inside_childs_should_not_validate_with_dates_partially_derived + with_settings :parent_issue_dates => 'partially_derived' do + parent = Issue.generate!(:start_date => '2021-11-01', :due_date => '2021-12-01') + child = parent.generate_child!(:start_date => '2021-11-01', :due_date => '2021-12-01') + parent.reload + parent.start_date = '2021-11-02' + parent.due_date = '2021-11-29' + assert !parent.save + assert_include I18n.t("field_start_date")+' '+I18n.t("activerecord.errors.messages.later_than_minimum_start_date", :date => I18n.l(child.start_date)), parent.errors.full_messages + assert_include I18n.t("field_due_date")+' '+I18n.t("activerecord.errors.messages.earlier_than_maximum_due_date", :date => I18n.l(child.due_date)), parent.errors.full_messages + end + end +#new + def test_setting_parent_done_ratio_higher_than_childs_should_not_validate_with_done_ratio_partially_derived + with_settings :parent_issue_done_ratio => 'partially_derived' do + parent = Issue.generate!(:done_ratio => 10) + child = parent.generate_child!(:done_ratio => 50) + parent.reload + parent.done_ratio = 60 + assert !parent.save + assert_include I18n.t("field_done_ratio")+' '+I18n.t("activerecord.errors.messages.done_ratio_higher_than_children", :done_ratio => child.done_ratio), parent.errors.full_messages + end + end +#new + def test_setting_parent_priority_lower_than_childs_should_not_validate_with_priority_partially_derived + with_settings :parent_issue_priority => 'partially_derived' do + parent = Issue.generate!(:priority => IssuePriority.find_by_name('Normal')) + child = parent.generate_child!(:priority => IssuePriority.find_by_name('High')) + parent.reload + parent.priority = IssuePriority.find_by_name('Normal') + assert !parent.save + +### errors.add :priority, :priority_lower_than_children, :own_priority => own_priority_name, :priority => children_priority_name + + assert_include I18n.t("field_priority")+' '+I18n.t("activerecord.errors.messages.priority_lower_than_children", :own_priority => parent.priority, :priority => child.priority ), parent.errors.full_messages + end + end + def test_parent_total_estimated_hours_should_be_sum_of_visible_descendants parent = Issue.generate! parent.generate_child!(:estimated_hours => nil) - assert_equal 0, parent.reload.total_estimated_hours parent.generate_child!(:estimated_hours => 5) assert_equal 5, parent.reload.total_estimated_hours parent.generate_child!(:estimated_hours => 7) assert_equal 12, parent.reload.total_estimated_hours parent.generate_child!(:estimated_hours => 9, :is_private => true) - assert_equal 12, parent.reload.total_estimated_hours end def test_open_issue_with_closed_parent_should_not_validate -- 2.30.2 From 5f6775298c8e50baa632c6f96c7251aa61e73f23 Mon Sep 17 00:00:00 2001 From: redacted Date: Tue, 2 Nov 2021 22:28:18 +0100 Subject: Fix validation of partially derived done ratio --- app/models/issue.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index 05e56dbca..df3415bd6 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1933,7 +1933,7 @@ class Issue < ActiveRecord::Base estimated * ratio end progress = done / (average * children.count) - if done_ratio_partially_derived? + if p.done_ratio_partially_derived? #done ratio like done_ratio_derived, but parent done ratio can be lower than calculated done ratio #TODO: use done_ratio derived or set, whichever is lower p.done_ratio = [progress.floor, p.done_ratio].compact.min -- 2.30.2