require 'rails_helper'

RSpec.describe Public::ZoomMeetingsController, type: :controller do
  let(:user) { create(:user) }
  let(:account) { user.primary_account }
  let(:project) { create(:project, account: user.primary_account) }
  let(:broadcast) { create(:broadcast, name: "Broadcast", project: project) }

  let(:meeting_start_url) { "http://meeting_start_url" }
  let(:meeting_hash) { HashWithIndifferentAccess.new(start_url: meeting_start_url) }

  before :each do
    allow_any_instance_of(ZoomGateway).to receive(:find_meeting).and_return(meeting_hash)
    allow_any_instance_of(ZoomGateway).to receive(:create_meeting).and_return("meeting_id")
    allow_any_instance_of(ZoomGateway).to receive(:create_host).and_return("host_id")
    allow(MuxLiveStream).to receive(:new).and_return OpenStruct.new(id: 'id', key: 'key', playback_id: 'playback_id')
  end

  describe "#show" do
    it "redirects to meeting start url" do
      get :show, params: { broadcast_token: broadcast.token }
      expect(response).to redirect_to(meeting_start_url)
    end
  end
end
