diff --git a/app/models/user.rb b/app/models/user.rb index 7bfdd16cf..cfdea7500 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -14,9 +14,7 @@ class User < ApplicationRecord include Blacklight::User # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable - devise :database_authenticatable, :invitable, :registerable, - :recoverable, :rememberable, :trackable, :validatable, - :omniauthable, omniauth_providers: %i[saml openid_connect cas] + devise(*Hyku::Application.user_devise_parameters) after_create :add_default_group_membership! diff --git a/config/application.rb b/config/application.rb index 40f2c32f2..3af68f13f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -41,6 +41,21 @@ class Application < Rails::Application # The title to render for the application's HTML > HEAD > TITLE element. # @return [String] class_attribute :html_head_title, default: "Hyku", attr_accessor: false + + # @!attribute user_devise_parameters + # @return [Object] + # + # This is a value that you want to set in the before_initialize block. + class_attribute :user_devise_parameters, instance_accessor: false, default: [ + :database_authenticatable, + :invitable, + :registerable, + :recoverable, + :rememberable, + :trackable, + :validatable, + :omniauthable, { omniauth_providers: %i[saml openid_connect cas] }] + # @!endgroup Class Attributes # Add this line to load the lib folder first because we need diff --git a/spec/config/application_spec.rb b/spec/config/application_spec.rb index 35ce1619b..a3ab79038 100644 --- a/spec/config/application_spec.rb +++ b/spec/config/application_spec.rb @@ -4,6 +4,24 @@ RSpec.describe Hyku::Application do describe '.html_head_title' do + subject { described_class.html_head_title } + it { is_expected.to be_a(String) } end + + describe '.user_devise_parameters' do + subject { described_class.user_devise_parameters } + + it do + is_expected.to eq([:database_authenticatable, + :invitable, + :registerable, + :recoverable, + :rememberable, + :trackable, + :validatable, + :omniauthable, + { omniauth_providers: %i[saml openid_connect cas] }]) + end + end end