Skip to content

Commit df15847

Browse files
Merge #401
401: Prevent background job queuing when deactivated r=ellnix a=ellnix # Pull Request ## Related issue Fixes #399 Co-authored-by: ellnix <[email protected]>
2 parents a3675cb + 8571262 commit df15847

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

.rubocop_todo.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2024-09-13 15:45:46 UTC using RuboCop version 1.27.0.
3+
# on 2025-03-08 11:51:39 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
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 1
1010
# This cop supports safe auto-correction (--auto-correct).
11-
# Configuration parameters: Include.
12-
# Include: **/*.gemspec
13-
Gemspec/RequireMFA:
11+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
13+
Bundler/OrderedGems:
1414
Exclude:
15-
- 'meilisearch-rails.gemspec'
15+
- 'Gemfile'
1616

1717
# Offense count: 1
18+
# This cop supports safe auto-correction (--auto-correct).
1819
# Configuration parameters: Include.
1920
# Include: **/*.gemspec
20-
Gemspec/RequiredRubyVersion:
21+
Gemspec/RequireMFA:
2122
Exclude:
2223
- 'meilisearch-rails.gemspec'
2324

@@ -29,6 +30,13 @@ Layout/EmptyLinesAroundModuleBody:
2930
Exclude:
3031
- 'lib/meilisearch-rails.rb'
3132

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+
3240
# Offense count: 1
3341
# This cop supports safe auto-correction (--auto-correct).
3442
# Configuration parameters: EnforcedStyle.
@@ -65,10 +73,10 @@ Lint/UnusedMethodArgument:
6573
Exclude:
6674
- 'lib/meilisearch-rails.rb'
6775

68-
# Offense count: 12
76+
# Offense count: 13
6977
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
7078
Metrics/AbcSize:
71-
Max: 103
79+
Max: 105
7280

7381
# Offense count: 1
7482
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
@@ -84,9 +92,9 @@ Metrics/ClassLength:
8492
# Offense count: 9
8593
# Configuration parameters: IgnoredMethods.
8694
Metrics/CyclomaticComplexity:
87-
Max: 27
95+
Max: 28
8896

89-
# Offense count: 19
97+
# Offense count: 20
9098
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
9199
Metrics/MethodLength:
92100
Max: 102
@@ -99,7 +107,7 @@ Metrics/ModuleLength:
99107
# Offense count: 8
100108
# Configuration parameters: IgnoredMethods.
101109
Metrics/PerceivedComplexity:
102-
Max: 34
110+
Max: 35
103111

104112
# Offense count: 1
105113
Naming/AccessorMethodName:
@@ -138,7 +146,7 @@ RSpec/ContextWording:
138146
- 'spec/options_spec.rb'
139147
- 'spec/system/tech_shop_spec.rb'
140148

141-
# Offense count: 55
149+
# Offense count: 57
142150
# Configuration parameters: CountAsOne.
143151
RSpec/ExampleLength:
144152
Max: 16
@@ -176,6 +184,13 @@ RSpec/VerifiedDoubles:
176184
Exclude:
177185
- 'spec/configuration_spec.rb'
178186

187+
# Offense count: 1
188+
# Configuration parameters: ForbiddenMethods, AllowedMethods.
189+
# 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
190+
Rails/SkipsModelValidations:
191+
Exclude:
192+
- 'spec/settings_spec.rb'
193+
179194
# Offense count: 2
180195
# This cop supports safe auto-correction (--auto-correct).
181196
# Configuration parameters: EnforcedStyle.

lib/meilisearch-rails.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def meilisearch(options = {}, &block)
415415
raise ArgumentError, "Invalid `enqueue` option: #{options[:enqueue]}"
416416
end
417417
meilisearch_options[:enqueue] = proc do |record, remove|
418-
proc.call(record, remove) unless ms_without_auto_index_scope
418+
proc.call(record, remove) if ::MeiliSearch::Rails.active? && !ms_without_auto_index_scope
419419
end
420420
end
421421
unless options[:auto_index] == false

spec/meilisearch/activation_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'support/models/queued_models'
2+
13
describe MeiliSearch::Rails do
24
it 'is active by default' do
35
expect(described_class).to be_active
@@ -16,6 +18,12 @@
1618
it 'responds with a black hole' do
1719
expect(described_class.client.foo.bar.now.nil.item.issue).to be_nil
1820
end
21+
22+
it 'does not queue tasks' do
23+
expect do
24+
EnqueuedDocument.create! name: 'hello world'
25+
end.not_to raise_error
26+
end
1927
end
2028

2129
context 'with a block' do

0 commit comments

Comments
 (0)