Class: DefectCopy

Inherits:
ObjectCopy show all
Defined in:
lib/translate/copy/defect_copy.rb

Instance Method Summary collapse

Methods inherited from ObjectCopy

#card_values, #copy, #copy_children, #create_object, #excluded_attributes, #fetch_object, #fetch_project, #find_project_in_new_workspace, #initialize, #logger, #new_workspace, #rally_rest, #remember, #type_as_symbol, #user_exists?

Constructor Details

This class inherits a constructor from ObjectCopy

Instance Method Details

#has_requirement?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/translate/copy/defect_copy.rb', line 49

def has_requirement?
  not work_product.nil?
end

#has_test_case?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/translate/copy/defect_copy.rb', line 45

def has_test_case?
  not @object.test_case.nil?
end

#shallow_copy(object) ⇒ Object



2
3
4
5
6
# File 'lib/translate/copy/defect_copy.rb', line 2

def shallow_copy(object)
  values = super
  values.delete(:submitted_by) unless user_exists? object.
  values
end

#tangleObject



8
9
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
# File 'lib/translate/copy/defect_copy.rb', line 8

def tangle
  super

  if @new_object.nil?
    logger.debug "Could not find new object for object #{@object.oid} -- #{@object.name}"
    return
  end

  values = {}

  if !@object.requirement.nil?
    new_requirement = fetch_object(:artifact, @object.requirement.oid)
    values[:requirement] = new_requirement
  end

  if has_test_case? && has_requirement? && test_cases_work_product != work_product 
    # no-op. Don't tangle the test_case. This exposes a bug in the system where we can be in an invalid state
  elsif has_test_case?
    new_test_case = fetch_object(:test_case, @object.test_case.oid)
    values[:test_case] = new_test_case
  end

  # tangle the duplicate defects
  unless @object.duplicates.nil?
    dups = []
    @object.duplicates.each do |dup|
	dups << fetch_object(:defect, dup.oid)
    end
    values[:duplicates] = dups
  end
  @new_object.update(values) unless values.length == 0
end

#test_cases_work_productObject



53
54
55
56
# File 'lib/translate/copy/defect_copy.rb', line 53

def test_cases_work_product
  return nil unless has_test_case?
  @object.test_case.work_product
end

#work_productObject



41
42
43
# File 'lib/translate/copy/defect_copy.rb', line 41

def work_product
  @object.requirement
end