require 'rails_helper'

feature 'Admin managing broadcasts' do
  let(:current_user) { create(:user, admin: true, email: 'user@test.com') }
  let(:project) { create(:project, account: current_user.primary_account, name: 'Test Project') }
  let(:broadcast) { create(:broadcast, project: project) }

  before do
    stub_mux_live_stream
    sign_in current_user
  end

  scenario 'admin can edit a broadcast' do
    visit edit_admin_broadcast_path(broadcast)

    fill_in video_conference_url_override_field, with: 'http://test.com'
    click_on submit_button

    expect(page).to have_content(update_notice)
  end

  private

  def video_conference_url_override_field
    Broadcast.human_attribute_name(:video_conference_url_override)
  end

  def submit_button
    'Save Changes'
  end

  def update_notice
    t 'admin.broadcasts.update.notice'
  end
end
