From 0bf5cee73cca355e73c1b043cd8cae1d35437a26 Mon Sep 17 00:00:00 2001 From: Stacy Curry Date: Thu, 9 Oct 2025 09:52:25 -0500 Subject: [PATCH 1/2] add locale to user --- lib/workos/user.rb | 4 +- lib/workos/user_management.rb | 3 + spec/lib/workos/user_management_spec.rb | 11 +++ .../user_management/update_user/locale.yml | 82 +++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml diff --git a/lib/workos/user.rb b/lib/workos/user.rb index 0840d459..6e952815 100644 --- a/lib/workos/user.rb +++ b/lib/workos/user.rb @@ -8,7 +8,7 @@ class User include HashProvider attr_accessor :id, :email, :first_name, :last_name, :email_verified, - :profile_picture_url, :external_id, :last_sign_in_at, :created_at, :updated_at + :profile_picture_url, :external_id, :locale, :last_sign_in_at, :created_at, :updated_at def initialize(json) hash = JSON.parse(json, symbolize_names: true) @@ -20,6 +20,7 @@ def initialize(json) @email_verified = hash[:email_verified] @profile_picture_url = hash[:profile_picture_url] @external_id = hash[:external_id] + @locale = hash[:locale] @last_sign_in_at = hash[:last_sign_in_at] @created_at = hash[:created_at] @updated_at = hash[:updated_at] @@ -34,6 +35,7 @@ def to_json(*) email_verified: email_verified, profile_picture_url: profile_picture_url, external_id: external_id, + locale: locale, last_sign_in_at: last_sign_in_at, created_at: created_at, updated_at: updated_at, diff --git a/lib/workos/user_management.rb b/lib/workos/user_management.rb index 8084e0e1..cc0da3fa 100644 --- a/lib/workos/user_management.rb +++ b/lib/workos/user_management.rb @@ -230,6 +230,7 @@ def create_user( # @param [String] last_name The user's last name. # @param [Boolean] email_verified Whether the user's email address was previously verified. # @param [String] external_id The users's external ID + # @param [String] locale The user's locale. # @param [String] password The user's password. # @param [String] password_hash The user's hashed password. # @option [String] password_hash_type The algorithm originally used to hash the password. @@ -243,6 +244,7 @@ def update_user( last_name: :not_set, email_verified: :not_set, external_id: :not_set, + locale: :not_set, password: :not_set, password_hash: :not_set, password_hash_type: :not_set @@ -255,6 +257,7 @@ def update_user( last_name: last_name, email_verified: email_verified, external_id: external_id, + locale: locale, password: password, password_hash: password_hash, password_hash_type: password_hash_type, diff --git a/spec/lib/workos/user_management_spec.rb b/spec/lib/workos/user_management_spec.rb index 1192e936..af704514 100644 --- a/spec/lib/workos/user_management_spec.rb +++ b/spec/lib/workos/user_management_spec.rb @@ -442,6 +442,16 @@ end end + it 'can update user locale' do + VCR.use_cassette 'user_management/update_user/locale' do + user = described_class.update_user( + id: 'user_01H7TVSKS45SDHN5V9XPSM6H44', + locale: 'en-US', + ) + expect(user.locale).to eq('en-US') + end + end + it 'can update email addresses' do VCR.use_cassette 'user_management/update_user/email' do user = described_class.update_user( @@ -462,6 +472,7 @@ expect(body).not_to have_key(:first_name) expect(body).not_to have_key(:last_name) expect(body).not_to have_key(:email) + expect(body).not_to have_key(:locale) # Return a mock request object double('request') diff --git a/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml b/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml new file mode 100644 index 00000000..7c7193f9 --- /dev/null +++ b/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml @@ -0,0 +1,82 @@ +--- +http_interactions: +- request: + method: put + uri: https://api.workos.com/user_management/users/user_01H7TVSKS45SDHN5V9XPSM6H44 + body: + encoding: UTF-8 + string: '{"locale":"en-US"}' + headers: + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - WorkOS; ruby/3.0.2; arm64-darwin21; v2.16.0 + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Aug 2023 23:37:04 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cf-Ray: + - 7fc7a9287d0330ba-SEA + Cf-Cache-Status: + - DYNAMIC + Etag: + - W/"153-w5d8Z7u7b9Obt9NziECtNSAY9Ac" + Strict-Transport-Security: + - max-age=15552000; includeSubDomains + Vary: + - Origin, Accept-Encoding + Via: + - 1.1 spaces-router (devel) + Access-Control-Allow-Credentials: + - 'true' + Content-Security-Policy: + - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' + https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src + ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests' + Expect-Ct: + - max-age=0 + Referrer-Policy: + - no-referrer + X-Content-Type-Options: + - nosniff + X-Dns-Prefetch-Control: + - 'off' + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - b333b9e1-c9ec-4e99-ae4f-17a854859cf1 + X-Xss-Protection: + - '0' + Set-Cookie: + - __cf_bm=adC6w3NUNGTpdZDzNn39guANJ9wi798uCuqc_EI8190-1693006624-0-AcpsuyzFE/KdM7ev5pSVTt2vnGqCSZBOuQYZ0iKFiJT0mBlAuNITn3hICEKvcZ4LH7JUIyjnEOWfq2w7JyRmrJ4=; + path=/; expires=Sat, 26-Aug-23 00:07:04 GMT; domain=.workos.com; HttpOnly; + Secure; SameSite=None + - __cfruid=1d0cc3edf886cc7b90bd0c9c3226f5611a385c1a-1693006624; path=/; domain=.workos.com; + HttpOnly; Secure; SameSite=None + Server: + - cloudflare + body: + encoding: ASCII-8BIT + string: '{"object":"user","id":"user_01H7TVSKS45SDHN5V9XPSM6H44","email":"willman@blips.app","email_verified":false,"first_name":"Jane","last_name":"Doe","external_id":"123","locale":"en-US","created_at":"2023-08-14T20:28:58.929Z","updated_at":"2023-08-25T22:57:44.262Z","user_type":"unmanaged","email_verified_at":null,"google_oauth_profile_id":null,"microsoft_oauth_profile_id":null}' + http_version: + recorded_at: Fri, 25 Aug 2023 23:37:04 GMT +recorded_with: VCR 5.0.0 \ No newline at end of file From ef73633ebcdcf8794eb4be51a21959bbea6dc04c Mon Sep 17 00:00:00 2001 From: Stacy Curry Date: Fri, 10 Oct 2025 19:41:03 -0500 Subject: [PATCH 2/2] fix cassette --- spec/lib/workos/user_management_spec.rb | 2 +- .../user_management/update_user/locale.yml | 28 ++++++++----------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/spec/lib/workos/user_management_spec.rb b/spec/lib/workos/user_management_spec.rb index af704514..f4626139 100644 --- a/spec/lib/workos/user_management_spec.rb +++ b/spec/lib/workos/user_management_spec.rb @@ -445,7 +445,7 @@ it 'can update user locale' do VCR.use_cassette 'user_management/update_user/locale' do user = described_class.update_user( - id: 'user_01H7TVSKS45SDHN5V9XPSM6H44', + id: 'user_01K78B3ZB5B7119MYEXTQE5KNE', locale: 'en-US', ) expect(user.locale).to eq('en-US') diff --git a/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml b/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml index 7c7193f9..6b3177c6 100644 --- a/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml +++ b/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: put - uri: https://api.workos.com/user_management/users/user_01H7TVSKS45SDHN5V9XPSM6H44 + uri: https://api.workos.com/user_management/users/user_01K78B3ZB5B7119MYEXTQE5KNE body: encoding: UTF-8 string: '{"locale":"en-US"}' @@ -14,7 +14,7 @@ http_interactions: Accept: - "*/*" User-Agent: - - WorkOS; ruby/3.0.2; arm64-darwin21; v2.16.0 + - WorkOS; ruby/3.1.4; arm64-darwin23; v5.25.0 Authorization: - Bearer response: @@ -23,7 +23,7 @@ http_interactions: message: OK headers: Date: - - Fri, 25 Aug 2023 23:37:04 GMT + - Sat, 11 Oct 2025 00:40:19 GMT Content-Type: - application/json; charset=utf-8 Transfer-Encoding: @@ -31,17 +31,15 @@ http_interactions: Connection: - keep-alive Cf-Ray: - - 7fc7a9287d0330ba-SEA + - 98ca4e2ece4df13a-ORD Cf-Cache-Status: - DYNAMIC Etag: - - W/"153-w5d8Z7u7b9Obt9NziECtNSAY9Ac" + - W/"14b-avtqVpGgr9LY49Al2c3gzw62Mbc" Strict-Transport-Security: - max-age=15552000; includeSubDomains Vary: - Origin, Accept-Encoding - Via: - - 1.1 spaces-router (devel) Access-Control-Allow-Credentials: - 'true' Content-Security-Policy: @@ -63,20 +61,16 @@ http_interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - b333b9e1-c9ec-4e99-ae4f-17a854859cf1 + - e9a5015e-44f0-4321-990a-66d2ba4a3e15 X-Xss-Protection: - '0' Set-Cookie: - - __cf_bm=adC6w3NUNGTpdZDzNn39guANJ9wi798uCuqc_EI8190-1693006624-0-AcpsuyzFE/KdM7ev5pSVTt2vnGqCSZBOuQYZ0iKFiJT0mBlAuNITn3hICEKvcZ4LH7JUIyjnEOWfq2w7JyRmrJ4=; - path=/; expires=Sat, 26-Aug-23 00:07:04 GMT; domain=.workos.com; HttpOnly; - Secure; SameSite=None - - __cfruid=1d0cc3edf886cc7b90bd0c9c3226f5611a385c1a-1693006624; path=/; domain=.workos.com; - HttpOnly; Secure; SameSite=None + - _cfuvid=IZBV12JrFjDy0rHr.O3LoIyI0iKnOHdGa_R3uam5bZI-1760143219077-0.0.1.1-604800000; + path=/; domain=.workos.com; HttpOnly; Secure; SameSite=None Server: - cloudflare body: encoding: ASCII-8BIT - string: '{"object":"user","id":"user_01H7TVSKS45SDHN5V9XPSM6H44","email":"willman@blips.app","email_verified":false,"first_name":"Jane","last_name":"Doe","external_id":"123","locale":"en-US","created_at":"2023-08-14T20:28:58.929Z","updated_at":"2023-08-25T22:57:44.262Z","user_type":"unmanaged","email_verified_at":null,"google_oauth_profile_id":null,"microsoft_oauth_profile_id":null}' - http_version: - recorded_at: Fri, 25 Aug 2023 23:37:04 GMT -recorded_with: VCR 5.0.0 \ No newline at end of file + string: '{"object":"user","id":"user_01K78B3ZB5B7119MYEXTQE5KNE","email":"test-locale@example.com","email_verified":false,"first_name":"Jane","last_name":"Doe","profile_picture_url":null,"metadata":{},"last_sign_in_at":null,"locale":"en-US","created_at":"2025-10-11T00:35:49.727Z","updated_at":"2025-10-11T00:40:19.051Z","external_id":null}' + recorded_at: Sat, 11 Oct 2025 00:40:19 GMT +recorded_with: VCR 6.3.1