diff --git a/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb b/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb index 0f66efc89..dbb9f6627 100644 --- a/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb +++ b/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb @@ -133,12 +133,4 @@ class Enterprise::Api::V1::AccountsController < Api::BaseController account_user: @current_account_user } end - - def v2_enabled? - Rails.application.config.stripe_v2[:enabled] && @account.custom_attributes['stripe_billing_version'].to_i == 2 - end - - def render_v2_not_enabled - render json: { error: 'V2 billing not enabled for this account' }, status: :unprocessable_entity - end end diff --git a/spec/enterprise/services/enterprise/billing/v2/pricing_plan_service_spec.rb b/spec/enterprise/services/enterprise/billing/v2/pricing_plan_service_spec.rb index 4bd22e4b8..0c01561aa 100644 --- a/spec/enterprise/services/enterprise/billing/v2/pricing_plan_service_spec.rb +++ b/spec/enterprise/services/enterprise/billing/v2/pricing_plan_service_spec.rb @@ -91,12 +91,15 @@ RSpec.describe Enterprise::Billing::V2::PricingPlanService do rate_card = OpenStruct.new(id: 'rc_123', latest_version: 'v1') allow(StripeV2Client).to receive(:request).and_return(cpu, meter, plan, service_action, rate_card) - allow_any_instance_of(Enterprise::Billing::V2::PricingPlanComponentBuilder) - .to receive(:add_license_fee_component).and_return(true) - allow_any_instance_of(Enterprise::Billing::V2::PricingPlanComponentBuilder) - .to receive(:add_service_action_component).and_return(service_action) - allow_any_instance_of(Enterprise::Billing::V2::PricingPlanComponentBuilder) - .to receive(:add_rate_card_component).and_return(rate_card) + + # Create a double for the component builder + component_builder = instance_double(Enterprise::Billing::V2::PricingPlanComponentBuilder) + allow(component_builder).to receive(:add_license_fee_component).and_return(true) + allow(component_builder).to receive(:add_service_action_component).and_return(service_action) + allow(component_builder).to receive(:add_rate_card_component).and_return(rate_card) + + # Stub the private component_builder method to return our double + allow(service).to receive(:component_builder).and_return(component_builder) result = service.create_complete_pricing_plan(config)