user upgrades: add links to Stripe payment & receipt page.

Add links to the Stripe payment page and the Stripe receipt page on
completed user upgrades.

The Stripe payment link is a link to the payment details on the Stripe
dashboard and is only visible to the owner.
This commit is contained in:
evazion
2020-12-28 22:25:09 -06:00
parent e29e2da8be
commit 87af02f689
8 changed files with 154 additions and 6 deletions

View File

@@ -121,6 +121,68 @@ class UserUpgradesControllerTest < ActionDispatch::IntegrationTest
end
end
context "receipt action" do
mock_stripe!
setup do
@user_upgrade = create(:gift_gold_upgrade, status: "complete")
@user_upgrade.create_checkout!
end
should "not allow unauthorized users to view the receipt" do
get_auth receipt_user_upgrade_path(@user_upgrade), create(:user)
assert_response 403
end
should "not allow the recipient to view the receipt" do
get_auth receipt_user_upgrade_path(@user_upgrade), @user_upgrade.recipient
assert_response 403
end
should "not allow the purchaser to view a pending receipt" do
@user_upgrade.update!(status: "pending")
get_auth receipt_user_upgrade_path(@user_upgrade), @user_upgrade.purchaser
assert_response 403
end
# XXX not supported yet by stripe-ruby-mock
should_eventually "allow the purchaser to view the receipt" do
get_auth receipt_user_upgrade_path(@user_upgrade), @user_upgrade.purchaser
assert_redirected_to "xxx"
end
# XXX not supported yet by stripe-ruby-mock
should_eventually "allow the site owner to view the receipt" do
get_auth receipt_user_upgrade_path(@user_upgrade), create(:owner_user)
assert_redirected_to "xxx"
end
end
context "payment action" do
setup do
@user_upgrade = create(:gift_gold_upgrade, status: "complete")
@user_upgrade.create_checkout!
end
should "not allow unauthorized users to view the receipt" do
get_auth payment_user_upgrade_path(@user_upgrade), @user_upgrade.purchaser
assert_response 403
end
# XXX not supported yet by stripe-ruby-mock
should_eventually "allow the site owner to view the receipt" do
get_auth payment_user_upgrade_path(@user_upgrade), create(:owner_user)
assert_redirected_to "xxx"
end
end
context "create action" do
mock_stripe!