• 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/location.rb
1
# frozen_string_literal: true
UNCOV
2
module Requests
×
3
  # This class is responsible for answering questions about
4
  # a location, based on data supplied from a bibdata hash
UNCOV
5
  class Location
×
6
    # @param bibdata_location [Hash] The hash for a bibdata holding (https://bibdata.princeton.edu/locations/holding_locations)
UNCOV
7
    def initialize(bibdata_location)
×
UNCOV
8
      @bibdata_location = bibdata_location.to_h.with_indifferent_access
×
UNCOV
9
    end
×
10

UNCOV
11
    def code
×
UNCOV
12
      return nil if bibdata_location.blank?
×
UNCOV
13
      bibdata_location['code']
×
UNCOV
14
    end
×
15

UNCOV
16
    def short_label
×
UNCOV
17
      bibdata_location["label"]
×
UNCOV
18
    end
×
19

UNCOV
20
    def location_label
×
UNCOV
21
      return nil unless library_data_present?
×
UNCOV
22
      label = library_label
×
UNCOV
23
      label += " - #{short_label}" if short_label.present?
×
UNCOV
24
      label
×
UNCOV
25
    end
×
26

UNCOV
27
    def library_code
×
UNCOV
28
      bibdata_location.dig('library', 'code')
×
UNCOV
29
    end
×
30

UNCOV
31
    def library_label
×
UNCOV
32
      bibdata_location.dig('library', 'label')
×
UNCOV
33
    end
×
34

UNCOV
35
    def valid?
×
UNCOV
36
      bibdata_location.key?(:library) && bibdata_location[:library].key?(:code)
×
UNCOV
37
    end
×
38

UNCOV
39
    def aeon?
×
UNCOV
40
      bibdata_location[:aeon_location] == true
×
UNCOV
41
    end
×
42

UNCOV
43
    def annex?
×
UNCOV
44
      valid? && library_code == 'annex'
×
UNCOV
45
    end
×
46

UNCOV
47
    def circulates?
×
48
      bibdata_location[:circulates] == true
×
UNCOV
49
    end
×
50

UNCOV
51
    def always_requestable?
×
52
      bibdata_location[:always_requestable] == true
×
UNCOV
53
    end
×
54

UNCOV
55
    def holding_library
×
UNCOV
56
      bibdata_location[:holding_library]
×
UNCOV
57
    end
×
58

UNCOV
59
    def delivery_locations
×
UNCOV
60
      bibdata_location[:delivery_locations] || []
×
UNCOV
61
    end
×
62

UNCOV
63
    def to_h
×
UNCOV
64
      bibdata_location
×
UNCOV
65
    end
×
66

UNCOV
67
    def recap?
×
UNCOV
68
      bibdata_location[:remote_storage] == "recap_rmt"
×
UNCOV
69
    end
×
70

71
    ## Accepts an array of location hashes and sorts them according to our quirks
UNCOV
72
    def sort_pick_ups
×
73
      # staff only locations go at the bottom of the list and Firestone to the top
74

UNCOV
75
      public_delivery_locations = delivery_locations.select { |loc| loc[:staff_only] == false }
×
UNCOV
76
      public_delivery_locations.sort_by! { |loc| loc[:label] }
×
77

UNCOV
78
      firestone = public_delivery_locations.find { |loc| loc[:label] == "Firestone Library" }
×
UNCOV
79
      public_delivery_locations.insert(0, public_delivery_locations.delete_at(public_delivery_locations.index(firestone))) unless firestone.nil?
×
80

UNCOV
81
      staff_delivery_locations = delivery_locations.select { |loc| loc[:staff_only] == true }
×
UNCOV
82
      staff_delivery_locations.sort_by! { |loc| loc[:label] }
×
83

UNCOV
84
      staff_delivery_locations.each do |loc|
×
UNCOV
85
        loc[:label] = loc[:label] + " (Staff Only)"
×
UNCOV
86
      end
×
UNCOV
87
      public_delivery_locations + staff_delivery_locations
×
UNCOV
88
    end
×
89

UNCOV
90
    def build_delivery_locations
×
UNCOV
91
      delivery_locations.map do |loc|
×
UNCOV
92
        library = loc["library"]
×
UNCOV
93
        pick_up_code = library.present? && library["code"]
×
UNCOV
94
        pick_up_code ||= 'firestone'
×
UNCOV
95
        loc.merge("pick_up_location_code" => pick_up_code) { |_key, v1, _v2| v1 }
×
UNCOV
96
      end
×
UNCOV
97
    end
×
98

UNCOV
99
      private
×
100

UNCOV
101
        def library_data_present?
×
UNCOV
102
          bibdata_location["library"].present?
×
UNCOV
103
        end
×
104

UNCOV
105
        attr_reader :bibdata_location
×
UNCOV
106
  end
×
UNCOV
107
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