Skip to content

Commit 1d03bba

Browse files
committed
Test that external_id can be set to null
1 parent 5601943 commit 1d03bba

File tree

4 files changed

+196
-0
lines changed

4 files changed

+196
-0
lines changed

spec/lib/workos/organizations_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,28 @@
340340
end
341341
end
342342
end
343+
344+
context 'can set external_id to null explicitly' do
345+
it 'includes external_id null in request body' do
346+
original_method = described_class.method(:put_request)
347+
allow(described_class).to receive(:put_request) do |kwargs|
348+
original_method.call(**kwargs)
349+
end
350+
351+
VCR.use_cassette 'organization/update_with_external_id_null' do
352+
described_class.update_organization(
353+
organization: "org_01K0SQV0S6EPWK2ZDEFD1CP1JC",
354+
name: 'Test Organization',
355+
external_id: nil,
356+
)
357+
end
358+
359+
# Verify the spy captured the right call
360+
expect(described_class).to have_received(:put_request).with(
361+
hash_including(body: hash_including(external_id: nil))
362+
)
363+
end
364+
end
343365
end
344366

345367
describe '.delete_organization' do

spec/lib/workos/user_management_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,25 @@
442442
)
443443
end
444444

445+
it 'can set external_id to null explicitly' do
446+
original_method = described_class.method(:put_request)
447+
allow(described_class).to receive(:put_request) do |kwargs|
448+
original_method.call(**kwargs)
449+
end
450+
451+
VCR.use_cassette 'user_management/update_user_external_id_null' do
452+
described_class.update_user(
453+
id: 'user_01K0SR53HJ58M957MYAB6TDZ9X',
454+
first_name: 'John',
455+
external_id: nil,
456+
)
457+
end
458+
459+
expect(described_class).to have_received(:put_request).with(
460+
hash_including(body: hash_including(external_id: nil))
461+
)
462+
end
463+
445464
context 'with an invalid payload' do
446465
it 'returns an error' do
447466
VCR.use_cassette 'user_management/update_user/invalid' do

spec/support/fixtures/vcr_cassettes/organization/update_with_external_id_null.yml

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/support/fixtures/vcr_cassettes/user_management/update_user_external_id_null.yml

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)