Skip to content

Commit f33f224

Browse files
authored
Merge pull request #52 from andrewjtait/synonym-set-upsert
fix(synonyms): add upsert method to SynonymSet
2 parents f669f21 + 392475a commit f33f224

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/typesense/synonym_set.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ def initialize(synonym_set_name, api_call)
77
@api_call = api_call
88
end
99

10+
def upsert(params)
11+
@api_call.put(endpoint_path, params)
12+
end
13+
1014
def retrieve
1115
@api_call.get(endpoint_path)
1216
end

spec/typesense/synonym_set_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
# Ignore errors if already deleted
4747
end
4848

49+
describe '#upsert' do
50+
it 'creates a synonym set and returns it' do
51+
skip('SynonymSets is only supported in Typesense v30+') unless typesense_v30_or_above?
52+
53+
result = synonym_set.upsert(synonym_set_data)
54+
55+
expect(result['items']).to eq(synonym_set_data['items'])
56+
end
57+
end
58+
4959
describe '#retrieve' do
5060
it 'returns the specified synonym set' do
5161
skip('SynonymSets is only supported in Typesense v30+') unless typesense_v30_or_above?

0 commit comments

Comments
 (0)