Class: DefectCopy
- Inherits:
-
ObjectCopy
- Object
- ObjectCopy
- DefectCopy
- Defined in:
- lib/translate/copy/defect_copy.rb
Instance Method Summary collapse
Methods inherited from ObjectCopy
#copy, #copy_children, #create_object, #excluded_attributes, #fetch_object, #fetch_project, #find_project_in_new_workspace, #initialize, #remember, #user_exists?
Constructor Details
This class inherits a constructor from ObjectCopy
Instance Method Details
#shallow_copy(object, new_workspace) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/translate/copy/defect_copy.rb', line 3 def shallow_copy(object, new_workspace) values = super values.delete(:submitted_by) unless user_exists? @object.submitted_by values end |
#tangle(new_workspace) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/translate/copy/defect_copy.rb', line 10 def tangle(new_workspace) values = {} new_defect = fetch_object(:defect, @object.oid, new_workspace) # If the original defect is in a different project from the stories' card, # then create a new user story, as the parent of this new user story, and make # the requirement on the defect this new story if @object.requirement != nil && @object.requirement.cards != nil && # The defect has a requirement, that is scheduled @object.project != nil && # The defect in not in the parent project @object.requirement.cards.first.project != @object.project # The card in in a different project from the defect story_name = @object.requirement.name new_requirement = fetch_object(:artifact, @object.requirement.oid, new_workspace) if new_requirement.parent && new_requirement.parent.project.nil? parent_story = new_requirement.parent else parent_story = new_workspace.rally_rest.create(:hierarchical_requirement, :workspace => new_workspace, :name => "Parent story for #{story_name} to hold defects in project #{@object.project.name}") end new_requirement.update(:parent => parent_story) values[:requirement] = parent_story else # if the old defect has a test case unless @object.test_case.nil? # get the new test_case new_test_case = fetch_object(:test_case, @object.test_case.oid, new_workspace) # update values[:test_case] = new_test_case # if the new defect is in the Parent Project and # the its related test_case is not in the same project as the defect, # then put the defect in the same project as the test_case if new_defect.project.nil? && new_defect.project != new_test_case.project values[:project] = new_test_case.project end end # if the old defect has a requirement if !@object.requirement.nil? && @object.requirement.type == "Story" # get the requiement, copied from this defect's requirement new_story = fetch_object(:artifact, @object.requirement.oid, new_workspace) # update the new defect values[:requirement] = new_story # if the new defect is in the Parent Project and # the new requirement is not in the same project as the defect, # then put the defect in the same project as the requirement if new_defect.project.nil? && new_defect.project != new_story.project values[:project] = new_story.project end end end # tangle the duplicate defects unless @object.duplicates.nil? dups = [] @object.duplicates.values.each do |dup| dups << fetch_object(:defect, dup.oid, new_workspace) end values[:duplicates] = dups end new_defect.update(values) unless values.length == 0 end |