require 'spec_helper'

describe 'Send invitation to others' do
  it 'should fail with invalid values' do
    user = create :customer
    login_as_user user
    click_link 'invite_others_button'
    fill_in 'name', with: ''
    fill_in 'message', with: ''
    click_button 'submit'

    page.should have_content "Name can't be blank"
    page.should have_content "Emails can't be blank"
    page.should have_content "Message can't be blank"
  end

  it 'should send invitations' do
    user = create :customer
    login_as_user user
    click_link 'invite_others_button'
    fill_in 'name', with: 'New user'
    fill_in 'email_list', with: 'user@email.com, user2@email.com'
    click_button 'submit'
    current_path.should eq home_path
    page.should have_content 'Invitations sent'
  end

end
