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

pulibrary / orangelight / 4e01fe00-694b-47b4-8b30-2de4dc4acc66

31 Jul 2025 07:56PM UTC coverage: 92.891% (-2.5%) from 95.4%
4e01fe00-694b-47b4-8b30-2de4dc4acc66

Pull #4962

circleci

web-flow
Merge pull request #5130 from pulibrary/clean_up_scss_comments

Remove SCSS commented code.
Pull Request #4962: Orangelight pos workcycle 07-07-2025

193 of 197 new or added lines in 24 files covered. (97.97%)

161 existing lines in 35 files now uncovered.

5932 of 6386 relevant lines covered (92.89%)

1443.08 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
2✔
8
  def initialize(adapter, holding_id, location_rules, holding, open_holdings = nil)
2✔
9
    @adapter = adapter
160✔
10
    @holding_id = holding_id
160✔
11
    @location_rules = location_rules
160✔
12
    @holding = holding
160✔
13
    @open_holdings = open_holdings
160✔
14
  end
15

16
    private
2✔
17

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

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

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

28
      # rubocop:disable Lint/DuplicateBranch
29
      # :reek:TooManyStatements
30
      def button_component
2✔
31
        if holding_id == 'thesis' || numismatics?
160✔
32
          AeonRequestButtonComponent.new(document:, holding: holding_hash, url_class: Requests::NonAlmaAeonUrl)
10✔
33
        elsif items && items.length > 1
150✔
34
          RequestButtonComponent.new(doc_id:, holding_id:, location: location_rules, open_holdings:)
88✔
35
        elsif aeon_location?
62✔
36
          AeonRequestButtonComponent.new(document:, holding: holding_hash)
24✔
37
        elsif scsb_location?
38✔
38
          RequestButtonComponent.new(doc_id:, location: location_rules, holding:, open_holdings:)
7✔
39
        elsif temporary_holding_id?
31✔
UNCOV
40
          holding_identifier = temporary_location_holding_id_first
×
NEW
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:)
31✔
44
        end
45
      end
46
      # rubocop:enable Lint/DuplicateBranch
47

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

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

60
      def open_location?
2✔
61
        location_rules && location_rules[:open]
160✔
62
      end
63

64
      def aeon_location?
2✔
65
        location_rules && location_rules[:aeon_location]
358✔
66
      end
67

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

74
      def numismatics?
2✔
75
        holding_id == 'numismatics'
264✔
76
      end
77

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

82
      def scsb_location?
2✔
83
        location_rules && /^scsb.+/ =~ location_rules['code']
143✔
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?
2✔
93
        /[a-zA-Z]\$[a-zA-Z]/.match?(holding_id)
31✔
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
2✔
UNCOV
98
        holding["items"][0]["holding_id"]
×
99
      end
100

101
      def document
2✔
102
        adapter.document
34✔
103
      end
104

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

110
      def items
2✔
111
        holding['items']
294✔
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