From 6a05223ea9de2fb8af3a5b540f7860223abbc1ed Mon Sep 17 00:00:00 2001 From: alallema Date: Wed, 5 May 2021 09:08:54 +0200 Subject: [PATCH 1/3] Adding possibility to send body null and tests --- lib/meilisearch/http_request.rb | 2 +- spec/meilisearch/index/settings_spec.rb | 35 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/meilisearch/http_request.rb b/lib/meilisearch/http_request.rb index b768cd90..bac4a836 100644 --- a/lib/meilisearch/http_request.rb +++ b/lib/meilisearch/http_request.rb @@ -63,7 +63,7 @@ def send_request(http_method, relative_path, query_params = nil, body = nil) end def http_config(query_params, body) - body = body.to_json unless body.nil? + body = body.to_json { headers: @headers, query: query_params, diff --git a/spec/meilisearch/index/settings_spec.rb b/spec/meilisearch/index/settings_spec.rb index 0dca9f23..ea2e991f 100644 --- a/spec/meilisearch/index/settings_spec.rb +++ b/spec/meilisearch/index/settings_spec.rb @@ -113,6 +113,13 @@ expect(index.ranking_rules).to eq(ranking_rules) end + it 'updates ranking rules at null' do + response = index.update_ranking_rules(nil) + expect(response).to have_key('updateId') + index.wait_for_pending_update(response['updateId']) + expect(index.ranking_rules).to eq(default_ranking_rules) + end + it 'fails when updating with wrong ranking rules name' do expect do index.update_ranking_rules(wrong_ranking_rules) @@ -150,6 +157,13 @@ expect(index.distinct_attribute).to eq(distinct_attribute) end + it 'updates distinct attribute at null' do + response = index.update_distinct_attribute(nil) + expect(response).to have_key('updateId') + index.wait_for_pending_update(response['updateId']) + expect(index.distinct_attribute).to be_nil + end + it 'resets distinct attribute' do response = index.reset_distinct_attribute expect(response).to have_key('updateId') @@ -181,6 +195,13 @@ expect(index.searchable_attributes).to eq(searchable_attributes) end + it 'updates searchable attributes at null' do + response = index.update_searchable_attributes(nil) + expect(response).to have_key('updateId') + index.wait_for_pending_update(response['updateId']) + expect(index.searchable_attributes).to eq(default_searchable_attributes) + end + it 'resets searchable attributes' do response = index.reset_searchable_attributes expect(response).to have_key('updateId') @@ -213,6 +234,13 @@ expect(index.displayed_attributes).to contain_exactly(*displayed_attributes) end + it 'updates displayed attributes at null' do + response = index.update_displayed_attributes(nil) + expect(response).to have_key('updateId') + index.wait_for_pending_update(response['updateId']) + expect(index.displayed_attributes).to eq(default_displayed_attributes) + end + it 'resets displayed attributes' do response = index.reset_displayed_attributes expect(response).to have_key('updateId') @@ -366,6 +394,13 @@ expect(index.attributes_for_faceting).to contain_exactly(*attributes_for_faceting) end + it 'updates attributes at null' do + response = index.update_attributes_for_faceting(nil) + expect(response).to have_key('updateId') + index.wait_for_pending_update(response['updateId']) + expect(index.attributes_for_faceting).to be_empty + end + it 'resets attributes for faceting' do response = index.reset_attributes_for_faceting expect(response).to have_key('updateId') From 1bf834fd7271f30dcf0b44f9d577ad9fb84324b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Am=C3=A9lie?= Date: Wed, 5 May 2021 09:44:28 +0200 Subject: [PATCH 2/3] Update spec/meilisearch/index/settings_spec.rb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clémentine Urquizar --- spec/meilisearch/index/settings_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/meilisearch/index/settings_spec.rb b/spec/meilisearch/index/settings_spec.rb index ea2e991f..f4c5f0b5 100644 --- a/spec/meilisearch/index/settings_spec.rb +++ b/spec/meilisearch/index/settings_spec.rb @@ -394,7 +394,7 @@ expect(index.attributes_for_faceting).to contain_exactly(*attributes_for_faceting) end - it 'updates attributes at null' do + it 'updates attributes for faceting at null' do response = index.update_attributes_for_faceting(nil) expect(response).to have_key('updateId') index.wait_for_pending_update(response['updateId']) From 636477ef3f2e07e2659436bbb1f6d50b40e79d5c Mon Sep 17 00:00:00 2001 From: alallema Date: Wed, 5 May 2021 09:49:49 +0200 Subject: [PATCH 3/3] Fixing linter by autofixing rubocop_todo.yml --- .rubocop_todo.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 04c019c0..19bdd9cb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-03-16 11:04:59 UTC using RuboCop version 1.11.0. +# on 2021-05-05 07:48:22 UTC using RuboCop version 1.13.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,11 +14,11 @@ Gemspec/DateAssignment: Exclude: - 'meilisearch.gemspec' -# Offense count: 30 +# Offense count: 34 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. # IgnoredMethods: refine Metrics/BlockLength: - Max: 432 + Max: 445 # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. @@ -31,6 +31,7 @@ Naming/AccessorMethodName: - 'lib/meilisearch/index.rb' # Offense count: 7 +# Configuration parameters: AllowedConstants. Style/Documentation: Exclude: - 'spec/**/*'