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

pulibrary / tigerdata-app / 1f9ee909-20b2-467d-b493-b5be4964430d

22 Oct 2025 04:57PM UTC coverage: 91.212%. Remained the same
1f9ee909-20b2-467d-b493-b5be4964430d

push

circleci

web-flow
Fixing flaky tests (#2080)

10 times out of 10 one of these tests would fail for me locally.

Really we just have to look at the page for something new so that we are
sure the controller action has finished before we check for something
that is not waiting.

2740 of 3004 relevant lines covered (91.21%)

755.12 hits per line

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

97.22
/app/presenters/project_xml_presenter.rb
1
# frozen_string_literal: true
2

3
# rubocop:disable Metrics/ClassLength
4
class ProjectXmlPresenter
4✔
5
  attr_reader :project, :project_metadata
4✔
6

7
  # Delegate methods to the project and project_metadata objects
8
  delegate(
4✔
9
    "id",
10
    "in_mediaflux?",
11
    "mediaflux_id",
12
    "title",
13
    to: :project
14
  )
15

16
  delegate(
4✔
17
    "approval_note",
18
    "description",
19
    "data_manager",
20
    "data_sponsor",
21
    "data_user_read_only",
22
    "data_user_read_write",
23
    "departments",
24
    "project_id",
25
    "project_purpose",
26
    "storage_capacity",
27
    "storage_performance_expectations",
28
    "created_by",
29
    "created_on",
30
    "updated_by",
31
    "updated_on",
32
    "schema_version",
33
    to: :project_metadata
34
  )
35

36
  # @param project [Project] The project for the presenter
37
  def initialize(project)
4✔
38
    @project = project
116✔
39
    @project_metadata = @project.metadata_model
116✔
40
  end
41

42
  # @return [Nokogiri::XML::Document] The XML document
43
  delegate :document, to: :build
4✔
44

45
  # @return [Boolean] Whether the request for a Globus mount is approved
46
  def globus_enable_approved?
4✔
47
    project_metadata.globus_request == "Yes"
284✔
48
  end
49

50
  # @return [String] Whether the request for a Globus mount is approved
51
  def globus_enable_approved
4✔
52
    if globus_enable_approved?
278✔
53
      "true"
2✔
54
    else
55
      "false"
276✔
56
    end
57
  end
58

59
  # @return [Boolean] Whether there is a request for a Globus mount
60
  def globus_enable_requested?
4✔
61
    project_metadata.globus_request == "Yes"
100✔
62
  end
63

64
  # @return [String] Whether the request for a Globus mount is requested
65
  def globus_enable_requested
4✔
66
    if globus_enable_requested?
96✔
67
      "true"
2✔
68
    else
69
      "false"
94✔
70
    end
71
  end
72

73
  # @return [Boolean] Whether the request for the SMB mount is approved
74
  def smb_enable_approved?
4✔
75
    project_metadata.smb_request == "Yes"
284✔
76
  end
77

78
  # @return [String] Whether the request for the SMB mount is approved
79
  def smb_enable_approved
4✔
80
    if smb_enable_approved?
184✔
81
      "true"
2✔
82
    else
83
      "false"
182✔
84
    end
85
  end
86

87
  # @return [Boolean] Whether there is a request for SMB mount
88
  def smb_enable_requested?
4✔
89
    project_metadata.smb_request == "Yes"
92✔
90
  end
91

92
  # @return [String] Whether the request for the SMB mount is requested
93
  def smb_enable_requested
4✔
94
    if smb_enable_requested?
90✔
95
      "true"
×
96
    else
97
      "false"
90✔
98
    end
99
  end
100

101
  # @return [String] The project status (mapped to values specified by the TigerData XML schema)
102
  # NOTE: Valid values are one of: 'AdminReview', 'Approved', 'Active', 'Retired', 'Published'
103
  def status
4✔
104
    project_status = project.status
90✔
105
    return if project_status.nil?
90✔
106

107
    project_status.capitalize
90✔
108
  end
109

110
  # @return [ProvenanceEvent] The first project submission event
111
  def submission
4✔
112
    @submission ||= project.provenance_events.find_by(event_type: ProvenanceEvent::SUBMISSION_EVENT_TYPE)
422✔
113
  end
114

115
  # @return [Array<ProvenanceEvent>] The project submission events
116
  def submissions
4✔
117
    [submission]
90✔
118
  end
119

120
  # @return [String] The user ID of the user who requested the project
121
  def requested_by
4✔
122
    return if submission.nil?
92✔
123

124
    submission.event_person
74✔
125
  end
126

127
  # @return [String] The date and time of the request
128
  def request_date_time
4✔
129
    return if submission.nil?
92✔
130

131
    value = submission.created_at
74✔
132
    value.strftime("%Y-%m-%dT%H:%M:%S%:z")
74✔
133
  end
134

135
  # @return [String] The user ID of the user who approved the project
136
  def approved_by
4✔
137
    return if approval_note.nil?
92✔
138

139
    approval_note[:note_by]
6✔
140
  end
141

142
  # @return [String] The date and time of the approval
143
  def approval_date_time
4✔
144
    return nil if approval_note.nil?
92✔
145

146
    approval_note[:note_date_time]
6✔
147
  end
148

149
  # @return [String] Whether or not the project data use agreement
150
  def data_use_agreement?
4✔
151
    project_metadata.data_use_agreement.present?
92✔
152
  end
153

154
  # @return [String] The project resource type
155
  def project_resource_type
4✔
156
    project_metadata.resource_type
92✔
157
  end
158

159
  # @return [Boolean] Whether the project is provisional
160
  def provisional_project?
4✔
161
    project_metadata.provisional
92✔
162
  end
163

164
  # @return [String] Whether or not the project is associated with HPC
165
  delegate :hpc, to: :project_metadata
4✔
166

167
  # @return [String] The project visibility
168
  delegate :project_visibility, to: :project_metadata
4✔
169

170
  # @return [Boolean] Whether the project directory request is approved
171
  def project_directory_approved?
4✔
172
    expectations = storage_performance_expectations
90✔
173
    expectations[:approved] || false
90✔
174
  end
175

176
  # @return [Boolean] Whether the project storage capacity request is approved
177
  def storage_capacity_approved?
4✔
178
    storage_capacity_size = storage_capacity["size"] || {}
90✔
179
    return false unless storage_capacity_size.key?(:approved)
90✔
180

181
    approved_size = storage_capacity_size[:approved] || 0
18✔
182
    approved_size > 0
18✔
183
  end
184

185
  # @return [Boolean] Whether the project storage request is approved
186
  def storage_performance_requested?
4✔
187
    requested = storage_performance_expectations[:requested]
90✔
188
    requested.present?
90✔
189
  end
190

191
  # @return [Array<String>] The project directory paths
192
  def project_directory
4✔
193
    [project.project_directory]
276✔
194
  end
195

196
  # @param index [Integer] The index of the project directory
197
  # @return [String] The project directory path
198
  def project_directory_path(index)
4✔
199
    entry = project_directory[index]
90✔
200
    entry
90✔
201
  end
202

203
  # @param index [Integer] The index of the project directory
204
  # @return [String] The protocol for the project directory
205
  def project_directory_protocol(index)
4✔
206
    entry = project_directory[index]
92✔
207
    segments = entry.split("://")
92✔
208

209
    if segments.length > 1
92✔
210
      value = segments[0]
×
211
      value.upcase
×
212
    else
213
      ProjectMetadata.default_directory_protocol
92✔
214
    end
215
  end
216

217
  # @param index [Integer] The index of the department code to retrieve
218
  # @return [String] The department code for departments associated with the project
219
  def department(index)
4✔
220
    value = departments[index]
104✔
221
    if value.length < 6
104✔
222
      value = value.rjust(6, "0")
100✔
223
    end
224
    value
104✔
225
  end
226

227
  # @return [String] The department code for the project
228
  def department_code(index)
4✔
229
    departments[index]
104✔
230
  end
231

232
  # @return [String] The requested project storage capacity
233
  def requested_storage
4✔
234
    storage_performance_expectations[:requested] || nil
92✔
235
  end
236

237
  private
4✔
238

239
    def xml_builder_config
4✔
240
      Rails.configuration.xml_builder
180✔
241
    end
242

243
    def presenter_builder_config
4✔
244
      xml_builder_config[:project] || {}
180✔
245
    end
246

247
    def find_builder_args(key)
4✔
248
      raise "No builder config for #{key}" unless presenter_builder_config.key?(key)
90✔
249

250
      values = presenter_builder_config[key]
90✔
251
      values[:presenter] = self
90✔
252
      values
90✔
253
    end
254

255
    def builder
4✔
256
      @builder ||= begin
90✔
257
                     builder_args = find_builder_args(:resource)
90✔
258
                     XmlTreeBuilder.new(**builder_args)
90✔
259
                   end
260
    end
261

262
    delegate :build, to: :builder
4✔
263
end
264
# rubocop:enable Metrics/ClassLength
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