Skip to content

Commit dc5ffc3

Browse files
authored
Merge pull request #293 from MITLibraries/use-183-tab-descriptions
Adds tab descriptions
2 parents 420c50e + e9d524f commit dc5ffc3

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

app/helpers/results_helper.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,26 @@ module ResultsHelper
22
def results_summary(hits)
33
hits.to_i >= 10_000 ? '10,000+ results' : "#{number_with_delimiter(hits)} results"
44
end
5+
6+
# Provides a description for the current tab in search results.
7+
def tab_description
8+
case params[:tab]
9+
when 'all'
10+
'All MIT Libraries sources'
11+
when 'cdi'
12+
'Journal and newspaper articles, book chapters, and more'
13+
when 'alma', 'timdex_alma'
14+
'Books, journals, streaming and physical media, and more'
15+
when 'primo'
16+
'Articles, books, chapters, streaming and physical media, and more'
17+
when 'aspace'
18+
'Archives, manuscripts, and other unique materials related to MIT'
19+
when 'timdex'
20+
'Digital collections, images, documents, and more from MIT Libraries'
21+
when 'website'
22+
'Information about the library: events, news, services, and more'
23+
else
24+
Rails.logger.error "Unknown tab parameter in `tab_description` helper: #{params[:tab]}"
25+
end
26+
end
527
end

app/views/search/results.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<% elsif @results.present? && @errors.blank? %>
2020

2121
<h2 class="results-context"><%= results_summary(@pagination[:hits]) %></h2>
22-
<p class="results-context-description">From all MIT Libraries sources</p>
22+
<p class="results-context-description"><%= tab_description %></p>
2323
<div id="results-layout-wrapper">
2424
<main id="results">
2525
<ol class="results-list use" start="<%= @pagination[:start] %>">

test/controllers/search_controller_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ def source_filter_count(controller)
715715
assert_response :success
716716
assert_select '.results-context', text: /10 results/
717717
assert_select '.results-context-description', count: 1
718-
assert_select '.results-context-description', text: /From all MIT Libraries sources/
718+
assert_select '.results-context-description',
719+
text: /Articles, books, chapters, streaming and physical media, and more/
719720
end
720721

721722
test 'primo results shows continuation partial when page exceeds API offset limit' do

test/helpers/results_helper_test.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,38 @@ class ResultsHelperTest < ActionView::TestCase
1717
hits = 9000
1818
assert_equal '9,000 results', results_summary(hits)
1919
end
20+
21+
test 'result helper handles tab descriptions for tabs based on params hash' do
22+
params[:tab] = 'all'
23+
description = 'All MIT Libraries sources'
24+
assert_equal description, tab_description
25+
26+
params[:tab] = 'cdi'
27+
description = 'Journal and newspaper articles, book chapters, and more'
28+
assert_equal description, tab_description
29+
30+
params[:tab] = 'alma'
31+
description = 'Books, journals, streaming and physical media, and more'
32+
assert_equal description, tab_description
33+
34+
params[:tab] = 'timdex_alma'
35+
description = 'Books, journals, streaming and physical media, and more'
36+
assert_equal description, tab_description
37+
38+
params[:tab] = 'primo'
39+
description = 'Articles, books, chapters, streaming and physical media, and more'
40+
assert_equal description, tab_description
41+
42+
params[:tab] = 'aspace'
43+
description = 'Archives, manuscripts, and other unique materials related to MIT'
44+
assert_equal description, tab_description
45+
46+
params[:tab] = 'timdex'
47+
description = 'Digital collections, images, documents, and more from MIT Libraries'
48+
assert_equal description, tab_description
49+
50+
params[:tab] = 'website'
51+
description = 'Information about the library: events, news, services, and more'
52+
assert_equal description, tab_description
53+
end
2054
end

0 commit comments

Comments
 (0)