require 'spec_helper'

describe 'fixxperts dashboard' do

  
  describe 'Update your profile alert' do

    # subtrades
    #----------------------------------------------------------------------

    it 'should show a link to subtrades if no filled' do
      fixxpert = create :fixxpert, has_amazon_account: true
      login_as_user fixxpert
      within '#wizard_box' do
        page.should have_content 'subtrades'
      end
    end

    it 'should not show a link to subtrades if filled' do
      pending "condition is removed"
      fixxpert = create :fixxpert
      subtrade = create :subtrade
      fixxpert.subtrade_ids = [subtrade.id]

      login_as_user fixxpert
      within '#wizard_box' do
        page.should_not have_content 'subtrades'
      end
    end

    # trades
    #----------------------------------------------------------------------

    it 'should show a link to trades if no filled' do
      fixxpert = create :fixxpert
      login_as_user fixxpert
      within '#wizard_box' do
        page.should have_content 'trades'
      end
    end

    it 'should not show a link to trades if filled' do
      pending "condition is removed"
      fixxpert = create :fixxpert
      trade = create :trade
      fixxpert.trade_ids = [trade.id]

      login_as_user fixxpert
      within '#wizard_box' do
        page.should_not have_content 'trades'
      end
    end


    # Avatar
    #----------------------------------------------------------------------

    it 'should show a link to settings if fixxpert has not avatar' do
      pending "photo is removed"
      fixxpert = create :fixxpert
      login_as_user fixxpert
      within '#wizard_box' do
        page.should have_content 'your photo'
      end
    end

    it 'should not show a link to settings if fixxpert has avatar' do
      pending "photo is removed"
      picture_path = File.join(Rails.root, 'spec', 'fixtures', 'picture.png')
      fixxpert = create :fixxpert, avatar: File.new(picture_path)
      login_as_user fixxpert
      within '#wizard_box' do
        page.should_not have_content 'your photo'
      end
    end

  end

  describe 'Search results alert' do

    before(:each) do
      pending "#search_alert is not in app"
    end

    # rate
    #----------------------------------------------------------------------

    it 'should show a link to search if no filled' do
      fixxpert = create :fixxpert, rate: 0
      login_as_user fixxpert
      within '#search_alert' do
        page.should have_content 'Rate'
      end
    end

    it 'should not show a link to search if filled' do
      fixxpert = create :fixxpert, rate: 10
      login_as_user fixxpert
      page.should_not have_css '#search_alert'
    end


    # availability
    #----------------------------------------------------------------------

    it 'should show a link to availability if no filled' do
      fixxpert = create :fixxpert, availability_defaults: nil
      login_as_user fixxpert
      within '#search_alert' do
        page.should have_content 'Availability'
      end
    end

    it 'should not show a link to availability if filled' do
      fixxpert = create :fixxpert
      login_as_user fixxpert
      page.should_not have_css '#search_alert'
    end

    #Profile counts
    #---------------------------------------------------------------------------
  end

  describe "should have" do
    it " profile counts" do
      fixxpert = create :fixxpert
      login_as_user fixxpert
      page.should have_content 'Profile Views'
    end
  end

  describe "should have link to" do
    before do
      fixxpert = create :fixxpert
      login_as_user fixxpert
    end
    it{ page.should have_link 'Contents' }
  end
end
