Skip to content

Commit 6a05223

Browse files
committed
Adding possibility to send body null and tests
1 parent 49a385b commit 6a05223

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/meilisearch/http_request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def send_request(http_method, relative_path, query_params = nil, body = nil)
6363
end
6464

6565
def http_config(query_params, body)
66-
body = body.to_json unless body.nil?
66+
body = body.to_json
6767
{
6868
headers: @headers,
6969
query: query_params,

spec/meilisearch/index/settings_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@
113113
expect(index.ranking_rules).to eq(ranking_rules)
114114
end
115115

116+
it 'updates ranking rules at null' do
117+
response = index.update_ranking_rules(nil)
118+
expect(response).to have_key('updateId')
119+
index.wait_for_pending_update(response['updateId'])
120+
expect(index.ranking_rules).to eq(default_ranking_rules)
121+
end
122+
116123
it 'fails when updating with wrong ranking rules name' do
117124
expect do
118125
index.update_ranking_rules(wrong_ranking_rules)
@@ -150,6 +157,13 @@
150157
expect(index.distinct_attribute).to eq(distinct_attribute)
151158
end
152159

160+
it 'updates distinct attribute at null' do
161+
response = index.update_distinct_attribute(nil)
162+
expect(response).to have_key('updateId')
163+
index.wait_for_pending_update(response['updateId'])
164+
expect(index.distinct_attribute).to be_nil
165+
end
166+
153167
it 'resets distinct attribute' do
154168
response = index.reset_distinct_attribute
155169
expect(response).to have_key('updateId')
@@ -181,6 +195,13 @@
181195
expect(index.searchable_attributes).to eq(searchable_attributes)
182196
end
183197

198+
it 'updates searchable attributes at null' do
199+
response = index.update_searchable_attributes(nil)
200+
expect(response).to have_key('updateId')
201+
index.wait_for_pending_update(response['updateId'])
202+
expect(index.searchable_attributes).to eq(default_searchable_attributes)
203+
end
204+
184205
it 'resets searchable attributes' do
185206
response = index.reset_searchable_attributes
186207
expect(response).to have_key('updateId')
@@ -213,6 +234,13 @@
213234
expect(index.displayed_attributes).to contain_exactly(*displayed_attributes)
214235
end
215236

237+
it 'updates displayed attributes at null' do
238+
response = index.update_displayed_attributes(nil)
239+
expect(response).to have_key('updateId')
240+
index.wait_for_pending_update(response['updateId'])
241+
expect(index.displayed_attributes).to eq(default_displayed_attributes)
242+
end
243+
216244
it 'resets displayed attributes' do
217245
response = index.reset_displayed_attributes
218246
expect(response).to have_key('updateId')
@@ -366,6 +394,13 @@
366394
expect(index.attributes_for_faceting).to contain_exactly(*attributes_for_faceting)
367395
end
368396

397+
it 'updates attributes at null' do
398+
response = index.update_attributes_for_faceting(nil)
399+
expect(response).to have_key('updateId')
400+
index.wait_for_pending_update(response['updateId'])
401+
expect(index.attributes_for_faceting).to be_empty
402+
end
403+
369404
it 'resets attributes for faceting' do
370405
response = index.reset_attributes_for_faceting
371406
expect(response).to have_key('updateId')

0 commit comments

Comments
 (0)