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

pulibrary / orangelight / 0e37073d-109c-440c-949f-49d2aa86311b

18 Aug 2025 09:05PM UTC coverage: 0.482% (-94.9%) from 95.343%
0e37073d-109c-440c-949f-49d2aa86311b

push

circleci

web-flow
Replace per_page_options_for_select with custom component to avoid deprecation issue (#5186)

* Start creating new component to address deprecaton warning

* Replace per_page_options_for_select with custom component to avoid deprecation issue

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

---------

Co-authored-by: Ryan Jensen <rj1044@princeton.edu>
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

0 of 33 new or added lines in 1 file covered. (0.0%)

9374 existing lines in 213 files now uncovered.

47 of 9753 relevant lines covered (0.48%)

0.01 hits per line

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

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

3
# rubocop:disable Metrics/ModuleLength
UNCOV
4
module HoldingsHelper
×
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
UNCOV
10
  def holding_block_search(document)
×
UNCOV
11
    block = ''.html_safe
×
UNCOV
12
    block_extra = ''.html_safe
×
UNCOV
13
    holdings_hash = document.holdings_all_display.sort { |a, b| sort_holdings(a, b) }
×
UNCOV
14
    @scsb_multiple = false
×
UNCOV
15
    if holdings_hash.count <= 4
×
UNCOV
16
      holdings_hash.each do |id, holding|
×
UNCOV
17
        block << holdings_block(document, id, holding)
×
UNCOV
18
      end
×
UNCOV
19
    elsif holdings_hash.count > 4
×
UNCOV
20
      holdings_array = holdings_hash.to_a
×
UNCOV
21
      holdings_array_first_three = holdings_array.first(3)
×
UNCOV
22
      holdings_array.count
×
UNCOV
23
      holdings_remaining = holdings_array.count - 3
×
24

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

UNCOV
34
      block << block_extra
×
35

UNCOV
36
    end
×
37

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

UNCOV
46
  def online_content_block(document)
×
UNCOV
47
    controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
×
UNCOV
48
  end
×
49

50
  # rubocop:disable Metrics/MethodLength
51
  # Currently having trouble breaking up this method further due to the "check_availability" variable
UNCOV
52
  def holdings_block(document, id, holding)
×
UNCOV
53
    location = holding_location(holding)
×
UNCOV
54
    check_availability = render_availability?
×
UNCOV
55
    accumulator = ''.html_safe
×
UNCOV
56
    if holding['library'] == 'Online'
×
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

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

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

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

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

UNCOV
114
  def dspace_or_numismatics_holding_block
×
UNCOV
115
    available_access_span
×
UNCOV
116
  end
×
117

UNCOV
118
  def scsb_item_block(holding)
×
UNCOV
119
    scsb_supervised_items?(holding) ? scsb_supervised_item : scsb_unsupervised_item(holding)
×
UNCOV
120
  end
×
121

UNCOV
122
  def scsb_supervised_item
×
UNCOV
123
    onsite_access_span
×
UNCOV
124
  end
×
125

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

UNCOV
138
  def dspace_not_defined_block(_location)
×
UNCOV
139
    content_tag(
×
UNCOV
140
      :span,
×
UNCOV
141
      'Loading...',
×
UNCOV
142
      class: 'lux-text-style gray strong'
×
UNCOV
143
    )
×
UNCOV
144
  end
×
145

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

UNCOV
154
  def library_location_div(holding, document, id)
×
UNCOV
155
    content_tag(
×
UNCOV
156
      :div,
×
UNCOV
157
      ApplicationController.new.view_context.render(Holdings::SearchLocationComponent.new(holding)),
×
UNCOV
158
      class: 'library-location',
×
UNCOV
159
      data: {
×
UNCOV
160
        location: true,
×
UNCOV
161
        record_id: document['id'],
×
UNCOV
162
        holding_id: id
×
UNCOV
163
      }
×
UNCOV
164
    )
×
UNCOV
165
  end
×
166

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

UNCOV
186
  private
×
187

188
    # rubocop:disable Naming/MethodParameterName
189
    # rubocop:disable Lint/DuplicateBranch
190
    # :reek:DuplicateMethodCall
191
    # :reek:TooManyStatements
192
    # :reek:UncommunicativeParameterName
193
    # :reek:UtilityFunction
UNCOV
194
    def sort_holdings(a, b)
×
195
      # First, check if one of the items is Firestone.  If so, it should come first
UNCOV
196
      if a.second['location_code'].starts_with?('firestone') && !b.second['location_code'].starts_with?('firestone')
×
UNCOV
197
        -1
×
UNCOV
198
      elsif b.second['location_code'].starts_with?('firestone') && !a.second['location_code'].starts_with?('firestone')
×
UNCOV
199
        1
×
200
      # Next, check if one of the items is Recap.  If so, it should come last
UNCOV
201
      elsif a.second['location_code'].starts_with?('recap') && !b.second['location_code'].starts_with?('recap')
×
UNCOV
202
        1
×
UNCOV
203
      elsif b.second['location_code'].starts_with?('recap') && !a.second['location_code'].starts_with?('recap')
×
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)
UNCOV
206
      elsif a.second['location_code'].starts_with?('annex') && !b.second['location_code'].starts_with?('annex')
×
207
        1
×
UNCOV
208
      elsif b.second['location_code'].starts_with?('annex') && !a.second['location_code'].starts_with?('annex')
×
209
        -1
×
UNCOV
210
      else
×
UNCOV
211
        a.second['location_code'] <=> b.second['location_code']
×
UNCOV
212
      end
×
UNCOV
213
    end
×
214
  # rubocop:enable Naming/MethodParameterName
215
  # rubocop:enable Lint/DuplicateBranch
UNCOV
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