diff --git a/app/controllers/api/v1/subscriptions_controller.rb b/app/controllers/api/v1/subscriptions_controller.rb index 98604d5a2a5..639cd230316 100644 --- a/app/controllers/api/v1/subscriptions_controller.rb +++ b/app/controllers/api/v1/subscriptions_controller.rb @@ -159,6 +159,7 @@ def plan_overrides :billable_metric_id, :min_amount_cents, :invoice_display_name, + :charge_model, { properties: {} }, { group_properties: [ diff --git a/db/schema.rb b/db/schema.rb index b43b90f43a1..1a8ea1f1ec8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -433,8 +433,8 @@ t.jsonb "metadata", default: {}, null: false t.uuid "subscription_id" t.datetime "deleted_at" - t.string "external_customer_id" t.string "external_subscription_id" + t.string "external_customer_id" t.index ["customer_id"], name: "index_events_on_customer_id" t.index ["deleted_at"], name: "index_events_on_deleted_at" t.index ["organization_id", "code", "created_at"], name: "index_events_on_organization_id_and_code_and_created_at", where: "(deleted_at IS NULL)" diff --git a/spec/services/plans/update_service_spec.rb b/spec/services/plans/update_service_spec.rb index 4ca1d8c47b1..78a74906882 100644 --- a/spec/services/plans/update_service_spec.rb +++ b/spec/services/plans/update_service_spec.rb @@ -153,6 +153,29 @@ end end + context 'with new charge' do + let(:plan_name) { 'foo' } + + let(:charges_args) do + [ + { + billable_metric_id: sum_billable_metric.id, + charge_model: 'standard', + pay_in_advance: false, + invoiceable: true, + properties: { + amount: '100', + }, + }, + ] + end + + it 'updates the plan' do + result = plans_service.call + expect(result.plan.charges.count).to eq(1) + end + end + context 'with premium charge model' do let(:plan_name) { 'foo' }