|
8 | 8 | it 'uses the specified scope' do |
9 | 9 | TestUtil.reset_colors! |
10 | 10 |
|
11 | | - Color.create!(name: 'red', short_name: 'r3', hex: 3) |
12 | | - Color.create!(name: 'red', short_name: 'r1', hex: 1) |
13 | | - Color.create!(name: 'purple', short_name: 'p') |
14 | | - |
15 | | - Color.clear_index!(true) |
| 11 | + Color.insert_all([ |
| 12 | + { name: 'red', short_name: 'r3', hex: 3 }, |
| 13 | + { name: 'red', short_name: 'r1', hex: 1 }, |
| 14 | + { name: 'purple', short_name: 'p', hex: 4 } |
| 15 | + ]) |
16 | 16 |
|
17 | 17 | Color.where(name: 'red').reindex!(3, true) |
18 | 18 | expect(Color.search('').size).to eq(2) |
19 | 19 |
|
20 | | - Color.clear_index!(true) |
21 | | - Color.where(id: Color.first.id).reindex!(3, true) |
| 20 | + Color.clear_index! |
| 21 | + Color.where(name: 'purple').reindex!(3, true) |
22 | 22 | expect(Color.search('').size).to eq(1) |
23 | 23 | end |
24 | 24 | end |
|
66 | 66 | ) |
67 | 67 | end |
68 | 68 |
|
| 69 | + # No need to await since Book is synchronous |
69 | 70 | expect(Book.search('Frankenstein')).to be_one |
70 | 71 | end |
71 | 72 | end |
|
77 | 78 | _blue = Color.create!(name: 'blue', short_name: 'blu', hex: 0x0000FF) |
78 | 79 | _black = Color.create!(name: 'black', short_name: 'bla', hex: 0x000000) |
79 | 80 |
|
| 81 | + # No need to await since Color is synchronous |
80 | 82 | json = Color.raw_search('') |
81 | 83 | Color.index_documents Color.limit(1), true # reindex last color, `limit` is incompatible with the reindex! method |
82 | 84 | expect(json['hits'].count).to eq(Color.raw_search('')['hits'].count) |
|
0 commit comments