Skip to content

Commit e3f8951

Browse files
bors[bot]alallema
andauthored
Merge #175
175: Adding possibility to send body null and tests r=bidoubiwa a=alallema **Description** Adding the possibility for the client to send body null. Fixing update settings method. Adding tests to check if nil could be sent properly. **Issue related** #121 **** Still not working on `update_synonyms()` and `update_stop_words()` method because the meilisearch API doesn't seem to take null as arguments Co-authored-by: alallema <[email protected]> Co-authored-by: Amélie <[email protected]>
2 parents 54e6bbc + 636477e commit e3f8951

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

.rubocop_todo.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2021-03-16 11:04:59 UTC using RuboCop version 1.11.0.
3+
# on 2021-05-05 07:48:22 UTC using RuboCop version 1.13.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -14,11 +14,11 @@ Gemspec/DateAssignment:
1414
Exclude:
1515
- 'meilisearch.gemspec'
1616

17-
# Offense count: 30
17+
# Offense count: 34
1818
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
1919
# IgnoredMethods: refine
2020
Metrics/BlockLength:
21-
Max: 432
21+
Max: 445
2222

2323
# Offense count: 1
2424
# Configuration parameters: CountComments, CountAsOne.
@@ -31,6 +31,7 @@ Naming/AccessorMethodName:
3131
- 'lib/meilisearch/index.rb'
3232

3333
# Offense count: 7
34+
# Configuration parameters: AllowedConstants.
3435
Style/Documentation:
3536
Exclude:
3637
- 'spec/**/*'

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 for faceting 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)