diff --git a/app/helpers/blacklight/catalog_helper_behavior.rb b/app/helpers/blacklight/catalog_helper_behavior.rb index f9b234178e..361e6b4b2c 100644 --- a/app/helpers/blacklight/catalog_helper_behavior.rb +++ b/app/helpers/blacklight/catalog_helper_behavior.rb @@ -206,6 +206,11 @@ def document_index_view_type query_params = params || {} end end + # Should we display special "home" splash screen content, instead of search results? + def display_splash_content? + !has_search_parameters? + end + private # @param [String] format diff --git a/app/views/catalog/index.html.erb b/app/views/catalog/index.html.erb index cd09b7d7c5..40998a2817 100644 --- a/app/views/catalog/index.html.erb +++ b/app/views/catalog/index.html.erb @@ -8,7 +8,7 @@ view_config: conf) %> <% end %> -<% unless has_search_parameters? %> +<% if display_splash_content? %> <%# if there are no input/search related params, display the "home" partial -%> <%= render 'home' %> <%= render 'shared/sitelinks_search_box' %> diff --git a/spec/views/catalog/index.html.erb_spec.rb b/spec/views/catalog/index.html.erb_spec.rb index 5fc046900f..fc0c7992f6 100644 --- a/spec/views/catalog/index.html.erb_spec.rb +++ b/spec/views/catalog/index.html.erb_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true RSpec.describe "catalog/index.html.erb" do - describe "with no search parameters" do + describe "with splash content (no search parameters)" do before do - allow(view).to receive(:has_search_parameters?).and_return(false) + allow(view).to receive(:display_splash_content?).and_return(true) allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config) @response = instance_double(Blacklight::Solr::Response, empty?: true, total: 11, start: 1, limit_value: 10, aggregations: {}) end @@ -17,9 +17,9 @@ end end - describe "with search parameters" do + describe "with results (search parameters)" do before do - allow(view).to receive(:has_search_parameters?).and_return(true) + allow(view).to receive(:display_splash_content?).and_return(false) stub_template "catalog/_results_pagination.html.erb" => "" stub_template "catalog/_search_header.html.erb" => "header_content" allow(view).to receive(:blacklight_config).and_return(Blacklight::Configuration.new)