Skip to content

Commit eed9d37

Browse files
committed
Add tests
1 parent 6d48ed2 commit eed9d37

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

lib/typesense/documents.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def initialize(collection_name, api_call)
1212
@documents = {}
1313
end
1414

15-
def create(document, query_parameters = {})
16-
@api_call.post(endpoint_path, document, query_parameters)
15+
def create(document)
16+
@api_call.post(endpoint_path, document)
1717
end
1818

1919
def upsert(document, query_parameters = {})

spec/typesense/document_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@
6868
headers: {
6969
'Content-Type' => 'application/json',
7070
'X-Typesense-Api-Key' => typesense.configuration.api_key
71+
},
72+
query: {
73+
dirty_values: 'coerce_or_reject'
7174
}
7275
)
7376
.to_return(status: 200, body: JSON.dump(partial_document), headers: { 'Content-Type': 'application/json' })
7477

75-
result = document_124.update(partial_document)
78+
result = document_124.update(partial_document, dirty_values: 'coerce_or_reject')
7679

7780
expect(result).to eq(partial_document)
7881
end

spec/typesense/documents_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@
6767
'Content-Type' => 'application/json'
6868
},
6969
query: {
70-
'action' => 'update'
70+
'action' => 'update',
71+
'dirty_values' => 'coerce_or_reject'
7172
})
7273
.to_return(status: 200, body: JSON.dump(document), headers: { 'Content-Type': 'application/json' })
7374

74-
result = companies_documents.update(document)
75+
result = companies_documents.update(document, dirty_values: 'coerce_or_reject')
7576

7677
expect(result).to eq(document)
7778
end
@@ -86,11 +87,12 @@
8687
'Content-Type' => 'application/json'
8788
},
8889
query: {
89-
'action' => 'upsert'
90+
'action' => 'upsert',
91+
'dirty_values' => 'coerce_or_reject'
9092
})
9193
.to_return(status: 200, body: JSON.dump(document), headers: { 'Content-Type': 'application/json' })
9294

93-
result = companies_documents.upsert(document)
95+
result = companies_documents.upsert(document, dirty_values: 'coerce_or_reject')
9496

9597
expect(result).to eq(document)
9698
end

0 commit comments

Comments
 (0)