|
74 | 74 | end |
75 | 75 |
|
76 | 76 | it 'resets all settings' do |
| 77 | + response = index.update_settings( |
| 78 | + rankingRules: ['title:asc', 'typo'], |
| 79 | + distinctAttribute: 'title', |
| 80 | + stopWords: ['the', 'a'], |
| 81 | + synonyms: { wow: ['world of warcraft'] } |
| 82 | + ) |
| 83 | + index.wait_for_pending_update(response['updateId']) |
| 84 | + |
77 | 85 | response = index.reset_settings |
78 | 86 | expect(response).to have_key('updateId') |
79 | 87 | index.wait_for_pending_update(response['updateId']) |
| 88 | + |
80 | 89 | settings = index.settings |
81 | 90 | expect(settings['rankingRules']).to eq(default_ranking_rules) |
82 | 91 | expect(settings['distinctAttribute']).to be_nil |
|
108 | 117 | end |
109 | 118 |
|
110 | 119 | it 'updates ranking rules at null' do |
| 120 | + response = index.update_ranking_rules(ranking_rules) |
| 121 | + index.wait_for_pending_update(response['updateId']) |
| 122 | + |
111 | 123 | response = index.update_ranking_rules(nil) |
112 | 124 | expect(response).to have_key('updateId') |
113 | 125 | index.wait_for_pending_update(response['updateId']) |
| 126 | + |
114 | 127 | expect(index.ranking_rules).to eq(default_ranking_rules) |
115 | 128 | end |
116 | 129 |
|
117 | 130 | it 'fails when updating with wrong ranking rules name' do |
118 | 131 | response = index.update_ranking_rules(wrong_ranking_rules) |
119 | 132 | index.wait_for_pending_update(response['updateId']) |
| 133 | + |
120 | 134 | response = index.get_update_status(response['updateId']) |
| 135 | + |
121 | 136 | expect(response.keys).to include('message') |
122 | 137 | expect(response['errorCode']).to eq('invalid_request') |
123 | 138 | end |
124 | 139 |
|
125 | 140 | it 'resets ranking rules' do |
| 141 | + response = index.update_ranking_rules(ranking_rules) |
| 142 | + index.wait_for_pending_update(response['updateId']) |
| 143 | + |
126 | 144 | response = index.reset_ranking_rules |
127 | 145 | expect(response).to have_key('updateId') |
128 | 146 | index.wait_for_pending_update(response['updateId']) |
| 147 | + |
129 | 148 | expect(index.ranking_rules).to eq(default_ranking_rules) |
130 | 149 | end |
131 | 150 | end |
132 | 151 |
|
133 | 152 | context 'On distinct-attribute sub-routes' do |
134 | | - before do |
135 | | - @uid = random_uid |
136 | | - client.create_index(@uid) |
137 | | - end |
138 | | - |
139 | | - let(:index) { client.index(@uid) } |
| 153 | + let(:uid) { random_uid } |
| 154 | + let(:index) { client.index(uid) } |
140 | 155 | let(:distinct_attribute) { 'title' } |
141 | 156 |
|
142 | 157 | it 'gets default values of distinct attribute' do |
| 158 | + client.create_index(uid) |
143 | 159 | response = index.distinct_attribute |
| 160 | + |
144 | 161 | expect(response).to be_nil |
145 | 162 | end |
146 | 163 |
|
147 | 164 | it 'updates distinct attribute' do |
148 | 165 | response = index.update_distinct_attribute(distinct_attribute) |
149 | 166 | expect(response).to have_key('updateId') |
150 | 167 | index.wait_for_pending_update(response['updateId']) |
| 168 | + |
151 | 169 | expect(index.distinct_attribute).to eq(distinct_attribute) |
152 | 170 | end |
153 | 171 |
|
154 | 172 | it 'updates distinct attribute at null' do |
| 173 | + response = index.update_distinct_attribute(distinct_attribute) |
| 174 | + index.wait_for_pending_update(response['updateId']) |
| 175 | + |
155 | 176 | response = index.update_distinct_attribute(nil) |
156 | | - expect(response).to have_key('updateId') |
157 | 177 | index.wait_for_pending_update(response['updateId']) |
| 178 | + |
158 | 179 | expect(index.distinct_attribute).to be_nil |
159 | 180 | end |
160 | 181 |
|
161 | 182 | it 'resets distinct attribute' do |
| 183 | + response = index.update_distinct_attribute(distinct_attribute) |
| 184 | + index.wait_for_pending_update(response['updateId']) |
| 185 | + |
162 | 186 | response = index.reset_distinct_attribute |
163 | | - expect(response).to have_key('updateId') |
164 | 187 | index.wait_for_pending_update(response['updateId']) |
| 188 | + |
165 | 189 | expect(index.distinct_attribute).to be_nil |
166 | 190 | end |
167 | 191 | end |
|
188 | 212 | end |
189 | 213 |
|
190 | 214 | it 'updates searchable attributes at null' do |
| 215 | + response = index.update_searchable_attributes(searchable_attributes) |
| 216 | + index.wait_for_pending_update(response['updateId']) |
| 217 | + |
191 | 218 | response = index.update_searchable_attributes(nil) |
192 | 219 | expect(response).to have_key('updateId') |
| 220 | + |
193 | 221 | index.wait_for_pending_update(response['updateId']) |
194 | 222 | expect(index.searchable_attributes).to eq(default_searchable_attributes) |
195 | 223 | end |
196 | 224 |
|
197 | 225 | it 'resets searchable attributes' do |
| 226 | + response = index.update_searchable_attributes(searchable_attributes) |
| 227 | + index.wait_for_pending_update(response['updateId']) |
| 228 | + |
198 | 229 | response = index.reset_searchable_attributes |
199 | 230 | expect(response).to have_key('updateId') |
200 | 231 | index.wait_for_pending_update(response['updateId']) |
| 232 | + |
201 | 233 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
202 | 234 | expect(index.searchable_attributes).to eq(default_searchable_attributes) |
203 | 235 | end |
|
221 | 253 | response = index.update_displayed_attributes(displayed_attributes) |
222 | 254 | expect(response).to have_key('updateId') |
223 | 255 | index.wait_for_pending_update(response['updateId']) |
| 256 | + |
224 | 257 | expect(index.displayed_attributes).to contain_exactly(*displayed_attributes) |
225 | 258 | end |
226 | 259 |
|
227 | 260 | it 'updates displayed attributes at null' do |
| 261 | + response = index.update_displayed_attributes(displayed_attributes) |
| 262 | + index.wait_for_pending_update(response['updateId']) |
| 263 | + |
228 | 264 | response = index.update_displayed_attributes(nil) |
229 | 265 | expect(response).to have_key('updateId') |
230 | 266 | index.wait_for_pending_update(response['updateId']) |
| 267 | + |
231 | 268 | expect(index.displayed_attributes).to eq(default_displayed_attributes) |
232 | 269 | end |
233 | 270 |
|
234 | 271 | it 'resets displayed attributes' do |
| 272 | + response = index.update_displayed_attributes(displayed_attributes) |
| 273 | + index.wait_for_pending_update(response['updateId']) |
| 274 | + |
235 | 275 | response = index.reset_displayed_attributes |
236 | 276 | expect(response).to have_key('updateId') |
237 | 277 | index.wait_for_pending_update(response['updateId']) |
| 278 | + |
238 | 279 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
239 | 280 | expect(index.displayed_attributes).to eq(default_displayed_attributes) |
240 | 281 | end |
|
353 | 394 | end |
354 | 395 |
|
355 | 396 | it 'updates stop-words at null' do |
| 397 | + response = index.update_stop_words(stop_words_string) |
| 398 | + index.wait_for_pending_update(response['updateId']) |
| 399 | + |
356 | 400 | response = index.update_stop_words(nil) |
357 | 401 | expect(response).to have_key('updateId') |
358 | 402 | index.wait_for_pending_update(response['updateId']) |
| 403 | + |
359 | 404 | expect(index.stop_words).to be_empty |
360 | 405 | end |
361 | 406 |
|
|
366 | 411 | end |
367 | 412 |
|
368 | 413 | it 'resets stop-words' do |
| 414 | + response = index.update_stop_words(stop_words_string) |
| 415 | + index.wait_for_pending_update(response['updateId']) |
| 416 | + |
369 | 417 | response = index.reset_stop_words |
370 | 418 | expect(response).to be_a(Hash) |
371 | 419 | expect(response).to have_key('updateId') |
372 | 420 | index.wait_for_pending_update(response['updateId']) |
| 421 | + |
373 | 422 | expect(index.stop_words).to be_a(Array) |
374 | 423 | expect(index.stop_words).to be_empty |
375 | 424 | end |
|
398 | 447 | end |
399 | 448 |
|
400 | 449 | it 'updates filterable attributes at null' do |
| 450 | + response = index.update_filterable_attributes(filterable_attributes) |
| 451 | + expect(response).to have_key('updateId') |
| 452 | + |
401 | 453 | response = index.update_filterable_attributes(nil) |
402 | 454 | expect(response).to have_key('updateId') |
403 | 455 | index.wait_for_pending_update(response['updateId']) |
| 456 | + |
404 | 457 | expect(index.filterable_attributes).to be_empty |
405 | 458 | end |
406 | 459 |
|
407 | 460 | it 'resets filterable attributes' do |
| 461 | + response = index.update_filterable_attributes(filterable_attributes) |
| 462 | + expect(response).to have_key('updateId') |
| 463 | + |
408 | 464 | response = index.reset_filterable_attributes |
409 | 465 | expect(response).to have_key('updateId') |
410 | 466 | index.wait_for_pending_update(response['updateId']) |
| 467 | + |
411 | 468 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
412 | 469 | expect(index.filterable_attributes).to be_empty |
413 | 470 | end |
|
436 | 493 | end |
437 | 494 |
|
438 | 495 | it 'updates sortable attributes at null' do |
| 496 | + response = index.update_sortable_attributes(sortable_attributes) |
| 497 | + index.wait_for_pending_update(response['updateId']) |
| 498 | + |
439 | 499 | response = index.update_sortable_attributes(nil) |
440 | 500 | expect(response).to have_key('updateId') |
441 | 501 | index.wait_for_pending_update(response['updateId']) |
| 502 | + |
442 | 503 | expect(index.sortable_attributes).to be_empty |
443 | 504 | end |
444 | 505 |
|
445 | 506 | it 'resets sortable attributes' do |
| 507 | + response = index.update_sortable_attributes(sortable_attributes) |
| 508 | + index.wait_for_pending_update(response['updateId']) |
| 509 | + |
446 | 510 | response = index.reset_sortable_attributes |
447 | 511 | expect(response).to have_key('updateId') |
448 | 512 | index.wait_for_pending_update(response['updateId']) |
| 513 | + |
449 | 514 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
450 | 515 | expect(index.sortable_attributes).to be_empty |
451 | 516 | end |
|
496 | 561 | end |
497 | 562 |
|
498 | 563 | it 'resets all settings' do |
| 564 | + response = index.update_settings( |
| 565 | + rankingRules: ['title:asc', 'typo'], |
| 566 | + distinctAttribute: 'title', |
| 567 | + stopWords: ['the'], |
| 568 | + synonyms: { |
| 569 | + wow: ['world of warcraft'] |
| 570 | + } |
| 571 | + ) |
| 572 | + index.wait_for_pending_update(response['updateId']) |
| 573 | + |
499 | 574 | response = index.reset_settings |
500 | 575 | expect(response).to have_key('updateId') |
501 | 576 | index.wait_for_pending_update(response['updateId']) |
| 577 | + |
502 | 578 | settings = index.settings |
503 | 579 | expect(settings['rankingRules']).to eq(default_ranking_rules) |
504 | 580 | expect(settings['distinctAttribute']).to be_nil |
|
508 | 584 | end |
509 | 585 |
|
510 | 586 | context 'Manipulation of searchable/displayed attributes with the primary-key' do |
511 | | - before do |
512 | | - @uid = random_uid |
513 | | - client.create_index(@uid) |
514 | | - end |
515 | | - |
516 | | - let(:index) { client.index(@uid) } |
| 587 | + let(:index) { client.index(random_uid) } |
517 | 588 |
|
518 | 589 | it 'does not add document when there is no primary-key' do |
519 | 590 | response = index.add_documents(title: 'Test') |
|
531 | 602 | end |
532 | 603 |
|
533 | 604 | it 'resets searchable/displayed attributes' do |
| 605 | + response = index.update_displayed_attributes(['title', 'description']) |
| 606 | + index.wait_for_pending_update(response['updateId']) |
| 607 | + response = index.update_searchable_attributes(['title']) |
| 608 | + expect(response).to have_key('updateId') |
| 609 | + index.wait_for_pending_update(response['updateId']) |
| 610 | + |
534 | 611 | response = index.reset_displayed_attributes |
535 | 612 | expect(response).to have_key('updateId') |
536 | 613 | index.wait_for_pending_update(response['updateId']) |
537 | 614 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
| 615 | + |
538 | 616 | response = index.reset_searchable_attributes |
539 | 617 | expect(response).to have_key('updateId') |
540 | 618 | index.wait_for_pending_update(response['updateId']) |
541 | 619 | expect(index.get_update_status(response['updateId'])['status']).to eq('processed') |
| 620 | + |
| 621 | + expect(index.displayed_attributes).to eq(['*']) |
542 | 622 | expect(index.searchable_attributes).to eq(['*']) |
543 | 623 | end |
544 | 624 | end |
|
0 commit comments