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