Skip to content

Commit 3991366

Browse files
committed
Test :enqueue with symbol
1 parent 3bdb146 commit 3991366

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

spec/options_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@
153153
end
154154

155155
describe ':enqueue' do
156+
context 'when configured with a symbol' do
157+
it 'runs the class method when created' do
158+
expect do
159+
SymbolEnqueuedDocument.create! name: 'hellraiser'
160+
end.to raise_error('enqueued hellraiser')
161+
end
162+
163+
it 'does not run method in without_auto_index block' do
164+
expect do
165+
SymbolEnqueuedDocument.without_auto_index do
166+
SymbolEnqueuedDocument.create! name: 'hellraiser'
167+
end
168+
end.not_to raise_error
169+
end
170+
end
171+
156172
context 'when configured with a proc' do
157173
it 'runs proc when created' do
158174
expect do

spec/support/models/queued_models.rb

+17
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
t.boolean :is_public
1414
end
1515

16+
ar_schema.create_table :symbol_enqueued_documents do |t|
17+
t.string :name
18+
end
19+
1620
class EnqueuedDocument < ActiveRecord::Base
1721
include MeiliSearch::Rails
1822

@@ -55,3 +59,16 @@ def should_index?
5559
is_public
5660
end
5761
end
62+
63+
class SymbolEnqueuedDocument < ActiveRecord::Base
64+
include MeiliSearch::Rails
65+
66+
meilisearch(enqueue: :queue_me,
67+
index_uid: safe_index_uid('SymbolEnqueuedDocument')) do
68+
attributes %i[name is_public]
69+
end
70+
71+
def self.queue_me(record, remove)
72+
raise "enqueued #{record.name}"
73+
end
74+
end

0 commit comments

Comments
 (0)