require "rails_helper" RSpec.describe Teams::Entitlements do let!(:club) { Club.create!(name: "Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") } let!(:team) { club.teams.create!(name: "Team", sport: "volleyball") } before do load Rails.root.join("db/seeds/plans.rb") Billing::AssignPlan.call(club: club, plan_slug: "free") end it "non consente copertina custom su free" do ent = described_class.new(team) expect(ent.can_use_custom_cover?).to eq(false) expect { ent.assert_can_upload_cover! }.to raise_error(Teams::EntitlementError, /Premium Full/) end it "consente copertina custom su premium full" do Billing::AssignPlan.call(club: club, plan_slug: "premium_full") ent = described_class.new(team) expect(ent.can_use_custom_cover?).to eq(true) expect { ent.assert_can_upload_cover! }.not_to raise_error end it "espone custom_cover_enabled in as_json" do Billing::AssignPlan.call(club: club, plan_slug: "premium_full") ent = described_class.new(team) expect(ent.as_json[:custom_cover_enabled]).to eq(true) end end