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

pulibrary / orangelight / 0394d607-2d0c-48c6-9ace-c8163c3efbf1

06 Sep 2023 09:28PM UTC coverage: 95.384% (-0.02%) from 95.401%
0394d607-2d0c-48c6-9ace-c8163c3efbf1

push

circleci

web-flow
Finish aeon deprecation (#3712)

* Expect load balancer to forward requests

* Remove deprecated aeon base

4 of 4 new or added lines in 3 files covered. (100.0%)

1 existing line in 1 file now uncovered.

5579 of 5849 relevant lines covered (95.38%)

1415.95 hits per line

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

98.04
/app/controllers/account_controller.rb
1
# frozen_string_literal: true
2
require './lib/orangelight/illiad_patron_client.rb'
2✔
3
require './lib/orangelight/illiad_account.rb'
2✔
4

5
class AccountController < ApplicationController
2✔
6
  include ApplicationHelper
2✔
7

8
  before_action :read_only_redirect, except: [:redirect_to_alma, :user_id]
2✔
9
  before_action :check_for_authentication_provider, except: [:redirect_to_alma, :user_id]
2✔
10
  before_action :verify_user, except: [:redirect_to_alma, :user_id]
2✔
11

12
  def index
2✔
13
    redirect_to digitization_requests_path
1✔
14
  end
15

16
  def digitization_requests
2✔
17
    set_patron
5✔
18
  end
19

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

35
  def redirect_to_alma
2✔
36
    render "redirect_to_alma"
3✔
37
  end
38

39
  def user_id
2✔
UNCOV
40
    render json: { user_id: current_user&.uid }
×
41
  end
42

43
  protected
2✔
44

45
    def read_only_redirect
2✔
46
      if Orangelight.read_only_mode
11✔
47
        flash[:notice] = 'Account login unavailable during maintenace.'
1✔
48
        redirect_to(root_url) && return
1✔
49
      end
50
    end
51

52
    def check_for_authentication_provider
2✔
53
      raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
10✔
54
    end
55

56
    def verify_user
2✔
57
      unless current_user
10✔
58
        flash[:error] = I18n.t('blacklight.saved_searches.need_login') &&
1✔
59
                        raise(Blacklight::Exceptions::AccessDenied)
60
      end
61
    end
62

63
    ## For local dev purposes hardcode a net id string in place of current_user.uid
64
    ## in this method. Hacky, but convienent to see what "real" data looks like for
65
    ## edge case patrons.
66
    def set_patron
2✔
67
      @netid = current_user.uid
8✔
68
      @patron = current_patron(current_user)
8✔
69
      illiad_patron_client(@patron)
8✔
70
    end
71

72
    def illiad_patron_client(patron)
2✔
73
      @illiad_transactions = []
11✔
74
      return unless patron && current_user.cas_provider?
11✔
75

76
      @illiad_account = IlliadAccount.new(patron)
9✔
77
      return unless @illiad_account.verify_user
9✔
78

79
      @illiad_transactions = IlliadPatronClient.new(patron).outstanding_ill_requests
8✔
80
    end
81

82
    def cancel_ill_success(response)
2✔
83
      bodies = response.map { |rep| JSON.parse(rep.body) }
4✔
84
      bodies.reject { |body| body['TransactionStatus'] =~ /^Cancelled/ }.empty?
4✔
85
    end
86

87
  private
2✔
88

89
    def current_patron(user)
2✔
90
      Bibdata.get_patron(user)
12✔
91
    end
92
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