• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / 7291b10e-eaa3-4284-9371-5a980ceebf59

24 Nov 2025 07:18PM UTC coverage: 87.613% (-3.7%) from 91.333%
7291b10e-eaa3-4284-9371-5a980ceebf59

push

circleci

web-flow
Adds breadcrumb to Wizard (#2231)

Adds the breadcrumb to the Wizard and the functionality to allow the
user to save their changes before leaving the Wizard when clicking on
the "Dashboard" link in the breadcrumbs.

Closes #2102

5 of 12 new or added lines in 11 files covered. (41.67%)

904 existing lines in 36 files now uncovered.

2801 of 3197 relevant lines covered (87.61%)

360.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/app/services/xml_element_builder.rb
1
# frozen_string_literal: true
UNCOV
2
class XmlElementBuilder < XmlNodeBuilder
3✔
UNCOV
3
  attr_reader :presenter, :name, :attributes, :content
3✔
UNCOV
4
  alias entry content
3✔
UNCOV
5
  delegate :blank?, to: :content
3✔
6

7
  # @return [Nokogiri::XML::Element] the XML element node
UNCOV
8
  def element
3✔
UNCOV
9
    @element ||= begin
4,252✔
UNCOV
10
                   created = @document.create_element(name)
1,438✔
UNCOV
11
                   @document.root = created
1,438✔
UNCOV
12
                   created
1,438✔
UNCOV
13
                 end
UNCOV
14
  end
15

16
  # @return [Nokogiri::XML::Element] the XML element node
UNCOV
17
  def build_attributes
3✔
UNCOV
18
    attributes.each do |key, attr_entry|
1,482✔
UNCOV
19
      value = attr_entry
2,863✔
UNCOV
20
      if attr_entry.is_a?(Hash) && attr_entry.key?(:object_method)
2,863✔
UNCOV
21
        allow_empty_attr = attr_entry.fetch(:allow_empty, true)
495✔
22

UNCOV
23
        message = attr_entry[:object_method]
495✔
UNCOV
24
        method_args = attr_entry[:args] || []
495✔
UNCOV
25
        method_args = @default_method_args + method_args
495✔
UNCOV
26
        value = presenter.send(message, *method_args)
495✔
27

UNCOV
28
        raise ArgumentError, "Value for #{key} cannot be nil" if value.nil? && !allow_empty_attr
490✔
UNCOV
29
      end
30

UNCOV
31
      element[key] = value unless value.nil?
2,819✔
UNCOV
32
    end
33

UNCOV
34
    element
1,438✔
UNCOV
35
  end
36

37
  # @return [String] the content for the XML element
UNCOV
38
  def build_content!
3✔
UNCOV
39
    allow_empty_content = entry.fetch(:allow_empty, true)
905✔
40

UNCOV
41
    message = entry[:object_method]
905✔
UNCOV
42
    method_args = entry[:args] || []
905✔
UNCOV
43
    method_args = @default_method_args + method_args
905✔
UNCOV
44
    @content = presenter.send(message, *method_args)
905✔
45

UNCOV
46
    raise ArgumentError, "Content for #{name} cannot be nil" if content.nil? && !allow_empty_content
905✔
UNCOV
47
    content
866✔
UNCOV
48
  end
49

50
  # rubocop:disable Metrics/AbcSize
51
  # rubocop:disable Metrics/CyclomaticComplexity
52
  # rubocop:disable Metrics/MethodLength
53
  # rubocop:disable Metrics/PerceivedComplexity
54
  #
55
  # @return [Nokogiri::XML::Element]
UNCOV
56
  def build
3✔
UNCOV
57
    if entry.is_a?(Hash) && entry.key?(:object_method)
1,521✔
UNCOV
58
      build_content!
905✔
UNCOV
59
    end
60

UNCOV
61
    built = build_attributes
1,482✔
UNCOV
62
    built.content = content
1,438✔
63

UNCOV
64
    built
1,438✔
UNCOV
65
  rescue ArgumentError => arg_error
UNCOV
66
    Rails.logger.warn("Error building XML project metadata: #{arg_error.message}")
83✔
UNCOV
67
    nil
83✔
UNCOV
68
  end
69
  # rubocop:enable Metrics/PerceivedComplexity
70
  # rubocop:enable Metrics/MethodLength
71
  # rubocop:enable Metrics/CyclomaticComplexity
72
  # rubocop:enable Metrics/AbcSize
73

74
  # @return [Nokogiri::XML::Element] the XML element node
UNCOV
75
  def node
3✔
UNCOV
76
    @node ||= build
2,917✔
UNCOV
77
  end
78

UNCOV
79
  def add_child(child)
3✔
UNCOV
80
    return if child.nil?
1,479✔
81

82
    # @see https://nokogiri.org/rdoc/Nokogiri/XML/Node.html#method-i-clone
UNCOV
83
    level = 1
1,396✔
UNCOV
84
    cloned = child.clone(level, document)
1,396✔
UNCOV
85
    node.add_child(cloned)
1,396✔
86

UNCOV
87
    cloned
1,396✔
UNCOV
88
  end
89

90
  # @param [ProjectXmlPresenter] presenter
91
  # @param [String] name
92
  # @param [Hash] attributes
93
  # @param [String] content
94
  # @param [Integer] index the index for the element (when there are multiple sibling nodes)
95
  # @param [Hash] options
UNCOV
96
  def initialize(presenter:, name:, attributes: {}, content: nil, index: nil, **options)
3✔
UNCOV
97
    super(**options)
1,521✔
98

UNCOV
99
    @presenter = presenter
1,521✔
UNCOV
100
    @name = name
1,521✔
101

UNCOV
102
    @attributes = attributes
1,521✔
UNCOV
103
    @content = content
1,521✔
104

UNCOV
105
    @index = index
1,521✔
106

UNCOV
107
    @default_method_args = []
1,521✔
UNCOV
108
    @default_method_args << @index unless @index.nil?
1,521✔
UNCOV
109
  end
UNCOV
110
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc