require 'spec_helper'

describe InvitedUser do

  subject { page }

  # create an administrative user
  let(:user) { FactoryGirl.create(:admin) }

  before { sign_in user }

  describe "enduser management" do

    # let's go the management page for users
    before { visit  admin_jam_ruby_invited_users_path }
    it { should have_selector('h2', text: "Jam Ruby Invited Users") }

    describe "create service invite" do

      before do

        # create a new user
        UserMailer.deliveries.clear
        visit new_admin_jam_ruby_invited_user_path
        fill_in "jam_ruby_invited_user_email",    with: "some_silly_guy@jamkazam.com"
        #fill_in "jam_ruby_invited_user_sender_id",    with: "some_silly_guy@jamkazam.com"
        #fill_in "jam_ruby_invited_user_autofriend",    with: "some_silly_guy@jamkazam.com"
        click_button "Create Invited user"

      end

      it { should have_selector('#main_content .panel:first-child h3', text: "Jam Ruby Invited User Details" ); }
      it { UserMailer.deliveries.length.should == 1 }
    end
  end
end
