Skip to content

Commit 37bb2eb

Browse files
authored
Merge pull request #158 from MITLibraries/filter-bugfix
Render filter value names in non-GDT contexts
2 parents 643614b + bcf832b commit 37bb2eb

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

app/views/search/_filter.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
<a href="<%= results_path(add_filter(@enhanced_query, category, term['key'])) %>">
1616
<span class="sr">Apply filter:</span>
1717
<% end %>
18-
<% if Flipflop.enabled?(:gdt) %>
19-
<span class="name"><%= gdt_sources(term['key'], category) %></span>
20-
<% end %>
18+
<% if Flipflop.enabled?(:gdt) %>
19+
<span class="name"><%= gdt_sources(term['key'], category) %></span>
20+
<% else %>
21+
<span class="name"><%= term['key'] %></span>
22+
<% end %>
2123
<span class="count"><%= term['docCount'] %> <span class="sr">records</span></span>
2224
</a>
2325
</li>

test/controllers/search_controller_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
139139
end
140140
end
141141

142+
test 'a filter category lists available filters with names and values' do
143+
VCR.use_cassette('data basic controller',
144+
allow_playback_repeats: true,
145+
match_requests_on: %i[method uri body]) do
146+
get '/results?q=data'
147+
assert_response :success
148+
assert_select '.filter-options .category-terms .name', { minimum: 1 }
149+
assert_select '.filter-options .category-terms .count', { minimum: 1 }
150+
end
151+
end
152+
142153
test 'results with valid query has div for pagination' do
143154
VCR.use_cassette('data basic controller',
144155
allow_playback_repeats: true,

0 commit comments

Comments
 (0)