• 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/selected_items_validator.rb
1
# frozen_string_literal: true
2

UNCOV
3
module Requests
×
UNCOV
4
  class SelectedItemsValidator < ActiveModel::Validator
×
UNCOV
5
    def mail_services
×
UNCOV
6
      ["paging", "pres", "annex", "on_order", "in_process", "ppl", "lewis", "on_shelf", "annex_in_library"]
×
UNCOV
7
    end
×
8

UNCOV
9
    def validate(record)
×
UNCOV
10
      record.errors.add(:items, { "empty_set" => { 'text' => 'Please Select an Item to Request!', 'type' => 'options' } }) unless record.items.size >= 1 && !record.items.any? { |item| defined? item.selected }
×
UNCOV
11
      record.items.each do |selected|
×
UNCOV
12
        validate_selected(record, selected)
×
UNCOV
13
      end
×
UNCOV
14
    end
×
15

UNCOV
16
    private
×
17

UNCOV
18
      def validate_selected(record, selected)
×
UNCOV
19
        return unless selected['selected'] == 'true'
×
UNCOV
20
        case selected["type"]
×
UNCOV
21
        when 'digitize', 'digitize_fill_in', 'annex_edd', 'marquand_edd', 'clancy_edd', "clancy_unavailable_edd"
×
UNCOV
22
          validate_delivery_mode(record:, selected:)
×
UNCOV
23
        when 'ill'
×
UNCOV
24
          validate_ill_on_shelf(record, selected, pick_up_phrase: 'delivery of your borrow direct item', action_phrase: 'requested via Borrow Direct')
×
UNCOV
25
        when 'recap_no_items'
×
UNCOV
26
          validate_recap_no_items(record, selected)
×
UNCOV
27
        when 'recap', 'recap_edd', 'recap_in_library', 'clancy_in_library', 'marquand_in_library', 'recap_marquand_edd', 'recap_marquand_in_library'
×
UNCOV
28
          validate_offsite(record, selected)
×
UNCOV
29
        when 'on_shelf'
×
UNCOV
30
          validate_ill_on_shelf(record, selected)
×
UNCOV
31
        when *mail_services
×
UNCOV
32
          validate_pick_up_location(record, selected, selected["type"])
×
UNCOV
33
        else
×
UNCOV
34
          record.errors.add(:items, { selected['mfhd'] => { 'text' => 'Please choose a Request Method for your selected item.', 'type' => 'pick_up' } })
×
UNCOV
35
        end
×
UNCOV
36
      end
×
37

UNCOV
38
      def validate_ill_on_shelf(record, selected, pick_up_phrase: 'your selected item', action_phrase: 'Requested')
×
UNCOV
39
        return unless validate_item_id?(record:, selected:, action_phrase:)
×
UNCOV
40
        item_id = selected['item_id']
×
UNCOV
41
        return if selected['pick_up'].present?
×
42

43
        record.errors.add(:items, { item_id => { 'text' => "Please select a pick-up location for #{pick_up_phrase}", 'type' => 'pick_up' } })
×
UNCOV
44
      end
×
45

UNCOV
46
      def validate_pick_up_location(record, selected, type)
×
UNCOV
47
        return if selected['pick_up'].present?
×
UNCOV
48
        id = selected['item_id']
×
UNCOV
49
        id = selected['mfhd'] if id.blank?
×
50

UNCOV
51
        record.errors.add(:items, { id => { 'text' => "Please select a pick-up location for your selected #{type} item", 'type' => 'pick_up' } })
×
UNCOV
52
      end
×
53

UNCOV
54
      def validate_recap_no_items(record, selected)
×
UNCOV
55
        return if selected['pick_up'].present? || selected['edd_art_title'].present?
×
56

UNCOV
57
        record.errors.add(:items, { selected['mfhd'] => { 'text' => 'Please select a pick-up location for your selected ReCAP item', 'type' => 'pick_up' } })
×
UNCOV
58
      end
×
59

UNCOV
60
      def validate_offsite(record, selected)
×
UNCOV
61
        return unless validate_item_id?(record:, selected:, action_phrase: 'Requested from Off-site Facility')
×
UNCOV
62
        validate_delivery_mode(record:, selected:)
×
UNCOV
63
      end
×
64

UNCOV
65
      def validate_delivery_mode(record:, selected:)
×
UNCOV
66
        item_id = selected['item_id']
×
UNCOV
67
        if selected["delivery_mode_#{item_id}"].nil?
×
UNCOV
68
          record.errors.add(:items, { item_id => { 'text' => 'Please select a delivery type for your selected recap item', 'type' => 'options' } })
×
UNCOV
69
        else
×
UNCOV
70
          delivery_type = selected["delivery_mode_#{item_id}"]
×
UNCOV
71
          record.errors.add(:items, { item_id => { 'text' => 'Please select a pick-up location for your selected recap item', 'type' => 'pick_up' } }) if delivery_type == 'print' && selected['pick_up'].blank?
×
UNCOV
72
          if delivery_type == 'edd'
×
UNCOV
73
            record.errors.add(:items, { item_id => { 'text' => 'Please specify title for the selection you want digitized.', 'type' => 'options' } }) if selected['edd_art_title'].empty?
×
UNCOV
74
          end
×
UNCOV
75
        end
×
UNCOV
76
      end
×
77

UNCOV
78
      def validate_item_id?(record:, selected:, action_phrase:)
×
UNCOV
79
        return true if selected['item_id'].present?
×
80

81
        record.errors.add(:items, { selected['mfhd'] => { 'text' => "Item Cannot be #{action_phrase}, see circulation desk.", 'type' => 'options' } })
×
82
        false
×
UNCOV
83
      end
×
UNCOV
84
  end
×
UNCOV
85
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