Sha256: 7c57a3f71ae0c2c4a4faa9707d20d6afb28dbb36d76b2a8f35950943dd1fd982

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe Hydra::Works::GetGenericFilesFromGenericWork do

  subject { Hydra::Works::GenericWork::Base.create }

  let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
  let(:generic_file2) { Hydra::Works::GenericFile::Base.create }

  let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
  let(:generic_work2) { Hydra::Works::GenericWork::Base.create }

  describe '#call' do
    it 'should return empty array when only generic_works are aggregated' do
      Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work1 )
      Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work2 )
      subject.save
      expect(Hydra::Works::GetGenericFilesFromGenericWork.call( subject )).to eq []
    end

    context 'with generic_files and generic_works' do
      before do
        Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file1 )
        Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file2 )
        Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work1 )
        Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work2 )
        subject.save
      end

      it 'should only return generic_files' do
        expect(Hydra::Works::GetGenericFilesFromGenericWork.call( subject )).to eq [generic_file1,generic_file2]
      end
   end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hydra-works-0.0.1 spec/hydra/works/services/generic_work/get_generic_files_spec.rb