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

UNCOV
4
module Requests
×
UNCOV
5
  class ClancyItem
×
UNCOV
6
    attr_reader :clancy_conn, :api_key, :barcode, :errors
×
7

UNCOV
8
    def initialize(barcode: nil, connection: Faraday.new(url: Requests.config[:clancy_base]))
×
UNCOV
9
      @clancy_conn = connection
×
UNCOV
10
      @api_key = Requests.config[:clancy_api_key]
×
UNCOV
11
      @barcode = barcode
×
UNCOV
12
      @errors = []
×
UNCOV
13
    end
×
14

UNCOV
15
    def status
×
UNCOV
16
      @status ||= load_clancy_status
×
UNCOV
17
    end
×
18

UNCOV
19
    def not_at_clancy?
×
UNCOV
20
      return true unless status["success"]
×
UNCOV
21
      "Item not Found" == status["status"] || status["status"].include?("Deaccessioned")
×
UNCOV
22
    end
×
23

UNCOV
24
    def at_clancy?
×
UNCOV
25
      !not_at_clancy?
×
UNCOV
26
    end
×
27

UNCOV
28
    def available?
×
UNCOV
29
      return false unless status["success"]
×
UNCOV
30
      ["Item In at Rest"].include?(status["status"]) # assuming there may be more than one available statuses
×
UNCOV
31
    end
×
32

UNCOV
33
    def request?(hold_id:, patron:, location: 'MQ')
×
UNCOV
34
      response = request_item(hold_id:, patron:, location:)
×
UNCOV
35
      return false unless response["success"]
×
36

UNCOV
37
      request_response = response["results"].first
×
UNCOV
38
      if request_response["deny"] == "N"
×
UNCOV
39
        true
×
UNCOV
40
      else
×
UNCOV
41
        errors << request_response["istatus"]
×
UNCOV
42
        false
×
UNCOV
43
      end
×
UNCOV
44
    end
×
45

UNCOV
46
    private
×
47

UNCOV
48
      def load_clancy_status
×
UNCOV
49
        return empty_status if barcode.blank?
×
50

UNCOV
51
        response = get_clancy(url: "itemstatus/v1/#{barcode}")
×
UNCOV
52
        if response.success?
×
UNCOV
53
          JSON.parse(response.body)
×
UNCOV
54
        else
×
UNCOV
55
          errors << "Error connecting with Clancy: #{response.status}"
×
UNCOV
56
          empty_status
×
UNCOV
57
        end
×
UNCOV
58
      end
×
59

UNCOV
60
      def get_clancy(url:)
×
UNCOV
61
        clancy_conn.get do |req|
×
UNCOV
62
          req.url url
×
UNCOV
63
          req.headers['Content-Type'] = 'application/json'
×
UNCOV
64
          req.headers['Accept'] = 'application/json'
×
UNCOV
65
          req.headers['X-API-Key'] = api_key
×
UNCOV
66
        end
×
UNCOV
67
      end
×
68

UNCOV
69
      def post_clancy(url:, body:)
×
UNCOV
70
        clancy_conn.post do |req|
×
UNCOV
71
          req.url url
×
UNCOV
72
          req.headers['Content-Type'] = 'application/json'
×
UNCOV
73
          req.headers['Accept'] = 'application/json'
×
UNCOV
74
          req.headers['X-API-Key'] = api_key
×
UNCOV
75
          req.body = body
×
UNCOV
76
        end
×
UNCOV
77
      end
×
78

UNCOV
79
      def empty_status
×
UNCOV
80
        { "success" => false }
×
UNCOV
81
      end
×
82

UNCOV
83
      def request_item(location:, hold_id:, patron:, request_type: "PYR")
×
UNCOV
84
        body = { "requests": [{ "request_id": hold_id, "request_type": request_type, "barcode": barcode, "stop": location, "requestor": "#{patron.first_name} #{patron.last_name}", "patron_id": patron.university_id }] }
×
UNCOV
85
        response = post_clancy(url: "circrequests/v1", body: body.to_json)
×
UNCOV
86
        if response.success?
×
UNCOV
87
          JSON.parse(response.body)
×
UNCOV
88
        else
×
UNCOV
89
          errors << "Error connecting with Clancy: #{response.status}"
×
UNCOV
90
          empty_status
×
UNCOV
91
        end
×
UNCOV
92
      end
×
UNCOV
93
  end
×
UNCOV
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