• 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

99.17
/app/models/requests/requestable.rb
1
# frozen_string_literal: true
2
module Requests
2✔
3
  # This class describes a resource that a
4
  # library patron might wish to request
5
  class Requestable
2✔
6
    attr_reader :bib
2✔
7
    attr_reader :holding
2✔
8
    attr_reader :item
2✔
9
    attr_reader :location
2✔
10
    attr_reader :call_number
2✔
11
    attr_reader :title
2✔
12
    attr_reader :patron
2✔
13
    attr_reader :services
2✔
14

15
    delegate :illiad_request_url, :illiad_request_parameters, to: :@illiad
2✔
16
    delegate :eligible_for_library_services?, to: :@patron
2✔
17

18
    include Requests::Aeon
2✔
19

20
    # @param bib [Hash] Solr Document of the Top level Request
21
    # @param holding [Requests::Holding] Bibdata information on where the item is held, created with data from the parsed solr_document[holdings_1display] json
22
    # @param item [Hash] Item level data from bib data (https://bibdata.princeton.edu/availability?id= or mfhd=)
23
    # @param location [Hash] The hash for a bib data holding (https://bibdata.princeton.edu/locations/holding_locations)
24
    # @param patron [Patron] the patron information about the current user
25
    def initialize(bib:, holding: nil, item: nil, location: nil, patron:)
2✔
26
      @bib = bib
2,266✔
27
      @holding = holding
2,266✔
28
      # Item inherits from SimpleDelegator which requires at least one argument
29
      # The argument is the Object that SimpleDelegator will delegate to.
30
      @item = item.present? ? Item.new(item) : NullItem.new({})
2,266✔
31
      @location = location
2,266✔
32
      @services = []
2,266✔
33
      @patron = patron
2,266✔
34
      @call_number = @holding.holding_data['call_number_browse']
2,266✔
35
      @title = bib[:title_citation_display]&.first
2,266✔
36
      @illiad = Requests::Illiad.new(enum: item&.fetch(:enum, nil), chron: item&.fetch(:chron, nil), call_number:)
2,266✔
37
    end
38

39
    delegate :pick_up_location_code, :item_type, :enum_value, :cron_value, :item_data?,
2✔
40
             :temp_loc_other_than_resource_sharing?, :on_reserve?, :enumerated?, :item_type_non_circulate?, :partner_holding?,
41
             :id, :use_statement, :collection_code, :charged?, :status, :status_label, :barcode?, :barcode, :preservation_conservation?, to: :item
42

43
    delegate :annex?, :location_label, to: :location_object
2✔
44

45
    delegate :thesis?, to: :@holding
2✔
46

47
    delegate :numismatics?, to: :@holding
2✔
48

49
    # Reading Room Request
50
    def aeon?
2✔
51
      location_object.aeon? || (use_statement == 'Supervised Use')
19,743✔
52
    end
53

54
    def recap?
2✔
55
      return false unless location_valid?
24,774✔
56
      location_object.recap?
24,774✔
57
    end
58

59
    def recap_pf?
2✔
60
      return false unless recap?
6,109✔
61
      location_object.code == "firestone$pf"
1,224✔
62
    end
63

64
    def clancy_available?
2✔
65
      item_at_clancy? && clancy_item.available?
263✔
66
    end
67

68
    def recap_edd?
2✔
69
      return location[:recap_electronic_delivery_location] == true unless partner_holding?
799✔
70
      in_scsb_edd_collection? && !scsb_in_library_use?
85✔
71
    end
72

73
    def preservation?
2✔
74
      location_object.code == 'pres'
120✔
75
    end
76

77
    def circulates?
2✔
78
      item_type_non_circulate? == false && location[:circulates] == true
4,680✔
79
    end
80

81
    def location_code
2✔
82
      location_object.code
2✔
83
    end
84

85
    def always_requestable?
2✔
86
      location[:always_requestable] == true
154✔
87
    end
88

89
    def use_restriction?
2✔
90
      partner_holding? && use_statement.present?
510✔
91
    end
92

93
    def in_process?
2✔
94
      return false if !item? || partner_holding?
9,938✔
95
      in_process_statuses.include?(item[:status_label])
9,677✔
96
    end
97

98
    def on_order?
2✔
99
      return false unless item? && !partner_holding?
8,185✔
100
      item[:status_label] == 'Acquisition'
7,968✔
101
    end
102

103
    def item?
2✔
104
      item.present?
20,715✔
105
    end
106

107
    def pending?
2✔
108
      return false unless location_valid?
134✔
109
      return false unless on_order? || in_process? || preservation?
134✔
110
      location[:library][:code] != 'recap' || location[:holding_library].present?
14✔
111
    end
112

113
    def ill_eligible?
2✔
114
      services.include?('ill')
1,345✔
115
    end
116

117
    def on_shelf?
2✔
118
      services.include?('on_shelf')
549✔
119
    end
120

121
    # assume numeric ids come from alma
122
    def alma_managed?
2✔
123
      bib[:id].to_i.positive?
9,516✔
124
    end
125

126
    def pick_up_locations
2✔
127
      return nil if location[:delivery_locations].empty?
217✔
128
      if partner_holding?
206✔
129
        scsb_pick_up_override(item[:collection_code])
11✔
130
      else
131
        location[:delivery_locations]
195✔
132
      end
133
    end
134

135
    # override the default delivery location for SCSB at certain collection codes
136
    def scsb_pick_up_override(collection_code)
2✔
137
      if ['AR', 'FL'].include? collection_code
11✔
138
        [Requests::BibdataService.delivery_locations[:PJ]]
2✔
139
      elsif collection_code == 'MR'
9✔
140
        [Requests::BibdataService.delivery_locations[:PK]]
3✔
141
      else
142
        location[:delivery_locations]
6✔
143
      end
144
    end
145

146
    def scsb_in_library_use?
2✔
147
      return false unless item?
2,075✔
148
      partner_holding? && (item[:use_statement] == "In Library Use" || collection_code == 'FL')
2,059✔
149
    end
150

151
    def holding_library_in_library_only?
2✔
152
      return false unless location["holding_library"]
760✔
153
      ["marquand", "lewis"].include?(holding_library) || recap_pf?
33✔
154
    end
155

156
    def holding_library
2✔
157
      location_object.holding_library&.dig(:code) || library_code
999✔
158
    end
159

160
    def ask_me?
2✔
UNCOV
161
      services.include?('ask_me')
×
162
    end
163

164
    def item_location_code
2✔
165
      item&.location || location_object.code
515✔
166
    end
167

168
    def held_at_marquand_library?
2✔
169
      library_code == 'marquand' && !recap?
18,995✔
170
    end
171

172
    def marquand_item?
2✔
173
      holding_library == 'marquand'
346✔
174
    end
175

176
    def clancy_item
2✔
177
      @clancy_item ||= Requests::ClancyItem.new(barcode:)
35✔
178
    end
179

180
    def item_at_clancy?
2✔
181
      held_at_marquand_library? && clancy_item.at_clancy?
8,402✔
182
    end
183

184
    def available?
2✔
185
      (always_requestable? && !held_at_marquand_library?) || item.available?
154✔
186
    end
187

188
    def cul_avery?
2✔
189
      item&.collection_code == 'AR'
117✔
190
    end
191

192
    def cul_music?
2✔
193
      item&.collection_code == 'MR'
35✔
194
    end
195

196
    def hl_art?
2✔
197
      item&.collection_code == 'FL'
24✔
198
    end
199

200
    def replace_existing_services(new_services)
2✔
201
      @services = new_services
2,263✔
202
    end
203

204
    private
2✔
205

206
      # Location data presented as an object, rather than a hash.
207
      # The goal is to gradually replace all uses of the hash with
208
      # this object, so that other classes don't need to know the
209
      # exact hash keys to use in order to get the needed data.
210
      def location_object
2✔
211
        @location_object ||= Location.new location
96,629✔
212
      end
213

214
      delegate :library_code, to: :location_object
2✔
215

216
      def in_scsb_edd_collection?
2✔
217
        scsb_edd_collection_codes =
218
          %w[AR BR CA CH CJ CP CR CU EN EV GC GE GS HS JC JD LD LE ML SW UT NA NH NL NP NQ NS NW GN JN JO PA PB PN GP JP] +
85✔
219
          %w[AH DL FL GUT HB HC HJ HK HL HS HW HY MCZ ML TZ WL] # Harvard collections available to digitize
220
        scsb_edd_collection_codes.include?(collection_code)
85✔
221
      end
222

223
      def location_valid?
2✔
224
        location_object.valid?
24,908✔
225
      end
226

227
      def in_process_statuses
2✔
228
        ["Acquisition technical services", "Acquisitions and Cataloging", "In Process"]
9,677✔
229
      end
230
  end
231
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