From 4e33490676b234ad0accf66109d62532f07e0234 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Tue, 2 Jun 2026 16:26:21 +0530 Subject: [PATCH] fix(billing): keep topup_checkout un-gated and seed topup options config in specs --- .../controllers/enterprise/api/v1/accounts_controller.rb | 2 +- .../enterprise/api/v1/accounts_controller_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb b/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb index cf055d421..f7c6ca403 100644 --- a/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb +++ b/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb @@ -2,7 +2,7 @@ class Enterprise::Api::V1::AccountsController < Api::BaseController include BillingHelper before_action :fetch_account before_action :check_authorization - before_action :check_cloud_env, only: [:limits, :toggle_deletion, :topup_checkout, :topup_options] + before_action :check_cloud_env, only: [:limits, :toggle_deletion, :topup_options] def subscription if stripe_customer_id.blank? && @account.custom_attributes['is_creating_customer'].blank? diff --git a/spec/enterprise/controllers/enterprise/api/v1/accounts_controller_spec.rb b/spec/enterprise/controllers/enterprise/api/v1/accounts_controller_spec.rb index b2a920b07..f840ddc11 100644 --- a/spec/enterprise/controllers/enterprise/api/v1/accounts_controller_spec.rb +++ b/spec/enterprise/controllers/enterprise/api/v1/accounts_controller_spec.rb @@ -256,6 +256,14 @@ RSpec.describe 'Enterprise Billing APIs', type: :request do { 'name' => 'Hacker', 'product_id' => ['prod_hacker'], 'price_ids' => ['price_hacker'] }, { 'name' => 'Business', 'product_id' => ['prod_business'], 'price_ids' => ['price_business'] } ]) + create(:installation_config, name: 'CHATWOOT_CLOUD_TOPUP_OPTIONS', value: { + 'usd' => [ + { 'credits' => 1000, 'amount' => 20.0 }, + { 'credits' => 2500, 'amount' => 50.0 }, + { 'credits' => 6000, 'amount' => 100.0 }, + { 'credits' => 12_000, 'amount' => 200.0 } + ] + }) end it 'returns unauthorized for unauthenticated user' do