• 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/submissions/hold_item.rb
1
# frozen_string_literal: true
UNCOV
2
require 'faraday'
×
3

UNCOV
4
module Requests::Submissions
×
UNCOV
5
  class HoldItem < Service
×
UNCOV
6
    attr_accessor :duplicate
×
7

UNCOV
8
    def initialize(submission, service_type: 'on_shelf')
×
UNCOV
9
      super
×
UNCOV
10
      @duplicate = false
×
UNCOV
11
    end
×
12

13
    # rubocop:disable Naming/PredicateMethod
UNCOV
14
    def handle
×
UNCOV
15
      items = submission.filter_items_by_service(service_type)
×
UNCOV
16
      items.each do |item|
×
UNCOV
17
        item_status = handle_item(item:)
×
UNCOV
18
        @sent << item_status if item_status.present?
×
UNCOV
19
      end
×
UNCOV
20
      return false if @errors.present?
×
UNCOV
21
    end
×
22
    # rubocop:enable Naming/PredicateMethod
23

UNCOV
24
    def duplicate?
×
UNCOV
25
      duplicate
×
UNCOV
26
    end
×
27

UNCOV
28
    def handle_item(item:)
×
UNCOV
29
      status = {}
×
UNCOV
30
      begin
×
UNCOV
31
        status = if item["user_supplied_enum"].present?
×
UNCOV
32
                   item # Alma can not create the correct hold.  This assumes the correct emails will go out during send_mail
×
UNCOV
33
                 else
×
UNCOV
34
                   place_hold(item)
×
UNCOV
35
                 end
×
UNCOV
36
      rescue Alma::BibRequest::ItemAlreadyExists
×
UNCOV
37
        status = item.merge(payload: payload(item), response: "DuplicateRequest")
×
UNCOV
38
        @duplicate = true
×
UNCOV
39
      rescue StandardError => invalid
×
UNCOV
40
        errors << { reply_text: "Can not create hold", create_hold: { note: "Hold can not be created", message: invalid.message } }.merge(submission.bib.to_h).merge(item.to_h).with_indifferent_access
×
UNCOV
41
      end
×
UNCOV
42
      status
×
UNCOV
43
    end
×
44

UNCOV
45
    def success_message
×
UNCOV
46
      if duplicate?
×
UNCOV
47
        I18n.t("requests.submit.duplicate")
×
UNCOV
48
      else
×
UNCOV
49
        I18n.t("requests.submit.#{service_type}_success", default: I18n.t('requests.submit.success'))
×
UNCOV
50
      end
×
UNCOV
51
    end
×
52

UNCOV
53
    def send_mail
×
UNCOV
54
      return if duplicate?
×
UNCOV
55
      super
×
UNCOV
56
    end
×
57

UNCOV
58
    private
×
59

UNCOV
60
      def place_hold(item)
×
UNCOV
61
        status = {}
×
UNCOV
62
        options = payload(item)
×
UNCOV
63
        response = Alma::ItemRequest.submit(options)
×
UNCOV
64
        if response.success?
×
UNCOV
65
          status = item.merge(payload: options, response: response.raw_response.parsed_response)
×
UNCOV
66
        else
×
67
          errors << reponse_json["response"].merge(submission.bib.to_h).merge(item.to_h).merge(type: service_type)
×
UNCOV
68
        end
×
UNCOV
69
        status
×
UNCOV
70
      end
×
71

UNCOV
72
      def payload(item)
×
UNCOV
73
        pick_up_library = if item["pick_up_location_code"] == "annex"
×
74
                            "firestone"
×
UNCOV
75
                          else
×
UNCOV
76
                            item["pick_up_location_code"]
×
UNCOV
77
                          end
×
78

UNCOV
79
        { mms_id: submission.bib['id'], holding_id: item["mfhd"], item_pid: item['item_id'], user_id: submission.patron.university_id, request_type: "HOLD", pickup_location_type: "LIBRARY", pickup_location_library: pick_up_library }
×
UNCOV
80
      end
×
UNCOV
81
  end
×
UNCOV
82
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