From 76a4140224a1bfbbcd31e222c4cd18baedc05b38 Mon Sep 17 00:00:00 2001 From: Honza Sterba Date: Wed, 20 Nov 2024 13:39:17 +0000 Subject: [PATCH] fix: Feature flags are not be stored on account creation (#10387) when creating an account via the platform API the feature flags do not get stored Co-authored-by: Sojan Jose --- app/controllers/platform/api/v1/accounts_controller.rb | 1 + .../platform/api/v1/accounts_controller_spec.rb | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/platform/api/v1/accounts_controller.rb b/app/controllers/platform/api/v1/accounts_controller.rb index 9e6d53fef..e11cf9d4a 100644 --- a/app/controllers/platform/api/v1/accounts_controller.rb +++ b/app/controllers/platform/api/v1/accounts_controller.rb @@ -4,6 +4,7 @@ class Platform::Api::V1::AccountsController < PlatformController def create @resource = Account.create!(account_params) update_resource_features + @resource.save! @platform_app.platform_app_permissibles.find_or_create_by(permissible: @resource) end diff --git a/spec/controllers/platform/api/v1/accounts_controller_spec.rb b/spec/controllers/platform/api/v1/accounts_controller_spec.rb index db1713bb6..c7b5b275b 100644 --- a/spec/controllers/platform/api/v1/accounts_controller_spec.rb +++ b/spec/controllers/platform/api/v1/accounts_controller_spec.rb @@ -60,11 +60,10 @@ RSpec.describe 'Platform Accounts API', type: :request do } }, headers: { api_access_token: platform_app.access_token.token }, as: :json json_response = response.parsed_body + created_account = Account.find(json_response['id']) + expect(created_account.enabled_features.keys).to match_array(%w[inbox_management ip_lookup help_center]) expect(json_response['name']).to include('Test Account') - expect(json_response['features']['inbox_management']).to be(true) - expect(json_response['features']['ip_lookup']).to be(true) - expect(json_response['features']['help_center']).to be(true) - expect(json_response['features']['disable_branding']).to be_nil + expect(json_response['features'].keys).to match_array(%w[inbox_management ip_lookup help_center]) end it 'creates an account with limits settings' do