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

pulibrary / orangelight / 4e01fe00-694b-47b4-8b30-2de4dc4acc66

31 Jul 2025 07:56PM UTC coverage: 92.891% (-2.5%) from 95.4%
4e01fe00-694b-47b4-8b30-2de4dc4acc66

Pull #4962

circleci

web-flow
Merge pull request #5130 from pulibrary/clean_up_scss_comments

Remove SCSS commented code.
Pull Request #4962: Orangelight pos workcycle 07-07-2025

193 of 197 new or added lines in 24 files covered. (97.97%)

161 existing lines in 35 files now uncovered.

5932 of 6386 relevant lines covered (92.89%)

1443.08 hits per line

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

71.43
/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: [:user_id]
2✔
9
  before_action :check_for_authentication_provider, except: [:user_id]
2✔
10
  before_action :verify_user, except: [: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
1✔
18
  end
19

20
  def cancel_ill_requests
2✔
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') }
×
29
      else
UNCOV
30
        format.js { flash.now[:error] = I18n.t('blacklight.account.cancel_fail') }
×
31
      end
32
    end
33
  end
34

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

39
  protected
2✔
40

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

48
    def check_for_authentication_provider
2✔
49
      raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
3✔
50
    end
51

52
    def verify_user
2✔
53
      unless current_user
3✔
54
        flash[:error] = I18n.t('blacklight.saved_searches.need_login') &&
1✔
55
                        raise(Blacklight::Exceptions::AccessDenied)
56
      end
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.
62
    def set_patron
2✔
63
      @netid = current_user.uid
1✔
64
      @patron = current_patron(current_user)
1✔
65
      illiad_patron_client(@patron)
1✔
66
    end
67

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

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

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

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

83
  private
2✔
84

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