require 'spec_helper'

describe "broadcast notification", :js => true, :type => :feature, :capybara_feature => true  do

  subject { page }

  let(:broadcast1) {FactoryGirl.create(:broadcast_notification, frequency: 4)}
  let(:broadcast2) {FactoryGirl.create(:broadcast_notification, frequency: 4)}
  let(:user) { FactoryGirl.create(:user) }
  let(:partner) { FactoryGirl.create(:affiliate_partner) }

  before(:each) do
    BroadcastNotificationView.delete_all
    BroadcastNotification.delete_all
  end

  it "cycles on home screen" do
    broadcast1.touch

    fast_signin(user, '/client')
    find('.broadcast-notification .message', text: broadcast1.message)

    broadcast2.touch

    visit current_path
    find('.broadcast-notification .message', text: broadcast2.message)

    visit current_path
    find('.broadcast-notification .message', text: broadcast1.message)
    find('.broadcast-notification .not-now').trigger(:click)

    visit current_path
    find('.broadcast-notification .message', text: broadcast2.message)

    go_to_root

    visit '/client'
    find('.broadcast-notification .message', text: broadcast2.message)
  end
end
