Skip to content

Commit 598fd3f

Browse files
committed
Prevent background job queuing when deactivated
1 parent 6afcd40 commit 598fd3f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/meilisearch-rails.rb

+1-1
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

+8
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)