Sha256: 0816ee7e270249cbdd4b583526c12b408f855eb2d502542910b5f50402f845ec

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe VisibilityCopyJob do
  describe 'an open access work' do
    let(:work) { create(:work_with_files) }

    it 'copies visibility to its contained files' do
      # files are private at the outset
      expect(work.file_sets.first.visibility).to eq Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE

      work.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
      work.save
      described_class.perform_now(work.id)
      work.reload.file_sets.each do |file|
        expect(file.visibility).to eq 'open'
      end
    end
  end

  describe 'an embargoed work' do
    let(:work) { create(:embargoed_work_with_files) }

    before do
      expect(work.visibility).to eq 'restricted'
      expect(work).to be_under_embargo
      expect(work.file_sets.first).to_not be_under_embargo
    end

    before do
      described_class.perform_now(work.id)
      work.reload
    end
    let(:file) { work.file_sets.first }

    it 'copies visibility to its contained files and apply a copy of the embargo to the files' do
      expect(file).to be_under_embargo
      expect(file.embargo.id).to_not eq work.embargo.id
    end
  end

  describe 'an leased work' do
    let(:work) { create(:leased_work_with_files) }

    before do
      expect(work.visibility).to eq 'open'
      expect(work).to be_active_lease
      expect(work.file_sets.first).to_not be_active_lease
    end

    before do
      described_class.perform_now(work.id)
      work.reload
    end
    let(:file) { work.file_sets.first }

    it 'copies visibility to its contained files and apply a copy of the lease to the files' do
      expect(file).to be_active_lease
      expect(file.lease.id).to_not eq work.lease.id
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
curation_concerns-0.10.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.9.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.8.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.7.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.6.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.5.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.4.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.3.0 spec/jobs/visibility_copy_job_spec.rb
curation_concerns-0.2.0 spec/jobs/visibility_copy_job_spec.rb