require "rails_helper"

feature "User managing downloads" do
  let(:current_user) { create(:user) }
  let(:project) { create(:project, account: current_user.primary_account) }

  before :each do
    sign_in current_user
  end

  scenario "searching for a downlaod", js: true do
    create(:download_release_type_appearance, project: project)
    create(:download_release_type_music, project: project)

    visit project_downloads_path(project)

    fill_in "query", with: "Music"
    click_on "search-button"

    expect(page).to have_content("Music Release")
    expect(page).not_to have_content("Appearance Release")

    fill_in "query", with: "Natgeo"
    click_on "search-button"
    
    expect(page).not_to have_content("Discovery Contract")
    expect(page).to have_content("Natgeo Contract")
  end
end
