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

pulibrary / orangelight / d973573e-9a44-478e-9952-901d9a0e6df1

10 Nov 2025 09:45PM UTC coverage: 95.247% (-0.2%) from 95.41%
d973573e-9a44-478e-9952-901d9a0e6df1

push

circleci

web-flow
Annex requests with no items should email forranx@princeton.edu (#5339)

* Add new confirmation and email templates when
there are no annex items - add new RequestMailer methods to
support the templates
email this case to forranx@princeton.edu

Update request_mailer_preview.rb
 * remove stale and unused methods
 * parsing of location label
Update mock data in request_mailer_preview.rb spec

related to [#4183]

* Update the hidden_service_options_fill_in with a new check for annex_no_items service
Update the submittable services to include annex_no_items
Include annex_no_items where needed by the code
Add new annex abstract method and subclasses for digitize , noitems and pickup
Pass patron as an argument in the new annex services
Update items validator with annex_no_items

Add a new condition in categorize_by_delivery_and_location method
that checks for an item type of annex_no_items && edd?
to set the item type to annex_edd (Illiad request)

related to [#4183]

* when annex no item service is used the patron should
receive a confirmation email
with the annex confirmation subject

related to [#4183]

50 of 63 new or added lines in 8 files covered. (79.37%)

1 existing line in 1 file now uncovered.

6232 of 6543 relevant lines covered (95.25%)

1448.52 hits per line

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

88.24
/app/models/requests/selected_items_validator.rb
1
# frozen_string_literal: true
2

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

9
    def validate(record)
3✔
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 }
194✔
11
      record.items.each do |selected|
83✔
12
        validate_selected(record, selected)
111✔
13
      end
14
    end
15

16
    private
3✔
17

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

40
      def validate_ill_on_shelf(record, selected, pick_up_phrase: 'your selected item', action_phrase: 'Requested')
3✔
41
        return unless validate_item_id?(record:, selected:, action_phrase:)
9✔
42
        item_id = selected['item_id']
9✔
43
        return if selected['pick_up'].present?
9✔
44

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

48
      def validate_pick_up_location(record, selected, type)
3✔
49
        return if selected['pick_up'].present?
22✔
50
        id = selected['item_id']
8✔
51
        id = selected['mfhd'] if id.blank?
8✔
52

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

56
      def validate_recap_no_items(record, selected)
3✔
57
        return if selected['pick_up'].present? || selected['edd_art_title'].present?
5✔
58

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

62
      # :reek:UtilityFunction
63
      def validate_annex_no_items(record, selected)
3✔
NEW
64
        return if selected['pick_up'].present? || selected['edd_art_title'].present?
×
65

NEW
66
        record.errors.add(:items, { selected['mfhd'] => { 'text' => 'Please select a pick-up location for your selected Annex item', 'type' => 'pick_up' } })
×
67
      end
68

69
      def validate_offsite(record, selected)
3✔
70
        return unless validate_item_id?(record:, selected:, action_phrase: 'Requested from Off-site Facility')
36✔
71
        validate_delivery_mode(record:, selected:)
36✔
72
      end
73

74
      def validate_delivery_mode(record:, selected:)
3✔
75
        item_id = selected['item_id']
41✔
76
        if selected["delivery_mode_#{item_id}"].nil?
41✔
77
          record.errors.add(:items, { item_id => { 'text' => 'Please select a delivery type for your selected recap item', 'type' => 'options' } })
11✔
78
        else
79
          delivery_type = selected["delivery_mode_#{item_id}"]
30✔
80
          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?
30✔
81
          if delivery_type == 'edd'
30✔
82
            record.errors.add(:items, { item_id => { 'text' => 'Please specify title for the selection you want digitized.', 'type' => 'options' } }) if selected['edd_art_title'].empty?
17✔
83
          end
84
        end
85
      end
86

87
      def validate_item_id?(record:, selected:, action_phrase:)
3✔
88
        return true if selected['item_id'].present?
45✔
89

90
        record.errors.add(:items, { selected['mfhd'] => { 'text' => "Item Cannot be #{action_phrase}, see circulation desk.", 'type' => 'options' } })
×
91
        false
×
92
      end
93
  end
94
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