require "rails_helper"

RSpec.describe Recordings::IncrementViews 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!(:user) { User.create!(email: "c@test.com", name: "C", password: "password123", role: "coach") }
  let!(:match) { team.matches.create!(opponent_name: "Rival", scheduled_at: 1.day.from_now) }
  let!(:session) { StreamSession.create!(match: match, user: user, platform: "matchlivetv", status: "ended") }
  let!(:recording) do
    Recording.create!(
      stream_session: session,
      team: team,
      status: "ready",
      expires_at: 10.days.from_now,
      storage_key: "key",
      view_count: 2
    )
  end

  it "increments view_count" do
    described_class.new(recording).call
    expect(recording.reload.view_count).to eq(3)
  end
end
