require "rails_helper" RSpec.describe Billing::SetClubQuote do let(:admin) { AdminAccount.create!(username: "ops-quote", password: "Password123") } let(:club) do c = Club.create!(name: "Quote Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") load Rails.root.join("db/seeds/plans.rb") Billing::AssignPlan.call(club: c, plan_slug: "free") c end it "salva l'importo in centesimi per la società" do quote = described_class.upsert( club: club, plan_slug: "premium_full", interval: "yearly", amount_euros: "150,00", note: "Accordo sponsor", admin: admin ) expect(quote).to be_active expect(quote.amount_cents).to eq(15_000) expect(quote.plan_slug).to eq("premium_full") expect(club.reload.active_billing_quote).to eq(quote) end it "revoca il prezzo concordato" do described_class.upsert( club: club, plan_slug: "premium_light", interval: "monthly", amount_euros: "5", note: nil, admin: admin ) described_class.revoke(club: club, admin: admin) expect(club.reload.active_billing_quote).to be_nil end end