require "rails_helper" RSpec.describe GenerateCoverSlateJob do let!(:club) { Club.create!(name: "Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") } let!(:team) { club.teams.create!(name: "Team", sport: "volleyball") } let!(:match) { team.matches.create!(opponent_name: "Opp", sport: "volleyball") } before do load Rails.root.join("db/seeds/plans.rb") match.cover_image.attach( io: StringIO.new("img"), filename: "c.png", content_type: "image/png" ) end it "usa coda critical per Match" do expect(described_class).to receive(:set).with(queue: :critical).and_return(described_class) expect(described_class).to receive(:perform_later).with("Match", match.id) described_class.enqueue_for(match) end it "usa coda default per Club" do club.cover_image.attach(io: StringIO.new("img"), filename: "c.png", content_type: "image/png") expect(described_class).to receive(:set).with(queue: :default).and_return(described_class) expect(described_class).to receive(:perform_later).with("Club", club.id) described_class.enqueue_for(club) end it "invoca GenerateCoverSlate al perform" do expect(Streams::GenerateCoverSlate).to receive(:call).with(match) described_class.perform_now("Match", match.id) end end