require "rails_helper"

RSpec.feature "User can see directories on project page", type: :feature do
  before do
    sign_in(user)
  end

  let!(:project) { create(:project_with_directories, members: user, account: user.primary_account) }

  context "User is an associate" do
    let(:user) { create(:user, :associate) }

    scenario "user is associate" do
      visit project_path(project)

      expect(page).to have_link("Add Folder")
      expect(page).to have_content("Shared")
      expect(page).not_to have_content("Financial Documents")
      expect(page).not_to have_content("Salaries")
    end
  end

  context "User is a project manager" do
    let(:user) { create(:user, :manager) }

    scenario "user is associate" do
      visit project_path(project)

      expect(page).to have_link("Add Folder")
      expect(page).to have_content("Shared")
      expect(page).to have_content("Financial Documents")
      expect(page).not_to have_content("Salaries")
    end
  end

  context "User is a account manager" do
    let(:user) { create(:user, :account_manager) }
    let!(:project) { create(:project_with_directories, account: user.primary_account) }

    scenario "user is associate" do
      visit project_path(project)

      expect(page).to have_link("Add Folder")
      expect(page).to have_content("Shared")
      expect(page).to have_content("Financial Documents")
      expect(page).to have_content("Salaries")
    end
  end
end
