Sha256: 4da908a65cc91d6a8a9d783481ebbc102a14ebd107ed0c2df96fbf683dea86ac

Contents?: true

Size: 1.59 KB

Versions: 11

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

feature 'leases' do
  let(:user) { FactoryGirl.create(:user) }
  before do
    sign_in user
  end
  describe 'create a new leased object' do
    let(:future_date) { 5.days.from_now }
    let(:later_future_date) { 10.days.from_now }

    it 'can be created, displayed and updated' do
      visit '/'
      click_link 'New Generic Work'
      fill_in 'Title', with: 'Lease test'
      choose 'Lease'
      fill_in 'generic_work_lease_expiration_date', with: future_date
      select 'Open Access', from: 'Is available for'
      select 'Private', from: 'then restrict it to'
      click_button 'Create Generic work'

      # chosen lease date is on the show page
      expect(page).to have_content(future_date.to_date.to_formatted_s(:standard))

      click_link 'Edit This Generic Work'
      click_link 'Lease Management Page'

      expect(page).to have_content('This work is under lease.')
      expect(page).to have_xpath("//input[@name='generic_work[lease_expiration_date]' and @value='#{future_date.to_datetime.iso8601}']") # current lease date is pre-populated in edit field

      fill_in 'until', with: later_future_date.to_s

      click_button 'Update Lease'
      expect(page).to have_content(later_future_date.to_date.to_formatted_s(:standard)) # new lease date is displayed in message
    end
  end

  describe 'managing leases' do
    before do
      # admin privs
      allow_any_instance_of(Ability).to receive(:user_groups).and_return(['admin'])
    end
    it 'shows lists of objects under lease' do
      visit '/leases'
      expect(page).to have_content 'Manage Leases'
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
curation_concerns-1.6.3 spec/features/lease_spec.rb
curation_concerns-1.6.2 spec/features/lease_spec.rb
curation_concerns-1.6.1 spec/features/lease_spec.rb
curation_concerns-1.6.0 spec/features/lease_spec.rb
curation_concerns-1.5.0 spec/features/lease_spec.rb
curation_concerns-1.4.0 spec/features/lease_spec.rb
curation_concerns-1.3.3 spec/features/lease_spec.rb
curation_concerns-1.3.2 spec/features/lease_spec.rb
curation_concerns-1.3.1 spec/features/lease_spec.rb
curation_concerns-1.3.0 spec/features/lease_spec.rb
curation_concerns-1.2.0 spec/features/lease_spec.rb