Skip to content

Commit b3129b1

Browse files
committed
ruby: Fix bug with boolean get_if_exists
1 parent bda63fe commit b3129b1

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

ruby/lib/svix/api/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_or_create(application_in, options = {})
4343
"POST",
4444
path,
4545
query_params: {
46-
"get_if_exists" => true
46+
"get_if_exists" => "true"
4747
},
4848
headers: {
4949
"idempotency-key" => options["idempotency-key"]

ruby/spec/json_responses.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,16 @@
217217
"iterator": "iterator",
218218
"prevIterator": "-iterator",
219219
"done": true
220-
}'
220+
}'
221+
ApplicationOut_JSON='{
222+
"uid": "unique-identifier",
223+
"name": "My first application",
224+
"rateLimit": 0,
225+
"id": "app_1srOrx2ZWZBpBUvZwXKQmoEYga2",
226+
"createdAt": "2019-08-24T14:15:22Z",
227+
"updatedAt": "2019-08-24T14:15:22Z",
228+
"metadata": {
229+
"property1": "string",
230+
"property2": "string"
231+
}
232+
}'

ruby/spec/webmock_tests_spec.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@
359359
expect(loaded_from_json.config.schedule).to eql(source_in.config.schedule)
360360
end
361361

362-
363362
it "struct enum without any fields" do
364363
json_source_in = '{"name":"My Stripe Source","uid":"src_123","type":"generic-webhook","config":{}}';
365364
source_in = Svix::IngestSourceIn.new(
@@ -376,10 +375,23 @@
376375
))
377376
expect(loaded_from_json.config.class).to eql(Svix::IngestSourceInConfig::GenericWebhook)
378377
end
378+
379379
it "op webhook body" do
380380
json_event = '{"data":{"data":{"appStats":[{"appId":"app_1srOrx2ZWZBpBUvZwXKQmoEYga2","appUid":null,"messageDestinations":343}]},"status":"finished","task":"application.stats","taskId":"qtask_1srOrx2ZWZBpBUvZwXKQmoEYga2"},"type":"background_task.finished"}';
381381
loaded_from_json = Svix::BackgroundTaskFinishedEvent.deserialize(JSON.parse(json_event))
382382

383383
expect(loaded_from_json.to_json).to eql(json_event)
384384
end
385+
386+
it "application get_or_create" do
387+
stub_request(:post, "#{host}/api/v1/app?get_if_exists=true")
388+
.to_return(
389+
status: 200,
390+
body: ApplicationOut_JSON
391+
)
392+
393+
svx.application.get_or_create({})
394+
395+
expect(WebMock).to(have_requested(:post, "#{host}/api/v1/app?get_if_exists=true"))
396+
end
385397
end

ruby/templates/api_extra/application_create.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def get_or_create(application_in, options = {})
55
"POST",
66
path,
77
query_params: {
8-
"get_if_exists" => true
8+
"get_if_exists" => "true"
99
},
1010
headers: {
1111
"idempotency-key" => options["idempotency-key"]

0 commit comments

Comments
 (0)