diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2a9e283e2a..4e4ec7b83d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -108,7 +108,7 @@ Metrics/MethodLength: # Offense count: 9 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 208 + Max: 211 Exclude: - 'lib/blacklight/solr/search_builder_behavior.rb' diff --git a/app/controllers/concerns/blacklight/catalog.rb b/app/controllers/concerns/blacklight/catalog.rb index 06ade55038..be839dd498 100644 --- a/app/controllers/concerns/blacklight/catalog.rb +++ b/app/controllers/concerns/blacklight/catalog.rb @@ -9,7 +9,9 @@ module Blacklight::Catalog # The following code is executed when someone includes blacklight::catalog in their # own controller. included do - helper_method :sms_mappings, :has_search_parameters? + if respond_to? :helper_method + helper_method :sms_mappings, :has_search_parameters? + end helper Blacklight::Facet diff --git a/app/controllers/concerns/blacklight/controller.rb b/app/controllers/concerns/blacklight/controller.rb index cb9e4f567a..e01e8eca89 100644 --- a/app/controllers/concerns/blacklight/controller.rb +++ b/app/controllers/concerns/blacklight/controller.rb @@ -14,17 +14,20 @@ module Blacklight::Controller # now in application.rb file under config.filter_parameters # filter_parameter_logging :password, :password_confirmation - helper_method :current_user_session, :current_user, :current_or_guest_user after_action :discard_flash_if_xhr # handle basic authorization exception with #access_denied rescue_from Blacklight::Exceptions::AccessDenied, :with => :access_denied - # extra head content - helper_method :has_user_authentication_provider? - helper_method :blacklight_config, :blacklight_configuration_context - helper_method :search_action_url, :search_action_path, :search_facet_url, :search_facet_path - helper_method :search_state + if respond_to? :helper_method + helper_method :current_user_session, :current_user, :current_or_guest_user + + # extra head content + helper_method :has_user_authentication_provider? + helper_method :blacklight_config, :blacklight_configuration_context + helper_method :search_action_url, :search_action_path, :search_facet_path + helper_method :search_state + end # Specify which class to use for the search state. You can subclass SearchState if you # want to override any of the methods (e.g. SearchState#url_for_document) diff --git a/app/controllers/concerns/blacklight/search_context.rb b/app/controllers/concerns/blacklight/search_context.rb index 6d9a4d79f8..9c4ba7dd4a 100644 --- a/app/controllers/concerns/blacklight/search_context.rb +++ b/app/controllers/concerns/blacklight/search_context.rb @@ -2,10 +2,12 @@ module Blacklight::SearchContext extend ActiveSupport::Concern - # The following code is executed when someone includes blacklight::catalog::search_session in their + # The following code is executed when someone includes Blacklight::Catalog::SearchSession in their # own controller. - included do - helper_method :current_search_session, :search_session + included do + if respond_to? :helper_method + helper_method :current_search_session, :search_session + end end module ClassMethods diff --git a/app/controllers/concerns/blacklight/token_based_user.rb b/app/controllers/concerns/blacklight/token_based_user.rb index 7b73edc984..93e757ac3b 100644 --- a/app/controllers/concerns/blacklight/token_based_user.rb +++ b/app/controllers/concerns/blacklight/token_based_user.rb @@ -3,7 +3,9 @@ module Blacklight::TokenBasedUser extend ActiveSupport::Concern included do - helper_method :encrypt_user_id + if respond_to? :helper_method + helper_method :encrypt_user_id + end rescue_from Blacklight::Exceptions::ExpiredSessionToken do head :unauthorized