Commit c6bc6dfa534f355616937ae52931ff05f2938c7b
1 parent
a387fbdd
Exists in
master
and in
8 other branches
Added better test for reloadable synonyms [skip ci]
Showing
1 changed file
with
23 additions
and
0 deletions
Show diff stats
test/search_synonyms_test.rb
... | ... | @@ -70,6 +70,29 @@ class SearchSynonymsTest < Minitest::Test |
70 | 70 | end |
71 | 71 | end |
72 | 72 | |
73 | + def test_reload_synonyms_better | |
74 | + skip unless ENV["ES_PATH"] && !Searchkick.server_below?("7.3.0") | |
75 | + | |
76 | + write_synonyms("test,hello") | |
77 | + | |
78 | + with_options(Speaker, search_synonyms: "synonyms.txt") do | |
79 | + store_names ["Hello", "Goodbye"] | |
80 | + assert_search "test", ["Hello"] | |
81 | + | |
82 | + write_synonyms("test,goodbye") | |
83 | + assert_search "test", ["Hello"] | |
84 | + | |
85 | + Speaker.search_index.reload_synonyms | |
86 | + assert_search "test", ["Goodbye"] | |
87 | + end | |
88 | + ensure | |
89 | + Speaker.reindex | |
90 | + end | |
91 | + | |
92 | + def write_synonyms(contents) | |
93 | + File.write("#{ENV.fetch("ES_PATH")}/config/synonyms.txt", contents) | |
94 | + end | |
95 | + | |
73 | 96 | def default_model |
74 | 97 | Speaker |
75 | 98 | end | ... | ... |