require 'spec_helper'

describe "the user is not a fixxpert" do

  let(:customer) { create :customer }

  it "should not see the manage trades link" do
    login_as_user customer
    page.should_not have_css "#fixxpert_trades_link"
  end

  it "should not be allowed to visit the manage trades page" do
    login_as_user customer
    visit fixxpert_trades_path
    current_path.should eq home_path
  end

end

describe "the fixxpert clicks the manage trades button" do
  it "should be redirected to the manage trades page" do
    fixxpert = create :fixxpert
    login_as_user fixxpert
    click_link "fixxpert_trades_link"
    current_path.should eq fixxpert_trades_path
  end

  it 'should pdate tutur trades', js: true do
    fixxpert = create :fixxpert
    login_as_user fixxpert
    click_link "fixxpert_trades_link"
    find('#trades_form').visible?.should be_false
    find('button#hide_trades_form').visible?.should be_false
    click_button 'show_trades_form'

    find('#trades_form').visible?.should be_true
    find('button#show_trades_form').visible?.should be_false
    find('button#hide_trades_form').visible?.should be_true
    click_button 'hide_trades_form'
    find('#trades_form').visible?.should be_false
    find('button#hide_trades_form').visible?.should be_false

  end

end
