Skip to content

Commit 4597126

Browse files
committed
Test for misconfiguration errors
1 parent bd18629 commit 4597126

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

spec/model_configuration_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'spec_helper'
2+
require 'support/models/unconfigured_model'
3+
4+
describe 'Model configuration' do
5+
describe 'options' do
6+
context 'if passed :per_environment' do
7+
fit 'throws error' do
8+
expect do
9+
UnconfiguredModel.meilisearch per_environment: true
10+
end.to raise_error(MeiliSearch::Rails::BadConfiguration)
11+
end
12+
end
13+
14+
context 'if passed :enqueue and :synchronous' do
15+
fit 'complains about incompatible options' do
16+
expect do
17+
UnconfiguredModel.meilisearch enqueue: true, synchronous: true
18+
end.to raise_error(ArgumentError)
19+
end
20+
end
21+
end
22+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'support/active_record_schema'
2+
3+
ar_schema.create_table :unconfigured_model do |t|
4+
t.string :name
5+
end
6+
7+
class UnconfiguredModel < ActiveRecord::Base
8+
include MeiliSearch::Rails
9+
end
10+
11+
module TestUtil
12+
def self.clear_unconfigured_model!
13+
UnconfiguredModel.clear_index!(true) if UnconfiguredModel.respond_to?(:clear_index)
14+
UnconfiguredModel.delete_all
15+
end
16+
end

0 commit comments

Comments
 (0)