This repository has been archived by the owner on May 1, 2023. It is now read-only.
forked from NCSU-Libraries/quick_search
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LIBSEARCH-155. Pass Best Bet keywords through "filter_query" method
When loading the Best Bet keywords, pass them through the "filter_query" method in the "QuickSearch::QueryFilter" concern, so that they will be matched with a query term passed through the same method. This takes care of things like a dash (hyphen) being removed from the query term. The implementation was somewhat complicated by the fact that the "filter_query" method is a private method on a Rails Concern. This was handled by creating a helper class in the initializer that delegates to the concern. It is not clear if this is the best way to accomplish this, but it does appear to work. https://issues.umd.edu/browse/LIBSEARCH-155
- Loading branch information
1 parent
bc379b3
commit d7e25d4
Showing
5 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'test_helper' | ||
|
||
class BestBestInitializerTest < ActionDispatch::IntegrationTest | ||
test 'best bet keyword with dash should be found' do | ||
# Clear the solr_url so we don't try to get Best Bet from Solr | ||
QuickSearch::Engine::APP_CONFIG['best_bets']['solr_url'] = '' | ||
|
||
# Keyword for "testbestbet" entry in test/dummy/config/best_bets.yml | ||
visit xhr_search_path(q: '123-456', endpoint: 'best_bets', format: 'json') | ||
|
||
json = JSON.parse(page.html) | ||
first_result = json['results'][0] | ||
assert_equal 'testbestbet', first_result['id'] | ||
end | ||
end |