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

pulibrary / allsearch_api / ed1cefda-f43b-4b58-95dd-12a33b7f1f7a

02 Jul 2025 06:23PM UTC coverage: 96.252% (-3.2%) from 99.494%
ed1cefda-f43b-4b58-95dd-12a33b7f1f7a

Pull #381

circleci

sandbergja
Refactor RackResponseController so that subclasses don't need to implement #json

Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
Pull Request #381: Rewrite DPUL and FindingAids controllers as rack applications

29 of 30 new or added lines in 3 files covered. (96.67%)

94 existing lines in 20 files now uncovered.

976 of 1014 relevant lines covered (96.25%)

63.21 hits per line

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

83.33
/app/models/physical_holding.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for determining
4
# the status of a physical holding in the ILS
5
class PhysicalHolding
2✔
6
  def initialize(holding_id:, holding_data:, document_id:)
2✔
7
    @holding_id = holding_id
23✔
8
    @holding_data = holding_data
23✔
9
    @document_id = document_id
23✔
10
  end
11

12
  def barcode
2✔
13
    items&.first&.barcode
23✔
14
  end
15

16
  def call_number
2✔
17
    @holding_data['call_number']
22✔
18
  end
19

20
  def library
2✔
21
    @library ||= @holding_data['library']
44✔
22
  end
23

24
  def status
2✔
25
    return unless library
22✔
26

27
    if coin? || senior_thesis?
22✔
UNCOV
28
      'On-site access'
×
29
    elsif alma_temporary_location_status
22✔
UNCOV
30
      alma_temporary_location_status
×
31
    elsif alma_location_status
22✔
32
      alma_location_status
11✔
33
    end
34
  end
35

36
  private
2✔
37

38
  attr_accessor :document_id
2✔
39

40
  def alma?
2✔
41
    document_id.start_with?('99') && document_id.end_with?('6421')
55✔
42
  end
43

44
  def coin?
2✔
45
    document_id.start_with? 'coin-'
22✔
46
  end
47

48
  def senior_thesis?
2✔
49
    document_id.start_with? 'dsp'
22✔
50
  end
51

52
  def alma_temporary_location_status
2✔
53
    # temporary location holdings have an alphabetical holding id
54
    return unless alma? && @holding_id.match(/[a-zA-Z]\$[a-zA-Z]/)
22✔
55

UNCOV
56
    @holding_id == 'RES_SHARE$IN_RS_REQ' ? 'Unavailable' : 'View record for Full Availability'
×
57
  end
58

59
  def alma_location_status
2✔
60
    return unless alma?
33✔
61

62
    if items_in_place_count == items&.count
22✔
63
      'Available'
22✔
UNCOV
64
    elsif items_in_place_count.zero?
×
UNCOV
65
      'Unavailable'
×
UNCOV
66
    elsif items_in_place_count < items&.count
×
UNCOV
67
      'Some items not available'
×
68
    end
69
  end
70

71
  def items
2✔
72
    @items ||= @holding_data['items']&.map { |item| PhysicalItem.new item: } || []
91✔
73
  end
74

75
  def items_in_place_count
2✔
76
    items&.count(&:in_place?)
22✔
77
  end
78
end
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