diff --git a/app/helpers/results_helper.rb b/app/helpers/results_helper.rb
index 85b4860d..2a32a5a2 100644
--- a/app/helpers/results_helper.rb
+++ b/app/helpers/results_helper.rb
@@ -2,4 +2,26 @@ module ResultsHelper
def results_summary(hits)
hits.to_i >= 10_000 ? '10,000+ results' : "#{number_with_delimiter(hits)} results"
end
+
+ # Provides a description for the current tab in search results.
+ def tab_description
+ case params[:tab]
+ when 'all'
+ 'All MIT Libraries sources'
+ when 'cdi'
+ 'Journal and newspaper articles, book chapters, and more'
+ when 'alma', 'timdex_alma'
+ 'Books, journals, streaming and physical media, and more'
+ when 'primo'
+ 'Articles, books, chapters, streaming and physical media, and more'
+ when 'aspace'
+ 'Archives, manuscripts, and other unique materials related to MIT'
+ when 'timdex'
+ 'Digital collections, images, documents, and more from MIT Libraries'
+ when 'website'
+ 'Information about the library: events, news, services, and more'
+ else
+ Rails.logger.error "Unknown tab parameter in `tab_description` helper: #{params[:tab]}"
+ end
+ end
end
diff --git a/app/views/search/results.html.erb b/app/views/search/results.html.erb
index 9d3a2a65..d0d7b457 100644
--- a/app/views/search/results.html.erb
+++ b/app/views/search/results.html.erb
@@ -19,7 +19,7 @@
<% elsif @results.present? && @errors.blank? %>
<%= results_summary(@pagination[:hits]) %>
- From all MIT Libraries sources
+ <%= tab_description %>
diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb
index aa60242a..f040a644 100644
--- a/test/controllers/search_controller_test.rb
+++ b/test/controllers/search_controller_test.rb
@@ -715,7 +715,8 @@ def source_filter_count(controller)
assert_response :success
assert_select '.results-context', text: /10 results/
assert_select '.results-context-description', count: 1
- assert_select '.results-context-description', text: /From all MIT Libraries sources/
+ assert_select '.results-context-description',
+ text: /Articles, books, chapters, streaming and physical media, and more/
end
test 'primo results shows continuation partial when page exceeds API offset limit' do
diff --git a/test/helpers/results_helper_test.rb b/test/helpers/results_helper_test.rb
index d3df676b..2f60bc08 100644
--- a/test/helpers/results_helper_test.rb
+++ b/test/helpers/results_helper_test.rb
@@ -17,4 +17,38 @@ class ResultsHelperTest < ActionView::TestCase
hits = 9000
assert_equal '9,000 results', results_summary(hits)
end
+
+ test 'result helper handles tab descriptions for tabs based on params hash' do
+ params[:tab] = 'all'
+ description = 'All MIT Libraries sources'
+ assert_equal description, tab_description
+
+ params[:tab] = 'cdi'
+ description = 'Journal and newspaper articles, book chapters, and more'
+ assert_equal description, tab_description
+
+ params[:tab] = 'alma'
+ description = 'Books, journals, streaming and physical media, and more'
+ assert_equal description, tab_description
+
+ params[:tab] = 'timdex_alma'
+ description = 'Books, journals, streaming and physical media, and more'
+ assert_equal description, tab_description
+
+ params[:tab] = 'primo'
+ description = 'Articles, books, chapters, streaming and physical media, and more'
+ assert_equal description, tab_description
+
+ params[:tab] = 'aspace'
+ description = 'Archives, manuscripts, and other unique materials related to MIT'
+ assert_equal description, tab_description
+
+ params[:tab] = 'timdex'
+ description = 'Digital collections, images, documents, and more from MIT Libraries'
+ assert_equal description, tab_description
+
+ params[:tab] = 'website'
+ description = 'Information about the library: events, news, services, and more'
+ assert_equal description, tab_description
+ end
end