• 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/illiad_patron.rb
1
# frozen_string_literal: true
UNCOV
2
require './lib/orangelight/illiad_patron_client'
×
UNCOV
3
require './lib/orangelight/illiad_account'
×
4

UNCOV
5
module Requests
×
6
  # Creates patron for Illiad requests
UNCOV
7
  class IlliadPatron < IlliadClient
×
UNCOV
8
    attr_reader :netid, :patron_id, :patron, :attributes
×
9

UNCOV
10
    def initialize(patron)
×
UNCOV
11
      super()
×
UNCOV
12
      @patron = patron
×
UNCOV
13
      @patron_id = patron.patron_id
×
UNCOV
14
      @netid = patron.netid
×
UNCOV
15
      @attributes = illiad_patron_attributes
×
UNCOV
16
    end
×
17

UNCOV
18
    def illiad_patron
×
UNCOV
19
      get_json_response
×
UNCOV
20
    end
×
21

UNCOV
22
    def create_illiad_patron
×
UNCOV
23
      return nil if patron.blank?
×
24

UNCOV
25
      patron_response = post_json_response(url: 'ILLiadWebPlatform/Users', body: attributes.to_json)
×
UNCOV
26
      patron_response = illiad_patron if patron_response.blank? && error.dig("ModelState", "UserName") == ["Username #{netid} already exists."]
×
UNCOV
27
      patron_response
×
UNCOV
28
    end
×
29

UNCOV
30
    private
×
31

UNCOV
32
      def illiad_patron_attributes
×
UNCOV
33
        return {} if status.blank?
×
UNCOV
34
        return {} if illiad_status.blank?
×
UNCOV
35
        {
×
UNCOV
36
          "Username" => netid, "ExternalUserId" => netid, "FirstName" => patron.first_name,
×
UNCOV
37
          "LastName" => patron.last_name, "LoanDeliveryMethod" => "Hold for Pickup", "NotificationMethod" => "Electronic",
×
UNCOV
38
          "EmailAddress" => patron.active_email, "DeliveryMethod" => "Hold for Pickup",
×
UNCOV
39
          "Phone" => patron.telephone, "Status" => illiad_status, "Number" => patron.university_id,
×
UNCOV
40
          "AuthType" => "Default", "NVTGC" => "ILL", "Department" => department, "Web" => true,
×
UNCOV
41
          "Address" => addresses&.shift, "Address2" => addresses&.join(', '), "City" => "Princeton", "State" => "NJ",
×
UNCOV
42
          "Zip" => "08544", "SSN" => patron.barcode, "Cleared" => "Yes", "Site" => "Firestone"
×
UNCOV
43
        }
×
UNCOV
44
      end
×
45

UNCOV
46
      def addresses
×
UNCOV
47
        @addresses ||= patron.address&.split('$')
×
UNCOV
48
      end
×
49

UNCOV
50
      def status
×
UNCOV
51
        patron.status
×
UNCOV
52
      end
×
53

UNCOV
54
      def pustatus
×
UNCOV
55
        patron.pustatus
×
UNCOV
56
      end
×
57

UNCOV
58
      def title
×
UNCOV
59
        patron.title
×
UNCOV
60
      end
×
61

UNCOV
62
      def department
×
UNCOV
63
        patron.department
×
UNCOV
64
      end
×
65

UNCOV
66
      def illiad_status
×
UNCOV
67
        return nil if pustatus.blank? || pustatus[0] == 'x'
×
68

UNCOV
69
        if status == "staff"
×
UNCOV
70
          illiad_staff_status
×
UNCOV
71
        elsif status == "student"
×
UNCOV
72
          student_mappings = { "gradetdc" => "GS - Graduate Student", "undergraduate" => "U - Undergraduate", "graduate" => "GS - Graduate Student" }
×
UNCOV
73
          student_mappings[pustatus]
×
UNCOV
74
        elsif status == "faculty"
×
UNCOV
75
          if title.present? && title.include?("Visiting")
×
76
            "F - Visiting Faculty"
×
UNCOV
77
          else
×
UNCOV
78
            "F - Faculty"
×
UNCOV
79
          end
×
UNCOV
80
        end
×
UNCOV
81
      end
×
82

UNCOV
83
      def illiad_staff_status
×
UNCOV
84
        if department.present? && department.include?("Library")
×
85
          "GS - Library Staff"
×
UNCOV
86
        elsif title.present?
×
UNCOV
87
          illiad_staff_title_status(ldap_title: patron.title)
×
UNCOV
88
        else
×
UNCOV
89
          "GS - University Staff"
×
UNCOV
90
        end
×
UNCOV
91
      end
×
92

UNCOV
93
      def illiad_staff_title_status(ldap_title:)
×
UNCOV
94
        if ldap_title.include?("Visiting Research")
×
95
          "GS - Visiting Research Scholar"
×
UNCOV
96
        elsif title.include?("Senior Research Scholar")
×
UNCOV
97
          "F - Senior Research Scholar"
×
98
        elsif title.include?("Research Scholar")
×
99
          "F - Research Scholar"
×
100
        elsif title.include?("Senior Professional")
×
101
          "F - Senior Professional Specialist"
×
102
        elsif title.match?(/Post*doc*Reseach*/i)
×
103
          "GS - Post doc Research Associate"
×
104
        elsif title.match?(/Post*doc*Fellow*/i)
×
105
          "F - Postdoctoral Fellow -- Teaching"
×
106
        elsif title.match?(/Visit*Fellow*/i)
×
107
          "GS - Visiting Fellow"
×
UNCOV
108
        else
×
109
          "GS - University Staff"
×
UNCOV
110
        end
×
UNCOV
111
      end
×
UNCOV
112
  end
×
UNCOV
113
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