|
14 | 14 | let(:default_searchable_attributes) { ['*'] } |
15 | 15 | let(:default_displayed_attributes) { ['*'] } |
16 | 16 | let(:default_pagination) { { maxTotalHits: 1000 } } |
| 17 | + let(:default_proximity_precision) { 'byWord' } |
17 | 18 | let(:settings_keys) do |
18 | 19 | [ |
19 | 20 | 'rankingRules', |
|
29 | 30 | 'pagination', |
30 | 31 | 'dictionary', |
31 | 32 | 'nonSeparatorTokens', |
32 | | - 'separatorTokens' |
| 33 | + 'separatorTokens', |
| 34 | + 'proximityPrecision' |
33 | 35 | ] |
34 | 36 | end |
35 | 37 | let(:uid) { random_uid } |
|
52 | 54 | expect(settings['pagination'].transform_keys(&:to_sym)).to eq(default_pagination) |
53 | 55 | expect(settings['filterableAttributes']).to eq([]) |
54 | 56 | expect(settings['sortableAttributes']).to eq([]) |
| 57 | + expect(settings['proximityPrecision']).to eq(default_proximity_precision) |
55 | 58 | end |
56 | 59 |
|
57 | 60 | it 'updates multiples settings at the same time' do |
|
85 | 88 | ranking_rules: ['title:asc', 'typo'], |
86 | 89 | distinct_attribute: 'title', |
87 | 90 | stop_words: ['the', 'a'], |
88 | | - synonyms: { wow: ['world of warcraft'] } |
| 91 | + synonyms: { wow: ['world of warcraft'] }, |
| 92 | + proximity_precision: 'byAttribute' |
89 | 93 | ) |
90 | 94 | client.wait_for_task(task['taskUid']) |
91 | 95 |
|
|
99 | 103 | expect(settings['distinctAttribute']).to be_nil |
100 | 104 | expect(settings['stopWords']).to be_empty |
101 | 105 | expect(settings['synonyms']).to be_empty |
| 106 | + expect(settings['proximityPrecision']).to eq(default_proximity_precision) |
102 | 107 | end |
103 | 108 | end |
104 | 109 |
|
@@ -880,5 +885,28 @@ def update_synonyms(index, synonyms) |
880 | 885 | expect(index.non_separator_tokens).to be_empty |
881 | 886 | end |
882 | 887 | end |
| 888 | + |
| 889 | + describe '#proximity_precision' do |
| 890 | + it 'has byWord as default value' do |
| 891 | + expect(index.proximity_precision).to eq('byWord') |
| 892 | + end |
| 893 | + |
| 894 | + it 'updates proximity precision' do |
| 895 | + update_task = index.update_proximity_precision('byAttribute') |
| 896 | + client.wait_for_task(update_task['taskUid']) |
| 897 | + |
| 898 | + expect(index.proximity_precision).to eq('byAttribute') |
| 899 | + end |
| 900 | + |
| 901 | + it 'resets proximity precision' do |
| 902 | + update_task = index.update_proximity_precision('byAttribute') |
| 903 | + client.wait_for_task(update_task['taskUid']) |
| 904 | + |
| 905 | + reset_task = index.reset_proximity_precision |
| 906 | + client.wait_for_task(reset_task['taskUid']) |
| 907 | + |
| 908 | + expect(index.proximity_precision).to eq('byWord') |
| 909 | + end |
| 910 | + end |
883 | 911 | end |
884 | 912 | end |
0 commit comments