Sha256: 08110d1c63556e4b3d498804af7802c319b26951affa6b971bd9615edf9e1659

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe Hydra::Works::GetGenericWorksFromCollection do

  subject { Hydra::Works::Collection.create }

  let(:collection1) { Hydra::Works::Collection.create }
  let(:collection2) { Hydra::Works::Collection.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 collections are aggregated' do
      Hydra::Works::AddCollectionToCollection.call( subject, collection1 )
      Hydra::Works::AddCollectionToCollection.call( subject, collection2 )
      subject.save
      expect(Hydra::Works::GetGenericWorksFromCollection.call( subject )).to eq []
    end

    context 'with collections and generic works' do
      before do
        Hydra::Works::AddCollectionToCollection.call( subject, collection1 )
        Hydra::Works::AddCollectionToCollection.call( subject, collection2 )
        Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work1 )
        Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work2 )
        subject.save
      end

      it 'should only return generic works' do
        expect(Hydra::Works::GetGenericWorksFromCollection.call( subject )).to eq [generic_work1,generic_work2]
      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/collection/get_generic_works_spec.rb