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

pulibrary / orangelight / a9945904-c4b1-47a3-9b94-042f58dd8a8e

26 Nov 2024 06:06PM UTC coverage: 96.419% (-0.3%) from 96.676%
a9945904-c4b1-47a3-9b94-042f58dd8a8e

push

circleci

web-flow
Merge pull request #4446 from pulibrary/4081-bootstrap5

[#4081] Update to bootstrap 5

4 of 5 new or added lines in 4 files covered. (80.0%)

16 existing lines in 4 files now uncovered.

6005 of 6228 relevant lines covered (96.42%)

1553.05 hits per line

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

86.57
/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
  def holding_block_search(document)
3✔
10
    block = ''.html_safe
682✔
11
    holdings_hash = document.holdings_all_display
682✔
12
    @scsb_multiple = false
682✔
13

14
    holdings_hash.first(2).each do |id, holding|
682✔
15
      block << first_two_holdings_block(document, id, holding)
622✔
16
      block << content_tag(:li, cdl_placeholder)
622✔
17
    end
18

19
    block << controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
682✔
20

21
    if @scsb_multiple == true || holdings_hash.length > 2
682✔
22
      block << view_record_for_full_avail_li(document)
40✔
23
    elsif !holdings_hash.empty?
642✔
24
      block << view_record_for_full_avail_li_two(document)
522✔
25
    end
26

27
    if block.empty?
682✔
28
      content_tag(:div, t('blacklight.holdings.search_missing'))
22✔
29
    else
30
      content_tag(:ul, block)
660✔
31
    end
32
  end
33

34
  # rubocop:disable Metrics/MethodLength
35
  # Currently having trouble breaking up this method further due to the "check_availability" variable
36
  def first_two_holdings_block(document, id, holding)
3✔
37
    location = holding_location(holding)
622✔
38
    check_availability = render_availability?
622✔
39
    accumulator = ''.html_safe
622✔
40
    if holding['library'] == 'Online'
622✔
UNCOV
41
      rendered_online_holdings_block = controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
×
UNCOV
42
      return rendered_online_holdings_block if rendered_online_holdings_block.present?
×
43

UNCOV
44
      check_availability = render_availability?
×
UNCOV
45
      accumulator << empty_link_online_holding_block
×
46

47
    else
48
      if holding['dspace'] || holding['location_code'] == 'rare$num'
622✔
49
        check_availability = false
18✔
50
        accumulator << dspace_or_numismatics_holding_block(location)
18✔
51
      elsif /^scsb.+/.match? location[:code]
604✔
52
        check_availability = false
9✔
53
        unless holding['items'].nil?
9✔
54
          @scsb_multiple = true unless holding['items'].count == 1
9✔
55
          accumulator << scsb_item_block(holding)
9✔
56
        end
57
      elsif holding['dspace'].nil?
595✔
58
        accumulator << dspace_not_defined_block(location)
595✔
59
      else
UNCOV
60
        check_availability = false
×
UNCOV
61
        accumulator << under_embargo_block
×
62
      end
63
      accumulator << library_location_div(holding, document, id)
622✔
64
    end
65
    holding_status_li(accumulator, document, check_availability, id, holding)
622✔
66
  end
67
  # rubocop:enable Metrics/MethodLength
68

69
  def empty_link_online_holding_block
3✔
UNCOV
70
    data = content_tag(
×
71
      :span,
72
      'Link Missing',
73
      class: 'availability-icon badge bg-secondary'
74
    )
UNCOV
75
    data << content_tag(
×
76
      :div,
77
      'Online access is not currently available.',
78
      class: 'library-location'
79
    )
80
  end
81

82
  def onsite_access_span
3✔
83
    content_tag(
20✔
84
      :span,
85
      'On-site access',
86
      class: 'availability-icon badge bg-success'
87
    )
88
  end
89

90
  def dspace_or_numismatics_holding_block(_location)
3✔
91
    onsite_access_span
18✔
92
  end
93

94
  def scsb_item_block(holding)
3✔
95
    scsb_supervised_items?(holding) ? scsb_supervised_item : scsb_unsupervised_item(holding)
9✔
96
  end
97

98
  def scsb_supervised_item
3✔
99
    onsite_access_span
2✔
100
  end
101

102
  def scsb_unsupervised_item(holding)
3✔
103
    content_tag(
7✔
104
      :span,
105
      '',
106
      class: 'availability-icon badge',
107
      data: {
108
        'scsb-availability': 'true',
109
        'scsb-barcode': holding['items'].first['barcode'].to_s
110
      }
111
    )
112
  end
113

114
  def dspace_not_defined_block(_location)
3✔
115
    content_tag(
595✔
116
      :span,
117
      'Loading...',
118
      class: 'availability-icon badge bg-secondary'
119
    )
120
  end
121

122
  def under_embargo_block
3✔
UNCOV
123
    content_tag(
×
124
      :span,
125
      'Unavailable',
126
      class: 'availability-icon badge bg-danger'
127
    )
128
  end
129

130
  def library_location_div(holding, document, id)
3✔
131
    content_tag(
622✔
132
      :div,
133
      search_location_display(holding),
134
      class: 'library-location',
135
      data: {
136
        location: true,
137
        record_id: document['id'],
138
        holding_id: id
139
      }
140
    )
141
  end
142

143
  def holding_status_li(accumulator, document, check_availability, id, holding)
3✔
144
    location = holding_location(holding)
622✔
145
    content_tag(
622✔
146
      :li,
147
      accumulator,
148
      class: 'holding-status',
149
      data: {
150
        availability_record: check_availability,
151
        record_id: document['id'],
152
        holding_id: id,
153
        temp_location_code: holding['temp_location_code'],
154
        aeon: aeon_location?(location),
155
        bound_with: document.bound_with?
156
      }.compact
157
    )
158
  end
159

160
  def cdl_placeholder
3✔
161
    content_tag(
622✔
162
      :span,
163
      '',
164
      class: 'badge bg-primary',
165
      data: { 'availability-cdl': true }
166
    )
167
  end
168

169
  def view_record_for_full_avail_li(document)
3✔
170
    content_tag(
40✔
171
      :li,
172
      link_to(
173
        'View Record for Full Availability',
174
        solr_document_path(document['id']),
175
        class: 'availability-icon badge bg-secondary more-info'
176
      )
177
    )
178
  end
179

180
  def view_record_for_full_avail_li_two(document)
3✔
181
    content_tag(
522✔
182
      :li,
183
      link_to(
184
        '',
185
        solr_document_path(document['id']),
186
        class: 'availability-icon more-info'
187
      ),
188
      class: 'empty',
189
      data: { record_id: document['id'] }
190
    )
191
  end
192
end
193
# 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