Skip to content

Commit

Permalink
Fix remaining integration_spec order problems
Browse files Browse the repository at this point in the history
  • Loading branch information
ellnix committed Nov 1, 2023
1 parent 6394f2e commit 9ada396
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
@products_in_database = Product.all

Product.reindex!(MeiliSearch::Rails::IndexSettings::DEFAULT_BATCH_SIZE, true)
sleep 5
end

it 'is not synchronous' do
Expand Down Expand Up @@ -525,7 +526,7 @@
end

describe 'Book' do
before(:all) do
before(:each) do
Book.clear_index!(true)
Book.index(safe_index_uid('BookAuthor')).delete_all_documents
Book.index(safe_index_uid('Book')).delete_all_documents
Expand Down Expand Up @@ -698,6 +699,7 @@
end

Restaurant.reindex!(MeiliSearch::Rails::IndexSettings::DEFAULT_BATCH_SIZE, true)
sleep 5
end

after(:all) { MeiliSearch::Rails.configuration[:pagination_backend] = nil }
Expand Down Expand Up @@ -752,6 +754,7 @@
10.times { Movie.create(title: Faker::Movie.title) }

Movie.reindex!(MeiliSearch::Rails::IndexSettings::DEFAULT_BATCH_SIZE, true)
sleep 5
end

after(:all) { MeiliSearch::Rails.configuration[:pagination_backend] = nil }
Expand Down Expand Up @@ -792,7 +795,12 @@
before(:all) { MeiliSearch::Rails.configuration[:pagination_backend] = :pagy }
after(:all) { MeiliSearch::Rails.configuration[:pagination_backend] = nil }

before(:all) { MeiliSearch::Rails.configuration[:per_environment] = false }
after(:all) { MeiliSearch::Rails.configuration[:per_environment] = true }

it 'has meaningful error when pagy is set as the pagination_backend' do
Movie.create(title: "Harry Potter").index!(true)

logger = double
allow(logger).to receive(:warning)
allow(::Rails).to receive(:logger).and_return(logger)
Expand Down Expand Up @@ -859,8 +867,8 @@
describe 'EnqueuedDocument' do
it 'enqueues a job' do
expect do
EnqueuedDocument.create! name: 'test'
end.to raise_error('enqueued 1')
EnqueuedDocument.create! name: 'hellraiser'
end.to raise_error('enqueued hellraiser')
end

it 'does not enqueue a job inside no index block' do
Expand Down Expand Up @@ -1000,6 +1008,9 @@
end

describe 'Songs' do
before(:all) { MeiliSearch::Rails.configuration[:per_environment] = false }
after(:all) { MeiliSearch::Rails.configuration[:per_environment] = true }

it 'targets multiple indices' do
Song.create!(name: 'Coconut nut', artist: 'Smokey Mountain', premium: false, released: true) # Only song supposed to be added to Songs index
Song.create!(name: 'Smoking hot', artist: 'Cigarettes before lunch', premium: true, released: true)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/active_record_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def self.find(_id)
EnqueuedDocument.first
end

meilisearch enqueue: proc { |record| raise "enqueued #{record.id}" },
meilisearch enqueue: proc { |record| raise "enqueued #{record.name}" },
index_uid: safe_index_uid('EnqueuedDocument') do
attributes [:name]
end
Expand Down

0 comments on commit 9ada396

Please sign in to comment.