|
16 | 16 | 'exactness' |
17 | 17 | ] |
18 | 18 | end |
| 19 | + let(:default_searchable_attributes) { ['*'] } |
| 20 | + let(:default_displayed_attributes) { ['*'] } |
19 | 21 |
|
20 | 22 | let(:settings_keys) do |
21 | 23 | [ |
|
25 | 27 | 'displayedAttributes', |
26 | 28 | 'stopWords', |
27 | 29 | 'synonyms', |
28 | | - 'acceptNewFields', |
29 | 30 | 'attributesForFaceting' |
30 | 31 | ] |
31 | 32 | end |
|
46 | 47 | expect(response.keys).to contain_exactly(*settings_keys) |
47 | 48 | expect(response['rankingRules']).to eq(default_ranking_rules) |
48 | 49 | expect(response['distinctAttribute']).to be_nil |
49 | | - expect(response['searchableAttributes']).to eq([]) |
50 | | - expect(response['displayedAttributes']).to eq([]) |
| 50 | + expect(response['searchableAttributes']).to eq(default_searchable_attributes) |
| 51 | + expect(response['displayedAttributes']).to eq(default_displayed_attributes) |
51 | 52 | expect(response['stopWords']).to eq([]) |
52 | 53 | expect(response['synonyms']).to eq({}) |
53 | | - expect(response['acceptNewFields']).to be_truthy |
54 | 54 | end |
55 | 55 |
|
56 | 56 | it 'updates multiples settings at the same time' do |
|
171 | 171 |
|
172 | 172 | it 'gets default values of searchable attributes' do |
173 | 173 | response = index.searchable_attributes |
174 | | - expect(response).to be_a(Array) |
175 | | - expect(response).to be_empty |
| 174 | + expect(response).to eq(default_searchable_attributes) |
176 | 175 | end |
177 | 176 |
|
178 | 177 | it 'updates searchable attributes' do |
|
187 | 186 | expect(response).to have_key('updateId') |
188 | 187 | sleep(0.1) |
189 | 188 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
| 189 | + expect(index.searchable_attributes).to eq(default_searchable_attributes) |
190 | 190 | end |
191 | 191 | end |
192 | 192 |
|
|
203 | 203 |
|
204 | 204 | it 'gets default values of displayed attributes' do |
205 | 205 | response = index.displayed_attributes |
206 | | - expect(response).to be_a(Array) |
207 | | - expect(response).to be_empty |
| 206 | + expect(response).to eq(default_displayed_attributes) |
208 | 207 | end |
209 | 208 |
|
210 | 209 | it 'updates displayed attributes' do |
|
219 | 218 | expect(response).to have_key('updateId') |
220 | 219 | sleep(0.1) |
221 | 220 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
222 | | - end |
223 | | - end |
224 | | - |
225 | | - context 'On accept-new-fields sub-routes' do |
226 | | - before(:all) do |
227 | | - @uid = SecureRandom.hex(4) |
228 | | - @client.create_index(@uid) |
229 | | - end |
230 | | - |
231 | | - after(:all) { clear_all_indexes(@client) } |
232 | | - |
233 | | - let(:index) { @client.index(@uid) } |
234 | | - |
235 | | - it 'gets default values of acceptNewFields' do |
236 | | - expect(index.accept_new_fields).to be_truthy |
237 | | - end |
238 | | - |
239 | | - it 'adds searchable or display attributes when truthy' do |
240 | | - index.update_searchable_attributes(['title', 'description']) |
241 | | - sleep(0.1) |
242 | | - index.update_displayed_attributes(['title', 'description']) |
243 | | - sleep(0.1) |
244 | | - index.add_documents(id: 1, title: 'Test', comment: 'comment test') |
245 | | - sleep(0.1) |
246 | | - sa = index.searchable_attributes |
247 | | - da = index.displayed_attributes |
248 | | - expect(sa).to contain_exactly('id', 'title', 'description', 'comment') |
249 | | - expect(da).to contain_exactly('id', 'title', 'description', 'comment') |
250 | | - index.update_searchable_attributes([]) |
251 | | - sleep(0.1) |
252 | | - index.update_displayed_attributes([]) |
253 | | - sleep(0.1) |
254 | | - index.delete_all_documents |
255 | | - sleep(0.1) |
256 | | - end |
257 | | - |
258 | | - it 'updates displayed attributes' do |
259 | | - response = index.update_accept_new_fields(false) |
260 | | - expect(response).to have_key('updateId') |
261 | | - sleep(0.1) |
262 | | - expect(index.accept_new_fields).to be_falsy |
263 | | - end |
264 | | - |
265 | | - it 'does not add searchable or display attributes when falsy' do |
266 | | - index.update_searchable_attributes(['title', 'description']) |
267 | | - sleep(0.1) |
268 | | - index.update_displayed_attributes(['title', 'description']) |
269 | | - sleep(0.1) |
270 | | - index.update_accept_new_fields(false) |
271 | | - sleep(0.1) |
272 | | - index.add_documents(id: 1, title: 'Test', comment: 'comment test', note: 'note') |
273 | | - sleep(0.1) |
274 | | - sa = index.searchable_attributes |
275 | | - da = index.displayed_attributes |
276 | | - expect(sa).to contain_exactly('title', 'description') |
277 | | - expect(da).to contain_exactly('title', 'description') |
| 221 | + expect(index.displayed_attributes).to eq(default_displayed_attributes) |
278 | 222 | end |
279 | 223 | end |
280 | 224 |
|
|
447 | 391 | expect(response.keys).to contain_exactly(*settings_keys) |
448 | 392 | expect(response['rankingRules']).to eq(default_ranking_rules) |
449 | 393 | expect(response['distinctAttribute']).to be_nil |
450 | | - expect(response['searchableAttributes']).to eq(['id']) |
451 | | - expect(response['displayedAttributes']).to eq(['id']) |
| 394 | + expect(response['searchableAttributes']).to eq(default_searchable_attributes) |
| 395 | + expect(response['displayedAttributes']).to eq(default_displayed_attributes) |
452 | 396 | expect(response['stopWords']).to eq([]) |
453 | 397 | expect(response['synonyms']).to eq({}) |
454 | | - expect(response['acceptNewFields']).to be_truthy |
455 | 398 | end |
456 | 399 |
|
457 | 400 | it 'updates multiples settings at the same time' do |
|
503 | 446 | it 'does not add document when there is no primary-key' do |
504 | 447 | expect do |
505 | 448 | index.add_documents(title: 'Test') |
506 | | - end.to raise_bad_request_meilisearch_api_error |
| 449 | + end.to raise_missing_primary_key_meilisearch_api_error |
507 | 450 | end |
508 | 451 |
|
509 | 452 | it 'adds documents when there is a primary-key' do |
|
522 | 465 | expect(response).to have_key('updateId') |
523 | 466 | sleep(0.1) |
524 | 467 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
| 468 | + expect(index.searchable_attributes).to eq(['*']) |
525 | 469 | end |
526 | 470 | end |
527 | 471 |
|
|
541 | 485 | expect(index.method(:distinct_attribute) == index.method(:get_distinct_attribute)).to be_truthy |
542 | 486 | expect(index.method(:searchable_attributes) == index.method(:get_searchable_attributes)).to be_truthy |
543 | 487 | expect(index.method(:displayed_attributes) == index.method(:get_displayed_attributes)).to be_truthy |
544 | | - expect(index.method(:accept_new_fields) == index.method(:get_accept_new_fields)).to be_truthy |
545 | 488 | expect(index.method(:synonyms) == index.method(:get_synonyms)).to be_truthy |
546 | 489 | expect(index.method(:stop_words) == index.method(:get_stop_words)).to be_truthy |
547 | 490 | expect(index.method(:attributes_for_faceting) == index.method(:get_attributes_for_faceting)).to be_truthy |
|
0 commit comments