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

pulibrary / orangelight / 0e37073d-109c-440c-949f-49d2aa86311b

18 Aug 2025 09:05PM UTC coverage: 0.482% (-94.9%) from 95.343%
0e37073d-109c-440c-949f-49d2aa86311b

push

circleci

web-flow
Replace per_page_options_for_select with custom component to avoid deprecation issue (#5186)

* Start creating new component to address deprecaton warning

* Replace per_page_options_for_select with custom component to avoid deprecation issue

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

---------

Co-authored-by: Ryan Jensen <rj1044@princeton.edu>
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

0 of 33 new or added lines in 1 file covered. (0.0%)

9374 existing lines in 213 files now uncovered.

47 of 9753 relevant lines covered (0.48%)

0.01 hits per line

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

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

UNCOV
15
    delegate :illiad_request_url, :illiad_request_parameters, to: :@illiad
×
UNCOV
16
    delegate :eligible_for_library_services?, to: :@patron
×
17

UNCOV
18
    include Requests::Aeon
×
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 [Requests::Item] A Requests::Item or similar object (e.g. NullItem)
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
UNCOV
25
    def initialize(bib:, holding: nil, item:, location: nil, patron:)
×
UNCOV
26
      @bib = bib
×
UNCOV
27
      @holding = holding
×
UNCOV
28
      @item = item
×
UNCOV
29
      @location = location
×
UNCOV
30
      @services = []
×
UNCOV
31
      @patron = patron
×
UNCOV
32
      @call_number = @holding.holding_data['call_number_browse']
×
UNCOV
33
      @title = bib[:title_citation_display]&.first
×
UNCOV
34
      @illiad = Requests::Illiad.new(enum: item&.fetch(:enum, nil), chron: item&.fetch(:chron, nil), call_number:)
×
UNCOV
35
    end
×
36

UNCOV
37
    delegate :pick_up_location_code, :item_type, :enum_value, :cron_value, :item_data?,
×
UNCOV
38
             :temp_loc_other_than_resource_sharing?, :on_reserve?, :enumerated?, :item_type_non_circulate?, :partner_holding?,
×
UNCOV
39
             :id, :use_statement, :collection_code, :charged?, :status, :status_label, :barcode?, :barcode, :preservation_conservation?, to: :item
×
40

UNCOV
41
    delegate :annex?, :location_label, to: :location_object
×
42

UNCOV
43
    delegate :thesis?, to: :@holding
×
44

UNCOV
45
    delegate :numismatics?, to: :@holding
×
46

47
    # Reading Room Request
UNCOV
48
    def aeon?
×
UNCOV
49
      location_object.aeon? || (use_statement == 'Supervised Use')
×
UNCOV
50
    end
×
51

UNCOV
52
    def recap?
×
UNCOV
53
      return false unless location_valid?
×
UNCOV
54
      location_object.recap?
×
UNCOV
55
    end
×
56

UNCOV
57
    def recap_pf?
×
UNCOV
58
      return false unless recap?
×
UNCOV
59
      location_object.code == "firestone$pf"
×
UNCOV
60
    end
×
61

UNCOV
62
    def clancy_available?
×
UNCOV
63
      item_at_clancy? && clancy_item.available?
×
UNCOV
64
    end
×
65

UNCOV
66
    def recap_edd?
×
UNCOV
67
      return location[:recap_electronic_delivery_location] == true unless partner_holding?
×
UNCOV
68
      in_scsb_edd_collection? && !scsb_in_library_use?
×
UNCOV
69
    end
×
70

UNCOV
71
    def preservation?
×
UNCOV
72
      location_object.code == 'pres'
×
UNCOV
73
    end
×
74

UNCOV
75
    def circulates?
×
UNCOV
76
      item_type_non_circulate? == false && location[:circulates] == true
×
UNCOV
77
    end
×
78

UNCOV
79
    def location_code
×
UNCOV
80
      location_object.code
×
UNCOV
81
    end
×
82

UNCOV
83
    def always_requestable?
×
UNCOV
84
      location[:always_requestable] == true
×
UNCOV
85
    end
×
86

UNCOV
87
    def use_restriction?
×
UNCOV
88
      partner_holding? && use_statement.present?
×
UNCOV
89
    end
×
90

UNCOV
91
    def in_process?
×
UNCOV
92
      return false if !item? || partner_holding?
×
UNCOV
93
      in_process_statuses.include?(item[:status_label])
×
UNCOV
94
    end
×
95

UNCOV
96
    def on_order?
×
UNCOV
97
      return false unless item? && !partner_holding?
×
UNCOV
98
      item[:status_label] == 'Acquisition'
×
UNCOV
99
    end
×
100

UNCOV
101
    def item?
×
UNCOV
102
      item.present?
×
UNCOV
103
    end
×
104

UNCOV
105
    def pending?
×
UNCOV
106
      return false unless location_valid?
×
UNCOV
107
      return false unless on_order? || in_process? || preservation?
×
UNCOV
108
      location[:library][:code] != 'recap' || location[:holding_library].present?
×
UNCOV
109
    end
×
110

UNCOV
111
    def ill_eligible?
×
UNCOV
112
      services.include?('ill')
×
UNCOV
113
    end
×
114

UNCOV
115
    def on_shelf?
×
UNCOV
116
      services.include?('on_shelf')
×
UNCOV
117
    end
×
118

119
    # assume numeric ids come from alma
UNCOV
120
    def alma_managed?
×
UNCOV
121
      bib[:id].to_i.positive?
×
UNCOV
122
    end
×
123

UNCOV
124
    def pick_up_locations
×
UNCOV
125
      return nil if location[:delivery_locations].empty?
×
UNCOV
126
      if partner_holding?
×
UNCOV
127
        scsb_pick_up_override(item[:collection_code])
×
UNCOV
128
      else
×
UNCOV
129
        location[:delivery_locations]
×
UNCOV
130
      end
×
UNCOV
131
    end
×
132

133
    # override the default delivery location for SCSB at certain collection codes
UNCOV
134
    def scsb_pick_up_override(collection_code)
×
UNCOV
135
      if ['AR', 'FL'].include? collection_code
×
UNCOV
136
        [Requests::BibdataService.delivery_locations[:PJ]]
×
UNCOV
137
      elsif collection_code == 'MR'
×
UNCOV
138
        [Requests::BibdataService.delivery_locations[:PK]]
×
UNCOV
139
      else
×
UNCOV
140
        location[:delivery_locations]
×
UNCOV
141
      end
×
UNCOV
142
    end
×
143

UNCOV
144
    def scsb_in_library_use?
×
UNCOV
145
      return false unless item?
×
UNCOV
146
      partner_holding? && (item[:use_statement] == "In Library Use" || collection_code == 'FL')
×
UNCOV
147
    end
×
148

UNCOV
149
    def holding_library_in_library_only?
×
UNCOV
150
      return false unless location["holding_library"]
×
UNCOV
151
      ["marquand", "lewis"].include?(holding_library) || recap_pf?
×
UNCOV
152
    end
×
153

UNCOV
154
    def holding_library
×
UNCOV
155
      location_object.holding_library&.dig(:code) || library_code
×
UNCOV
156
    end
×
157

UNCOV
158
    def ask_me?
×
UNCOV
159
      services.include?('ask_me')
×
UNCOV
160
    end
×
161

UNCOV
162
    def item_location_code
×
UNCOV
163
      item&.location || location_object.code
×
UNCOV
164
    end
×
165

UNCOV
166
    def held_at_marquand_library?
×
UNCOV
167
      library_code == 'marquand' && !recap?
×
UNCOV
168
    end
×
169

UNCOV
170
    def marquand_item?
×
UNCOV
171
      holding_library == 'marquand'
×
UNCOV
172
    end
×
173

UNCOV
174
    def clancy_item
×
UNCOV
175
      @clancy_item ||= Requests::ClancyItem.new(barcode:)
×
UNCOV
176
    end
×
177

UNCOV
178
    def item_at_clancy?
×
UNCOV
179
      held_at_marquand_library? && clancy_item.at_clancy?
×
UNCOV
180
    end
×
181

UNCOV
182
    def available?
×
UNCOV
183
      (always_requestable? && !held_at_marquand_library?) || item.available?
×
UNCOV
184
    end
×
185

UNCOV
186
    def cul_avery?
×
UNCOV
187
      item&.collection_code == 'AR'
×
UNCOV
188
    end
×
189

UNCOV
190
    def cul_music?
×
UNCOV
191
      item&.collection_code == 'MR'
×
UNCOV
192
    end
×
193

UNCOV
194
    def hl_art?
×
UNCOV
195
      item&.collection_code == 'FL'
×
UNCOV
196
    end
×
197

UNCOV
198
    def replace_existing_services(new_services)
×
UNCOV
199
      @services = new_services
×
UNCOV
200
    end
×
201

UNCOV
202
    private
×
203

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

UNCOV
212
      delegate :library_code, to: :location_object
×
213

UNCOV
214
      def in_scsb_edd_collection?
×
UNCOV
215
        scsb_edd_collection_codes =
×
UNCOV
216
          %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] +
×
UNCOV
217
          %w[AH DL FL GUT HB HC HJ HK HL HS HW HY MCZ ML TZ WL] # Harvard collections available to digitize
×
UNCOV
218
        scsb_edd_collection_codes.include?(collection_code)
×
UNCOV
219
      end
×
220

UNCOV
221
      def location_valid?
×
UNCOV
222
        location_object.valid?
×
UNCOV
223
      end
×
224

UNCOV
225
      def in_process_statuses
×
UNCOV
226
        ["Acquisition technical services", "Acquisitions and Cataloging", "In Process"]
×
UNCOV
227
      end
×
UNCOV
228
  end
×
UNCOV
229
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