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

tulibraries / tul_cob / ba55f8aa-172b-4015-b85d-8d7c3ef2641c

06 Oct 2023 02:24PM UTC coverage: 84.734% (-0.06%) from 84.791%
ba55f8aa-172b-4015-b85d-8d7c3ef2641c

push

circleci

web-flow
Merge pull request #3991 from tulibraries/update-dockerfile

Update package in Dockerfile

2964 of 3498 relevant lines covered (84.73%)

55.08 hits per line

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

38.89
/app/controllers/users_controller.rb
1
# frozen_string_literal: true
2

3
class UsersController < ApplicationController
1✔
4
  include JsonLogger
1✔
5
  include QuikPay
1✔
6

7
  rescue_from ActionView::Template::Error,
1✔
8
    with: :no_account_found
9

10
  def account
1✔
11
    no_cache
6✔
12
    @user = current_user
6✔
13
    if @user.uid.nil?
6✔
14
      flash[:error] = "It may take a few days for your library account to be created. If you have questions about this please call 215-204-0744."
×
15
      redirect_to root_path
×
16
    else
17
      # Add total fines and other info to session so that we do not need to make extra call to Alma.
18
      session["total_fines"] = current_user.alma.total_fines
6✔
19
      session["can_pay_online?"] = current_user.can_pay_online?
6✔
20
    end
21
  end
22

23
  def holds
1✔
24
    holds = current_user.holds
2✔
25
    if holds.success?
2✔
26
      render partial: "users/holds_details", layout: nil, locals: { holds: holds }
2✔
27
    else
28
      render "Problem!"
×
29
    end
30
  end
31

32
  def fines
1✔
33
    fines = current_user.fines
×
34
    if fines.success?
×
35
      render partial: "users/fines_details", layout: nil, locals: { fines: fines }
×
36
    else
37
      render "Problem!"
×
38
    end
39
  end
40

41
  def loans
1✔
42
    loans = current_user.loans
×
43
    if loans.success?
×
44
      render partial: "users/loans_details", layout: nil, locals: { loans: loans }
×
45
    else
46
      render "Problem!"
×
47
    end
48
  end
49

50
  def renew
1✔
51
    log = { type: "alma_user", uid: current_user.uid }
×
52
    lib_user = do_with_json_logger(log) { Alma::User.find(current_user.uid) }
×
53

54
    # Pass loan_id and loan status to view
55
    @loan_id = params[:loan_id]
×
56
    result = lib_user.renew_loan(@loan_id)
×
57
    @message = result.renewed? ? "RENEWED" : result.error_message
×
58

59
    respond_to do |format|
×
60
      format.js
×
61
    end
62
  end
63

64
  def renew_selected
1✔
65
    if params[:loan_ids].nil?
×
66
      redirect_to(users_account_path) && return
×
67
    else
68
      renew_results = current_user.renew_selected(params[:loan_ids])
×
69
      @renew_responses = multiple_renew_responses(renew_results, params[:loan_ids])
×
70
      logger.info "RENEWAL STATUS:"
×
71
      logger.info ap(@renew_responses)
×
72
    end
73
  end
74

75
  def renew_response(result, loan_id)
1✔
76
    {
77
      loan_id:  loan_id,
×
78
      renewed:  result.renewed?,
79
      title:    result.item_title,
80
      due_date: result.due_date,
81
      message:  result.has_error? ? result.error_message : result.message
×
82
    }
83
  end
84

85
  def multiple_renew_responses(renew_results, loan_id_list)
1✔
86
    renew_results.map.with_index do |r, i|
×
87
      logger.debug "Multi Renewed: #{r.has_error? ? r.error_message : r.message}"
×
88
      renew_response(r, loan_id_list[i])
×
89
    end
90
  end
91

92
  def no_account_found(exception)
1✔
93
    error_code = JSON.parse(exception.message)
×
94
      .dig("errorList", "error")
95
      .first.fetch("errorCode", "") rescue nil
96

97
    Honeybadger.notify(exception.message) if error_code == "60101"
×
98
    flash[:notice] = "Your user account was not found."
×
99
    render "errors/internal_server_error"
×
100
  end
101
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

© 2026 Coveralls, Inc