Project

General

Profile

Actions

Defect #5524

closed

Update_parent_attributes doesn't work for the old parent issue when reparenting

Added by Fri Flaj over 14 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Issues
Target version:
Start date:
2010-05-14
Due date:
% Done:

100%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Try the following scenario:
  • Create issue "Parent 1"
  • Create issue "Parent 2"
  • Create subissue "Child" on "Parent 2" and set its estimated hours to 5

Current situation: Parent 1: 0hrs, Parent 2: 5 hrs, Child: 5 hrs

Now change parent for Child to "Parent 1"

Current situation: Parent 1: 5hrs, Parent 2: 5 hrs, Child: 5 hrs


Files

5524_svn.diff (2.03 KB) 5524_svn.diff Jean-Baptiste Barth, 2010-06-08 19:50
Actions #1

Updated by Fri Flaj over 14 years ago

I think this could be solved by doing something like the following when an issue is saved:

if <issue has parent> and <new parent != current parent>
p = <parent>
c = <children excluding tree starting at issue being reparented>
l = <leaves excluding tree starting at issue being reparented>
<update parent attributes as usual>
end

this will not disturb the usual workflow, and will work even if the issue being reparented is the last sub issue on its parent. I just don't know where to stick this behaviour.

Actions #2

Updated by Fri Flaj over 14 years ago

I had expected the following to work:

before_save :store_parent
after_save :fix_old_parent

def store_parent
if self.parent_id_was && !(self.parent_id_was == self.parent_issue_id)
@old_parent = self.parent_id_was
else
@old_parent = nil
end
end

def fix_old_parent
if @old_parent
dummy_child = Issue.new (:parent_id => @old_parent)
dummy_child.instance_eval { update_parent_attributes }
end
end

I can see the methods being called when I add logging, but the estimated hours remain as they are.

Actions #3

Updated by Jean-Baptiste Barth over 14 years ago

Reproduced here on current trunk. I leave a patch to solve this problem, a unit test included, all tests passing succesfully on my config.

Emiliano: maybe you can apply this and see if it works for you..

Actions #4

Updated by Fri Flaj over 14 years ago

Seems to do the job for me. Is there a timeline for this to be included in RM trunk?

Actions #5

Updated by Felix Schäfer over 14 years ago

  • Assignee set to Eric Davis
  • Target version set to 1.0.0 (RC)

My best bet to get this merged would be Eric Davis, though he is under a lot of stress from his work and redmine at the moment. I think this is important enough that it should be fixed for 1.0.0 though.

Actions #6

Updated by Eric Davis over 14 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100
  • Resolution set to Fixed

Applied in r3821. Thank you for the test in the patch, I had trouble understanding what this bug was doing until I read the test case.

Actions

Also available in: Atom PDF