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

pulibrary / orangelight / 4c391e0e-519a-40cb-8ad3-354445f4ce03

12 Aug 2025 08:47PM UTC coverage: 85.348% (-10.0%) from 95.335%
4c391e0e-519a-40cb-8ad3-354445f4ce03

push

circleci

web-flow
[#5143] Use access restriction note as Aeon ItemInfo1 if available (#5173)

With this commit, if a user visits a record with an access
restrictions note and presses the Reading Room Request
button, they will get to an Aeon form with the 'Restrictions'
field pre-filled with the restriction note.

If the record does not have an access restrictions note,
the field will be pre-filled with 'Reading Room Access Only',
as it has been previously.

Closes #5143

5493 of 6436 relevant lines covered (85.35%)

251.82 hits per line

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

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

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

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

34
      block << block_extra
2✔
35

36
    end
37

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

46
  def online_content_block(document)
1✔
47
    controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
320✔
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)
1✔
53
    location = holding_location(holding)
318✔
54
    check_availability = render_availability?
318✔
55
    accumulator = ''.html_safe
318✔
56
    if holding['library'] == 'Online'
318✔
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)
318✔
65
      if holding['dspace'] || holding['location_code'] == 'rare$num'
318✔
66
        check_availability = false
26✔
67
        accumulator << dspace_or_numismatics_holding_block
26✔
68
      elsif /^scsb.+/.match? location[:code]
292✔
69
        check_availability = false
12✔
70
        unless holding['items'].nil?
12✔
71
          @scsb_multiple = true unless holding['items'].one?
12✔
72
          accumulator << scsb_item_block(holding)
12✔
73
        end
74
      elsif holding['dspace'].nil?
280✔
75
        accumulator << dspace_not_defined_block(location)
280✔
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)
318✔
82
  end
83
  # rubocop:enable Metrics/MethodLength
84

85
  def empty_link_online_holding_block
1✔
86
    data = content_tag(
×
87
      :span,
88
      'Link Missing',
89
      class: 'lux-text-style gray strong'
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
1✔
99
    content_tag(
2✔
100
      :span,
101
      'On-site access',
102
      class: 'lux-text-style green strong'
103
    )
104
  end
105

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

114
  def dspace_or_numismatics_holding_block
1✔
115
    available_access_span
26✔
116
  end
117

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

122
  def scsb_supervised_item
1✔
123
    onsite_access_span
2✔
124
  end
125

126
  def scsb_unsupervised_item(holding)
1✔
127
    content_tag(
10✔
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)
1✔
139
    content_tag(
280✔
140
      :span,
141
      'Loading...',
142
      class: 'lux-text-style gray strong'
143
    )
144
  end
145

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

154
  def library_location_div(holding, document, id)
1✔
155
    content_tag(
318✔
156
      :div,
157
      ApplicationController.new.view_context.render(Holdings::SearchLocationComponent.new(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)
1✔
168
    location = holding_location(holding)
318✔
169
    content_tag(:a, href: "/catalog/#{document['id']}") do
318✔
170
      content_tag(
318✔
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
1✔
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)
1✔
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')
178✔
197
        -1
4✔
198
      elsif b.second['location_code'].starts_with?('firestone') && !a.second['location_code'].starts_with?('firestone')
174✔
199
        1
×
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')
174✔
202
        1
2✔
203
      elsif b.second['location_code'].starts_with?('recap') && !a.second['location_code'].starts_with?('recap')
172✔
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')
172✔
207
        1
×
208
      elsif b.second['location_code'].starts_with?('annex') && !a.second['location_code'].starts_with?('annex')
172✔
209
        -1
×
210
      else
211
        a.second['location_code'] <=> b.second['location_code']
172✔
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