Dopo la conferma admin la card restava su «Paga con bonifico»; la società parte da Free, l'owner è staff trasmissione e le mail non bloccano se manca SMTP. Co-authored-by: Cursor <cursoragent@cursor.com>
90 lines
3.5 KiB
Ruby
90 lines
3.5 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Public bank transfer billing", type: :request do
|
|
let!(:coach) do
|
|
User.create!(email: "bt-coach@test.it", name: "Coach", password: "Password123", role: "coach")
|
|
end
|
|
let!(:club) do
|
|
c = Club.create!(
|
|
name: "BT HTTP Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff",
|
|
billing_entity_type: "company", billing_legal_name: "ASD BT", billing_email: "bill@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"
|
|
)
|
|
ClubMembership.create!(user: coach, club: c, role: "owner")
|
|
c.teams.create!(name: "U15", sport: "volleyball")
|
|
load Rails.root.join("db/seeds/plans.rb")
|
|
Billing::AssignPlan.call(club: c, plan_slug: "free")
|
|
c
|
|
end
|
|
|
|
before do
|
|
allow(MatchLiveTv).to receive_messages(
|
|
stripe_enabled?: true,
|
|
stripe_premium_light_yearly_price_id: "py",
|
|
stripe_premium_light_monthly_price_id: "pm",
|
|
stripe_premium_full_yearly_price_id: "fy",
|
|
stripe_premium_full_monthly_price_id: "fm",
|
|
bank_transfer_configured?: true,
|
|
bank_transfer_iban: "IT60X0542811101000000123456",
|
|
bank_transfer_account_holder: "Match Live TV",
|
|
bank_transfer_bank_name: "Banca Test",
|
|
bank_transfer_bic: "TESTITMM",
|
|
bank_transfer_proof_email: "info@matchlivetv.it"
|
|
)
|
|
post public_login_path, params: { email: coach.email, password: "Password123" }
|
|
end
|
|
|
|
it "mostra il pulsante bonifico a listino" do
|
|
get public_club_billing_path(club)
|
|
expect(response).to have_http_status(:ok)
|
|
expect(response.body).to include("Paga con bonifico")
|
|
end
|
|
|
|
it "accetta la richiesta di bonifico senza attivare il piano" do
|
|
post public_club_billing_bank_transfer_path(club, plan: "premium_light", interval: "yearly")
|
|
expect(response).to redirect_to(public_club_billing_path(club))
|
|
expect(club.reload.subscription.plan.slug).to eq("free")
|
|
expect(club.billing_transfer_orders.awaiting_payment).to exist
|
|
end
|
|
|
|
it "con prezzo concordato nasconde Stripe e mostra l'importo" do
|
|
Billing::SetClubQuote.upsert(
|
|
club: club, plan_slug: "premium_full", interval: "yearly",
|
|
amount_euros: "120", note: "Test", admin: nil
|
|
)
|
|
|
|
get public_club_billing_path(club)
|
|
expect(response.body).to include("Prezzo concordato")
|
|
expect(response.body).to include("€120")
|
|
expect(response.body).to include("Paga con bonifico")
|
|
expect(response.body).not_to include("Attiva Full — €199/anno")
|
|
end
|
|
|
|
it "con prezzo concordato già attivato mostra Piano attivo e nasconde il pagamento" do
|
|
Billing::SetClubQuote.upsert(
|
|
club: club, plan_slug: "premium_full", interval: "yearly",
|
|
amount_euros: "99", note: "Test", admin: nil
|
|
)
|
|
Billing::AssignPlan.call(
|
|
club: club,
|
|
plan_slug: "premium_full",
|
|
status: "active",
|
|
stripe_attrs: {
|
|
stripe_subscription_id: nil,
|
|
billing_interval: "yearly",
|
|
current_period_start: Time.current,
|
|
current_period_end: 1.year.from_now,
|
|
cancel_at_period_end: true
|
|
}
|
|
)
|
|
|
|
get public_club_billing_path(club)
|
|
expect(response.body).to include("Piano attivo")
|
|
expect(response.body).to include("In questo momento vale")
|
|
expect(response.body).to include("€99")
|
|
expect(response.body).not_to include("Paga con bonifico")
|
|
expect(response.body).not_to include("Il piano resta quello attuale finché Match Live TV non conferma")
|
|
end
|
|
end
|