require 'spec_helper'

describe MusicSessionsController, type: :controller do

  let(:user) { FactoryGirl.create(:user, subscription_plan_code: 'jamsubplatinum') }
  let(:music_session) { FactoryGirl.create(:active_music_session, :creator => user) }
  let(:connection) { FactoryGirl.create(:connection,
                                  :user => user,
                                  :music_session => music_session,
                                  :addr => "1.1.1.1",
                                  ) }




  before(:each) do
    MusicSession.delete_all
    ActiveMusicSession.delete_all
    controller.current_user = user
    connection.connect!
  end

  describe "video conferencing server url" do
    it "GET /video/room/:music_session_id" do
      get :session_video, music_session_id: music_session.id
      temp_token = TempToken.order(created_at: :desc).first
      expect(temp_token.user).to eq(user)
      video_conf_url = "#{Rails.application.config.video_conferencing_host}/room/#{music_session.id}?token=#{temp_token.token}"
      #response.should redirect_to video_conf_url
      resp = {
        url: video_conf_url
      }
      response.body.should == resp.to_json
    end
  end
end
