Skip to content

Adding possibility to send body null and tests #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/meilisearch/http_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 35 additions & 0 deletions spec/meilisearch/index/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down