require 'spec_helper'

describe 'A logged customer visiting the fixxperts page' do
  let(:customer) { create :customer, name: 'Jhon Doe', email: 'jhon@foobar.com' }
  describe 'should view a list of fixxperts' do

    before do
      login_as_user customer
      click_link 'Fixxpert'
    end

    it "should have your fixxperts link" do
      click_link 'Your fixxperts'
      current_path.should eq customer_fixxperts_path
    end

    it "should have find fixxpert and the fixxpert name", :js => true do

      fixxpert1 = create :fixxpert
      fixxpert2 = build :fixxpert, availability_defaults: nil, searchable: false

      click_link 'Find a fixxpert'
      current_path.should eq search_customer_fixxperts_path
      page.should have_content fixxpert1.name
      page.should_not have_content fixxpert2.name
    end
  end
end


describe 'A visitor visiting the fixxperts page' do
  it 'should view a list of fixxperts' do

    fixxpert1 = create :fixxpert
    fixxpert2 = build :fixxpert, availability_defaults: nil, searchable: false
    visit root_path
    click_button 'submit_customer_fixxperts_search'
    current_path.should eq search_customer_fixxperts_path
    page.should have_content fixxpert1.name
    page.should_not have_content fixxpert2.name
  end

end
