Skip to content

Commit 56ab610

Browse files
authored
fix(helpers): deserialize_settings function (#430)
1 parent be65147 commit 56ab610

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/algolia/helpers.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ def path_encode(path, *args)
5353
# Support to convert old settings to their new names
5454
#
5555
def deserialize_settings(data, symbolize_keys)
56-
settings = symbolize_hash(data)
56+
settings = data
5757
keys = {
5858
attributesToIndex: 'searchableAttributes',
5959
numericAttributesToIndex: 'numericAttributesForFiltering',
6060
slaves: 'replicas'
6161
}
6262

6363
keys.each do |deprecated_key, current_key|
64+
deprecated_key = symbolize_keys ? deprecated_key : deprecated_key.to_s
6465
if settings.has_key?(deprecated_key)
6566
key = symbolize_keys ? current_key.to_sym : current_key.to_s
6667
settings[key] = settings.delete(deprecated_key)

test/algolia/unit/helpers_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ def test_deserialize_settings_with_string
2626
old_settings = {
2727
'attributesToIndex' => %w(attr1 attr2),
2828
'numericAttributesToIndex' => %w(attr1 attr2),
29-
'slaves' => %w(index1 index2)
29+
'slaves' => %w(index1 index2),
30+
'minWordSizefor1Typo' => 1
3031
}
3132

3233
new_settings = {
3334
'searchableAttributes' => %w(attr1 attr2),
3435
'numericAttributesForFiltering' => %w(attr1 attr2),
35-
'replicas' => %w(index1 index2)
36+
'replicas' => %w(index1 index2),
37+
'minWordSizefor1Typo' => 1
3638
}
3739

3840
deserialized_settings = deserialize_settings(old_settings, false)

0 commit comments

Comments
 (0)