require 'spec_helper'

describe "Artifact Update" do

  include UsesTempFiles
  ARTIFACT_FILE='jkclient-0.1.1.exe'

  subject { page }

  let(:user) { FactoryGirl.create(:admin) }
  before { sign_in user }

  describe "crud" do
    before { visit admin_artifacts_path }
    it { should have_selector('h2', text: "Artifacts") }

    describe "upload artifact" do

      in_directory_with_file(ARTIFACT_FILE)

      before do
        visit new_admin_artifact_path
        fill_in "artifacts_version",    with: "1"
        fill_in "artifacts_environment", with: "public"
        select('JamClient/Win32', from: "artifacts_product")
        fill_in "artifacts_environment", with: "public"
        attach_file("artifacts_uri", ARTIFACT_FILE)
        click_button "Create Artifact update"
      end

      it {
        should have_selector('#main_content .panel:first-child h3', text: "Artifacts Details" ) }
    end
  end
end
