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

UNCOV
5
class AccountController < ApplicationController
×
UNCOV
6
  include ApplicationHelper
×
7

UNCOV
8
  before_action :read_only_redirect, except: [:user_id]
×
UNCOV
9
  before_action :check_for_authentication_provider, except: [:user_id]
×
UNCOV
10
  before_action :verify_user, except: [:user_id]
×
11

UNCOV
12
  def index
×
UNCOV
13
    redirect_to digitization_requests_path
×
UNCOV
14
  end
×
15

UNCOV
16
  def digitization_requests
×
UNCOV
17
    set_patron
×
UNCOV
18
  end
×
19

UNCOV
20
  def cancel_ill_requests
×
UNCOV
21
    set_patron
×
UNCOV
22
    response = Orangelight::IlliadPatronClient.new(@patron).cancel_ill_requests(params[:cancel_requests]) unless params[:cancel_requests].nil?
×
UNCOV
23
    illiad_patron_client(@patron)
×
UNCOV
24
    respond_to do |format|
×
UNCOV
25
      if params[:cancel_requests].nil?
×
UNCOV
26
        format.js { flash.now[:error] = I18n.t('blacklight.account.cancel_no_items') }
×
UNCOV
27
      elsif cancel_ill_success?(response)
×
UNCOV
28
        format.js { flash.now[:success] = I18n.t('blacklight.account.cancel_success') }
×
UNCOV
29
      else
×
UNCOV
30
        format.js { flash.now[:error] = I18n.t('blacklight.account.cancel_fail') }
×
UNCOV
31
      end
×
UNCOV
32
    end
×
UNCOV
33
  end
×
34

UNCOV
35
  def user_id
×
UNCOV
36
    render json: { user_id: current_user&.uid }
×
UNCOV
37
  end
×
38

UNCOV
39
  protected
×
40

UNCOV
41
    def read_only_redirect
×
UNCOV
42
      if Orangelight.read_only_mode
×
UNCOV
43
        flash[:notice] = 'Account login unavailable during maintenace.'
×
UNCOV
44
        redirect_to(root_url) && return
×
UNCOV
45
      end
×
UNCOV
46
    end
×
47

UNCOV
48
    def check_for_authentication_provider
×
UNCOV
49
      raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
×
UNCOV
50
    end
×
51

UNCOV
52
    def verify_user
×
UNCOV
53
      unless current_user
×
UNCOV
54
        flash[:error] = I18n.t('blacklight.saved_searches.need_login') &&
×
UNCOV
55
                        raise(Blacklight::Exceptions::AccessDenied)
×
UNCOV
56
      end
×
UNCOV
57
    end
×
58

59
    ## For local dev purposes hardcode a net id string in place of current_user.uid
60
    ## in this method. Hacky, but convienent to see what "real" data looks like for
61
    ## edge case patrons.
UNCOV
62
    def set_patron
×
UNCOV
63
      @netid = current_user.uid
×
UNCOV
64
      @patron = current_patron(current_user)
×
UNCOV
65
      illiad_patron_client(@patron)
×
UNCOV
66
    end
×
67

UNCOV
68
    def illiad_patron_client(patron)
×
UNCOV
69
      @illiad_transactions = []
×
UNCOV
70
      return unless patron && current_user.cas_provider?
×
71

UNCOV
72
      @illiad_account = Orangelight::IlliadAccount.new(patron)
×
UNCOV
73
      return unless @illiad_account.verify_user?
×
74

UNCOV
75
      @illiad_transactions = Orangelight::IlliadPatronClient.new(patron).outstanding_ill_requests
×
UNCOV
76
    end
×
77

UNCOV
78
    def cancel_ill_success?(response)
×
UNCOV
79
      bodies = response.map { |rep| JSON.parse(rep.body) }
×
UNCOV
80
      bodies.reject { |body| body['TransactionStatus'] =~ /^Cancelled/ }.empty?
×
UNCOV
81
    end
×
82

UNCOV
83
  private
×
84

UNCOV
85
    def current_patron(user)
×
UNCOV
86
      Bibdata.get_patron(user, ldap: false)
×
UNCOV
87
    end
×
UNCOV
88
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