Files
eminuxandCursor e436f5ece4 Aggiunge pagamento con bonifico e importo concordato per società.
Il piano si attiva solo dopo la conferma admin; Stripe resta a listino se non c'è un prezzo commerciale.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 23:20:43 +02:00

55 lines
2.2 KiB
Ruby

require "rails_helper"
RSpec.describe "Admin bank transfer", type: :request do
let!(:admin) { AdminAccount.create!(username: "ops-bt-http", password: "Password123") }
let!(:club) do
c = Club.create!(
name: "Admin BT Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff",
billing_entity_type: "company", billing_legal_name: "ASD Admin BT", billing_email: "adminbt@test.it",
billing_address_line: "Via 1", billing_city: "Milano", billing_province: "MI", billing_postal_code: "20100",
billing_country: "IT", billing_vat_number: "12345678901", billing_recipient_code: "ABCDEFG"
)
load Rails.root.join("db/seeds/plans.rb")
Billing::AssignPlan.call(club: c, plan_slug: "free")
c
end
before do
post admin_login_path, params: { username: "ops-bt-http", password: "Password123" }
end
it "salva il prezzo concordato sulla società" do
post set_quote_admin_club_path(club), params: {
plan_slug: "premium_full",
interval: "yearly",
amount_euros: "175,50",
note: "Accordo regionale"
}
expect(response).to redirect_to(admin_club_path(club))
quote = club.reload.active_billing_quote
expect(quote.amount_cents).to eq(17_550)
expect(quote.note).to eq("Accordo regionale")
end
it "conferma un bonifico in attesa e attiva il piano" do
allow(MatchLiveTv).to receive_messages(
bank_transfer_configured?: true,
bank_transfer_iban: "IT60X0542811101000000123456",
bank_transfer_account_holder: "Match Live TV",
bank_transfer_bank_name: "Banca",
bank_transfer_bic: "TESTITMM",
bank_transfer_proof_email: "info@matchlivetv.it"
)
user = User.create!(email: "req@test.it", name: "R", password: "Password123", role: "coach")
ClubMembership.create!(user: user, club: club, role: "owner")
order = Billing::RequestBankTransfer.call(club: club, user: user, plan_slug: "premium_light", interval: "monthly")
post admin_billing_transfer_confirm_path(order)
expect(response).to redirect_to(admin_billing_path(club_id: club.id))
expect(club.reload.subscription.plan.slug).to eq("premium_light")
expect(order.reload).to be_paid
end
end