Sha256: e7b25831af633d3e800b9f04accbe6ad253777fadc71f1ed0d53b14dc599fbbc

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'redlock'

feature 'Creating a new Work', :workflow do
  let(:user) { FactoryGirl.create(:user) }

  let(:redlock_client_stub) { # stub out redis connection
    client = double('redlock client')
    allow(client).to receive(:lock).and_yield(true)
    allow(Redlock::Client).to receive(:new).and_return(client)
    client
  }

  before do
    col = Collection.new title: ['Test Collection']
    col.apply_depositor_metadata user.user_key
    col.save!
    sign_in user

    # stub out characterization. Travis doesn't have fits installed, and it's not relevant to the test.
    allow(CharacterizeJob).to receive(:perform_later)
    redlock_client_stub
  end

  it 'creates the work and allow you to attach a file' do
    visit '/concern/generic_works/new'
    work_title = 'My Test Work'
    source = 'related resource'
    within('form.new_generic_work') do
      fill_in('Title', with: work_title)
      fill_in('Source', with: source)
      select 'Attribution 3.0 United States', from: 'generic_work[rights][]'
      attach_file('Upload a file', fixture_file_path('files/image.png'))
      choose('generic_work_visibility_open')
      select 'Test Collection', from: 'generic_work[member_of_collection_ids][]'
      click_on('Create Generic work')
    end

    expect(page).to have_content(source)
    expect(page).to have_link 'Attribution 3.0 United States',
                              href: 'http://creativecommons.org/licenses/by/3.0/us/'

    within '.related_files' do
      expect(page).to have_link 'image.png'
    end

    within '.member_of_collections' do
      expect(page).to have_link 'Test Collection'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curation_concerns-2.0.0 spec/features/create_work_spec.rb
curation_concerns-2.0.0.rc2 spec/features/create_work_spec.rb
curation_concerns-2.0.0.rc1 spec/features/create_work_spec.rb