mirror of
https://github.com/we-promise/sure.git
synced 2026-04-09 07:14:47 +00:00
* Hide payment contribution options from demo and manually created users Demo data users and manually created users don't have stripe_customer_id set on their family, so they should not see payment/contribution options. Changes: - Add can_manage_subscription? method to Family::Subscribeable that checks for presence of stripe_customer_id - Guard Settings::PaymentsController to return 403 for users without stripe_customer_id - Guard SubscriptionsController#show action (Stripe portal redirect) for users without stripe_customer_id - Update settings navigation to hide the payment link when stripe_customer_id is not present - Add tests for the new behavior * Fix broken test --------- Co-authored-by: Claude <noreply@anthropic.com>
29 lines
973 B
Ruby
29 lines
973 B
Ruby
require "test_helper"
|
|
|
|
class Family::SubscribeableTest < ActiveSupport::TestCase
|
|
setup do
|
|
@family = families(:dylan_family)
|
|
end
|
|
|
|
# We keep the status eventually consistent, but don't rely on it for guarding the app
|
|
test "trial respects end date even if status is not yet updated" do
|
|
@family.subscription.update!(trial_ends_at: 1.day.ago, status: "trialing")
|
|
assert_not @family.trialing?
|
|
end
|
|
|
|
test "can_manage_subscription? returns true when stripe_customer_id is present" do
|
|
@family.update!(stripe_customer_id: "cus_test123")
|
|
assert @family.can_manage_subscription?
|
|
end
|
|
|
|
test "can_manage_subscription? returns false when stripe_customer_id is nil" do
|
|
@family.update!(stripe_customer_id: nil)
|
|
assert_not @family.can_manage_subscription?
|
|
end
|
|
|
|
test "can_manage_subscription? returns false when stripe_customer_id is blank" do
|
|
@family.update!(stripe_customer_id: "")
|
|
assert_not @family.can_manage_subscription?
|
|
end
|
|
end
|