• 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/user.rb
1
# frozen_string_literal: true
2

UNCOV
3
class User < ApplicationRecord
×
UNCOV
4
  validates :username, presence: true
×
5

6
  # Connects this user object to Blacklights Bookmarks.
UNCOV
7
  include Blacklight::User
×
8
  # Include default devise modules. Others available are:
9
  # :confirmable, :lockable, :timeoutable and :omniauthable
UNCOV
10
  devise :database_authenticatable, :rememberable,
×
UNCOV
11
         :trackable, :omniauthable
×
12

13
  # Method added by Blacklight; Blacklight uses #to_s on your
14
  # user class to get a user-displayable login/identifier for
15
  # the account.
16
  # @return [String] the user name
UNCOV
17
  def to_s
×
UNCOV
18
    username || 'User'
×
UNCOV
19
  end
×
20

21
  # Determines whether or not this is a user which is identifiable by alma
22
  # @return [TrueClass, FalseClass]
UNCOV
23
  def alma_provider?
×
UNCOV
24
    provider == 'alma'
×
UNCOV
25
  end
×
26

27
  # Determines whether or not this is a user which is identifiable by cas
28
  # @return [TrueClass, FalseClass]
UNCOV
29
  def cas_provider?
×
UNCOV
30
    provider == 'cas'
×
UNCOV
31
  end
×
32

33
  # Retrieves a user authenticated using the CAS
34
  # @param access_token []
35
  # @return [User,nil]
UNCOV
36
  def self.from_cas(access_token)
×
UNCOV
37
    access_token.uid = access_token.uid.downcase
×
UNCOV
38
    User.where(provider: access_token.provider, uid: access_token.uid).first_or_create do |user|
×
UNCOV
39
      user.uid = access_token.uid
×
UNCOV
40
      user.username = access_token.uid
×
UNCOV
41
      user.email = "#{access_token.uid}@princeton.edu"
×
UNCOV
42
      user.password = SecureRandom.urlsafe_base64
×
UNCOV
43
      user.provider = access_token.provider
×
UNCOV
44
    end
×
UNCOV
45
  end
×
46

47
  # Retrieves a user authenticated using an Alma account
48
  # @param access_token [] access token containing the barcode accessed using #uid
49
  # @return [User,nil]
UNCOV
50
  def self.from_alma(access_token)
×
UNCOV
51
    User.where(provider: access_token.provider, uid: access_token.uid).first_or_initialize do |user|
×
UNCOV
52
      user.uid = access_token.uid
×
UNCOV
53
      user.username = access_token.uid
×
UNCOV
54
      user.guest = false
×
UNCOV
55
      user.provider = access_token.provider
×
UNCOV
56
    end
×
UNCOV
57
  end
×
58

UNCOV
59
  def self.from_hash(user_hash)
×
60
    User.where(provider: user_hash['provider'], uid: user_hash['uid']).first
×
UNCOV
61
  end
×
62

63
  # Alternative to the implementation used in devise-guests, due to memory use
64
  # problems when running that task
65
  # https://github.com/cbeer/devise-guests/blob/7ab8c55d7a2b677ce61cc83486d6e3723d8795b2/lib/railties/devise_guests.rake
UNCOV
66
  def self.expire_guest_accounts
×
UNCOV
67
    User
×
UNCOV
68
      .where("guest = ? and updated_at < ?", true, Time.now.utc - 3.days)
×
UNCOV
69
      .find_each(batch_size: 25_000, &:destroy)
×
UNCOV
70
  end
×
71

UNCOV
72
  def admin?
×
UNCOV
73
    netids.include? uid
×
UNCOV
74
  end
×
75

UNCOV
76
  private
×
77

UNCOV
78
    def netids
×
UNCOV
79
      @netids ||= ENV['ORANGELIGHT_ADMIN_NETIDS']&.split(" ") || ""
×
UNCOV
80
    end
×
UNCOV
81
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