• 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

94.64
/app/components/holdings/location_services_component.rb
1
# frozen_string_literal: true
2
# This component is responsible for showing the user
3
# which services are available for a holding, given
4
# its location (typically some type of Request button)
5
# :reek:TooManyMethods
6
# :reek:TooManyInstanceVariables
7
class Holdings::LocationServicesComponent < ViewComponent::Base
1✔
8
  def initialize(adapter, holding_id, location_rules, holding, open_holdings = nil)
1✔
9
    @adapter = adapter
41✔
10
    @holding_id = holding_id
41✔
11
    @location_rules = location_rules
41✔
12
    @holding = holding
41✔
13
    @open_holdings = open_holdings
41✔
14
  end
15

16
    private
1✔
17

18
      attr_reader :adapter, :holding_id, :location_rules, :holding, :open_holdings
1✔
19

20
      def doc_id
1✔
21
        holding["mms_id"] || adapter.doc_id
28✔
22
      end
23

24
      def holding_object
1✔
25
        Requests::Holding.new(mfhd_id: holding_id, holding_data: holding)
13✔
26
      end
27

28
      # rubocop:disable Lint/DuplicateBranch
29
      # :reek:TooManyStatements
30
      def button_component
1✔
31
        if holding_id == 'thesis' || numismatics?
41✔
32
          AeonRequestButtonComponent.new(document:, holding: holding_hash, url_class: Requests::NonAlmaAeonUrl)
1✔
33
        elsif items && items.length > 1
40✔
34
          RequestButtonComponent.new(doc_id:, holding_id:, location: location_rules, open_holdings:)
18✔
35
        elsif aeon_location?
22✔
36
          AeonRequestButtonComponent.new(document:, holding: holding_hash)
12✔
37
        elsif scsb_location?
10✔
38
          RequestButtonComponent.new(doc_id:, location: location_rules, holding:, open_holdings:)
5✔
39
        elsif temporary_holding_id?
5✔
40
          holding_identifier = temporary_location_holding_id_first
×
41
          RequestButtonComponent.new(doc_id:, holding_id: holding_identifier, location: location_rules, open_holdings:)
×
42
        else
43
          RequestButtonComponent.new(doc_id:, holding_id:, location: location_rules, open_holdings:)
5✔
44
        end
45
      end
46
      # rubocop:enable Lint/DuplicateBranch
47

48
      def show_request
1✔
49
        if (requestable? && !thesis?) || numismatics?
41✔
50
          'service-always-requestable'
29✔
51
        else
52
          'service-conditional'
12✔
53
        end
54
      end
55

56
      def requestable?
1✔
57
        !adapter.alma_holding?(holding_id) || aeon_location? || scsb_location?
41✔
58
      end
59

60
      def open_location?
1✔
61
        location_rules && location_rules[:open]
41✔
62
      end
63

64
      def aeon_location?
1✔
65
        location_rules && location_rules[:aeon_location]
92✔
66
      end
67

68
      def requestable_location?
1✔
69
        return false if adapter.sc_location_with_suppressed_button?(holding)
41✔
70
        return false if adapter.unavailable_holding?(holding)
41✔
71
        location_rules && location_rules[:requestable]
41✔
72
      end
73

74
      def numismatics?
1✔
75
        holding_id == 'numismatics'
52✔
76
      end
77

78
      def thesis?
1✔
79
        holding_id == 'thesis' && adapter.pub_date > 2012
30✔
80
      end
81

82
      def scsb_location?
1✔
83
        location_rules && /^scsb.+/ =~ location_rules['code']
21✔
84
      end
85

86
      # Example of a temporary holding, in this case holding_id is : firestone$res3hr
87
      # {\"firestone$res3hr\":{\"location_code\":\"firestone$res3hr\",
88
      # \"current_location\":\"Circulation Desk (3 Hour Reserve)\",\"current_library\":\"Firestone Library\",
89
      # \"call_number\":\"HT1077 .M87\",\"call_number_browse\":\"HT1077 .M87\",
90
      # \"items\":[{\"holding_id\":\"22740601020006421\",\"id\":\"23740600990006421\",
91
      # \"status_at_load\":\"1\",\"barcode\":\"32101005621469\",\"copy_number\":\"1\"}]}}
92
      def temporary_holding_id?
1✔
93
        /[a-zA-Z]\$[a-zA-Z]/.match?(holding_id)
5✔
94
      end
95

96
      # When it is a temporary location and is requestable, use the first holding_id of this temporary location items.
97
      def temporary_location_holding_id_first
1✔
98
        holding["items"][0]["holding_id"]
×
99
      end
100

101
      def document
1✔
102
        adapter.document
13✔
103
      end
104

105
      # The full holding hash, with the holding_id as the key
106
      def holding_hash
1✔
107
        holding_object.to_h
13✔
108
      end
109

110
      def items
1✔
111
        holding['items']
77✔
112
      end
113
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