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

pulibrary / orangelight / a13c74e8-95d6-4e88-a984-67ca4d4d68ef

29 Jul 2025 08:10PM UTC coverage: 95.182% (-0.2%) from 95.407%
a13c74e8-95d6-4e88-a984-67ca4d4d68ef

Pull #4962

circleci

web-flow
Merge pull request #5093 from pulibrary/dont-download-franklin-gothic-urw

Stop downloading franklin-gothic-urw font
Pull Request #4962: Orangelight pos workcycle 07-07-2025

183 of 186 new or added lines in 23 files covered. (98.39%)

16 existing lines in 5 files now uncovered.

6104 of 6413 relevant lines covered (95.18%)

1508.55 hits per line

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

86.36
/app/helpers/holdings_helper.rb
1
# frozen_string_literal: false
2

3
# rubocop:disable Metrics/ModuleLength
4
module HoldingsHelper
3✔
5
  # Generate the markup block for individual search result items containing holding information
6
  # @param document [SolrDocument] the Solr Document retrieved in the search result set
7
  # @return [String] the markup
8

9
  # rubocop:disable Metrics/MethodLength
10
  def holding_block_search(document)
3✔
11
    block = ''.html_safe
1,601✔
12
    block_extra = ''.html_safe
1,601✔
13
    holdings_hash = document.holdings_all_display.sort { |a, b| sort_holdings(a, b) }
2,135✔
14
    @scsb_multiple = false
1,601✔
15
    if holdings_hash.count <= 4
1,601✔
16
      holdings_hash.each do |id, holding|
1,597✔
17
        block << holdings_block(document, id, holding)
1,614✔
18
      end
19
    elsif holdings_hash.count > 4
4✔
20
      holdings_array = holdings_hash.to_a
4✔
21
      holdings_array_first_three = holdings_array.first(3)
4✔
22
      holdings_array.count
4✔
23
      holdings_remaining = holdings_array.count - 3
4✔
24

25
      holdings_array_first_three.each do |id, holding|
4✔
26
        block << holdings_block(document, id, holding)
12✔
27
      end
28
      block_extra << content_tag(:a, href: "/catalog/#{document['id']}") do
4✔
29
        content_tag(:"lux-card", class: 'show-more-holdings') do
4✔
30
          content_tag(:span, "See #{holdings_remaining} more locations", class: 'lux-text-style blue')
4✔
31
        end
32
      end
33

34
      block << block_extra
4✔
35

36
    end
37

38
    if block.empty?
1,601✔
39
      ''
233✔
40
    else
41
      content_tag(:div, block, class: "holdings-card")
1,368✔
42
    end
43
  end
44
  # rubocop:enable Metrics/MethodLength
45

46
  def online_content_block(document)
3✔
47
    controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
1,601✔
48
  end
49

50
  # rubocop:disable Metrics/MethodLength
51
  # Currently having trouble breaking up this method further due to the "check_availability" variable
52
  def holdings_block(document, id, holding)
3✔
53
    location = holding_location(holding)
1,626✔
54
    check_availability = render_availability?
1,626✔
55
    accumulator = ''.html_safe
1,626✔
56
    if holding['library'] == 'Online'
1,626✔
57
      rendered_online_holdings_block = controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
×
58
      return rendered_online_holdings_block if rendered_online_holdings_block.present?
×
59

60
      check_availability = render_availability?
×
61
      accumulator << empty_link_online_holding_block
×
62

63
    else
64
      accumulator << library_location_div(holding, document, id)
1,626✔
65
      if holding['dspace'] || holding['location_code'] == 'rare$num'
1,626✔
66
        check_availability = false
50✔
67
        accumulator << dspace_or_numismatics_holding_block
50✔
68
      elsif /^scsb.+/.match? location[:code]
1,576✔
69
        check_availability = false
16✔
70
        unless holding['items'].nil?
16✔
71
          @scsb_multiple = true unless holding['items'].one?
16✔
72
          accumulator << scsb_item_block(holding)
16✔
73
        end
74
      elsif holding['dspace'].nil?
1,560✔
75
        accumulator << dspace_not_defined_block(location)
1,560✔
76
      else
77
        check_availability = false
×
78
        accumulator << under_embargo_block
×
79
      end
80
    end
81
    holding_status_li(accumulator, document, check_availability, id, holding)
1,626✔
82
  end
83
  # rubocop:enable Metrics/MethodLength
84

85
  def empty_link_online_holding_block
3✔
86
    data = content_tag(
×
87
      :span,
88
      'Link Missing',
89
      class: 'lux-text-style gray'
90
    )
91
    data << content_tag(
×
92
      :div,
93
      'Online access is not currently available.',
94
      class: 'library-location'
95
    )
96
  end
97

98
  def onsite_access_span
3✔
99
    content_tag(
4✔
100
      :span,
101
      'On-site access',
102
      class: 'lux-text-style green'
103
    )
104
  end
105

106
  def available_access_span
3✔
107
    content_tag(
50✔
108
      :span,
109
      'Available',
110
      class: 'lux-text-style green'
111
    )
112
  end
113

114
  def dspace_or_numismatics_holding_block
3✔
115
    available_access_span
50✔
116
  end
117

118
  def scsb_item_block(holding)
3✔
119
    scsb_supervised_items?(holding) ? scsb_supervised_item : scsb_unsupervised_item(holding)
16✔
120
  end
121

122
  def scsb_supervised_item
3✔
123
    onsite_access_span
4✔
124
  end
125

126
  def scsb_unsupervised_item(holding)
3✔
127
    content_tag(
12✔
128
      :span,
129
      '',
130
      class: 'lux-text-style',
131
      data: {
132
        'scsb-availability': 'true',
133
        'scsb-barcode': holding['items'].first['barcode'].to_s
134
      }
135
    )
136
  end
137

138
  def dspace_not_defined_block(_location)
3✔
139
    content_tag(
1,560✔
140
      :span,
141
      'Loading...',
142
      class: 'lux-text-style gray'
143
    )
144
  end
145

146
  def under_embargo_block
3✔
147
    content_tag(
×
148
      :span,
149
      'Request',
150
      class: 'lux-text-style red'
151
    )
152
  end
153

154
  def library_location_div(holding, document, id)
3✔
155
    content_tag(
1,626✔
156
      :div,
157
      search_location_display(holding),
158
      class: 'library-location',
159
      data: {
160
        location: true,
161
        record_id: document['id'],
162
        holding_id: id
163
      }
164
    )
165
  end
166

167
  def holding_status_li(accumulator, document, check_availability, id, holding)
3✔
168
    location = holding_location(holding)
1,626✔
169
    content_tag(:a, href: "/catalog/#{document['id']}") do
1,626✔
170
      content_tag(
1,626✔
171
        :'lux-card',
172
        accumulator,
173
        class: 'holding-status',
174
        data: {
175
          availability_record: check_availability,
176
          record_id: document['id'],
177
          holding_id: id,
178
          temp_location_code: holding['temp_location_code'],
179
          aeon: aeon_location?(location),
180
          bound_with: document.bound_with?
181
        }.compact
182
      )
183
    end
184
  end
185

186
  private
3✔
187

188
    # rubocop:disable Naming/MethodParameterName
189
    # rubocop:disable Lint/DuplicateBranch
190
    # :reek:DuplicateMethodCall
191
    # :reek:TooManyStatements
192
    # :reek:UncommunicativeParameterName
193
    # :reek:UtilityFunction
194
    def sort_holdings(a, b)
3✔
195
      # First, check if one of the items is Firestone.  If so, it should come first
196
      if a.second['location_code'].starts_with?('firestone') && !b.second['location_code'].starts_with?('firestone')
534✔
197
        -1
22✔
198
      elsif b.second['location_code'].starts_with?('firestone') && !a.second['location_code'].starts_with?('firestone')
512✔
199
        1
20✔
200
      # Next, check if one of the items is Recap.  If so, it should come last
201
      elsif a.second['location_code'].starts_with?('recap') && !b.second['location_code'].starts_with?('recap')
492✔
202
        1
38✔
203
      elsif b.second['location_code'].starts_with?('recap') && !a.second['location_code'].starts_with?('recap')
454✔
NEW
204
        -1
×
205
      # Next, check if one of the items is Annex.  If so, it should come last (but still before recap, which was handled previously)
206
      elsif a.second['location_code'].starts_with?('annex') && !b.second['location_code'].starts_with?('annex')
454✔
NEW
207
        1
×
208
      elsif b.second['location_code'].starts_with?('annex') && !a.second['location_code'].starts_with?('annex')
454✔
NEW
209
        -1
×
210
      else
211
        a.second['location_code'] <=> b.second['location_code']
454✔
212
      end
213
    end
214
  # rubocop:enable Naming/MethodParameterName
215
  # rubocop:enable Lint/DuplicateBranch
216
end
217
# rubocop:enable Metrics/ModuleLength
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