Skip to content

Commit f9640bc

Browse files
committed
Speed up multi search specs
1 parent 5450df2 commit f9640bc

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

.rubocop_todo.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-03-08 11:51:39 UTC using RuboCop version 1.27.0.
3+
# on 2025-03-14 19:22:00 UTC using RuboCop version 1.27.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -30,13 +30,6 @@ Layout/EmptyLinesAroundModuleBody:
3030
Exclude:
3131
- 'lib/meilisearch-rails.rb'
3232

33-
# Offense count: 2
34-
# This cop supports safe auto-correction (--auto-correct).
35-
# Configuration parameters: IndentationWidth.
36-
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
37-
Layout/FirstArrayElementIndentation:
38-
EnforcedStyle: consistent
39-
4033
# Offense count: 1
4134
# This cop supports safe auto-correction (--auto-correct).
4235
# Configuration parameters: EnforcedStyle.
@@ -146,7 +139,7 @@ RSpec/ContextWording:
146139
- 'spec/options_spec.rb'
147140
- 'spec/system/tech_shop_spec.rb'
148141

149-
# Offense count: 57
142+
# Offense count: 61
150143
# Configuration parameters: CountAsOne.
151144
RSpec/ExampleLength:
152145
Max: 16
@@ -174,7 +167,7 @@ RSpec/MultipleDescribes:
174167
Exclude:
175168
- 'spec/search_spec.rb'
176169

177-
# Offense count: 2
170+
# Offense count: 3
178171
RSpec/NestedGroups:
179172
Max: 4
180173

@@ -184,12 +177,12 @@ RSpec/VerifiedDoubles:
184177
Exclude:
185178
- 'spec/configuration_spec.rb'
186179

187-
# Offense count: 1
180+
# Offense count: 3
188181
# Configuration parameters: ForbiddenMethods, AllowedMethods.
189182
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
190183
Rails/SkipsModelValidations:
191184
Exclude:
192-
- 'spec/settings_spec.rb'
185+
- 'spec/multi_search_spec.rb'
193186

194187
# Offense count: 2
195188
# This cop supports safe auto-correction (--auto-correct).
@@ -247,7 +240,7 @@ Style/StringLiterals:
247240
Exclude:
248241
- 'spec/ms_clean_up_job_spec.rb'
249242

250-
# Offense count: 15
243+
# Offense count: 16
251244
# This cop supports safe auto-correction (--auto-correct).
252245
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
253246
# URISchemes: http, https

spec/multi_search_spec.rb

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,37 @@
44
require 'support/models/color'
55

66
describe 'multi-search' do
7-
def reset_indexes
7+
before do
88
[Book, Color, Product].each do |klass|
99
klass.delete_all
10-
klass.clear_index!(true)
10+
klass.clear_index!
1111
end
12-
end
1312

14-
before do
15-
reset_indexes
16-
17-
Product.create! name: 'palm pixi plus', href: 'ebay', tags: ['terrible']
18-
Product.create! name: 'lg vortex', href: 'ebay', tags: ['decent']
19-
Product.create! name: 'palmpre', href: 'ebay', tags: ['discontinued', 'worst phone ever']
13+
Product.insert_all([
14+
{ name: 'palm pixi plus', href: 'ebay', tags: ['terrible'] },
15+
{ name: 'lg vortex', href: 'ebay', tags: ['decent'] },
16+
{ name: 'palmpre', href: 'ebay', tags: ['discontinued', 'worst phone ever'] }
17+
])
2018
Product.reindex!
2119

22-
Color.create! name: 'blue', short_name: 'blu', hex: 0x0000FF
23-
Color.create! name: 'black', short_name: 'bla', hex: 0x000000
24-
Color.create! name: 'green', short_name: 'gre', hex: 0x00FF00
25-
26-
Book.create! name: 'Steve Jobs', author: 'Walter Isaacson'
27-
Book.create! name: 'Moby Dick', author: 'Herman Melville'
20+
Color.insert_all([
21+
{ name: 'blue', short_name: 'blu', hex: 0x0000FF },
22+
{ name: 'black', short_name: 'bla', hex: 0x000000 },
23+
{ name: 'green', short_name: 'gre', hex: 0x00FF00 }
24+
])
25+
Color.reindex!
26+
27+
Book.insert_all([
28+
{ name: 'Steve Jobs', author: 'Walter Isaacson' },
29+
{ name: 'Moby Dick', author: 'Herman Melville' }
30+
])
31+
Book.reindex!
2832
end
2933

30-
let!(:palm_pixi_plus) { Product.find_by name: 'palm pixi plus' }
31-
let!(:steve_jobs) { Book.find_by name: 'Steve Jobs' }
32-
let!(:blue) { Color.find_by name: 'blue' }
33-
let!(:black) { Color.find_by name: 'black' }
34+
let(:palm_pixi_plus) { Product.find_by name: 'palm pixi plus' }
35+
let(:steve_jobs) { Book.find_by name: 'Steve Jobs' }
36+
let(:blue) { Color.find_by name: 'blue' }
37+
let(:black) { Color.find_by name: 'black' }
3438

3539
context 'with class keys' do
3640
it 'returns ORM records' do

0 commit comments

Comments
 (0)