Sha256: ea639b06e153a0eefc6caf8481882bf9840826c52e2202bb7985f2f10af7b040

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
describe CurationConcerns::AddToCollectionActor do
  let(:user) { create(:user) }
  let(:curation_concern) { GenericWork.new }
  let(:attributes) { {} }
  subject do
    CurationConcerns::CurationConcern::ActorStack.new(curation_concern,
                                                      user,
                                                      [described_class,
                                                       CurationConcerns::GenericWorkActor])
  end
  describe 'the next actor' do
    let(:root_actor) { double }
    before do
      allow(CurationConcerns::RootActor).to receive(:new).and_return(root_actor)
    end

    let(:attributes) do
      { collection_ids: ['123'], title: ['test'] }
    end

    it 'does not receive the collection_ids' do
      expect(root_actor).to receive(:create).with(title: ['test'])
      subject.create(attributes)
    end
  end

  describe 'create' do
    let(:collection) { create(:collection) }
    let(:attributes) do
      { collection_ids: [collection.id], title: ['test'] }
    end

    it 'adds it to the collection' do
      expect(subject.create(attributes)).to be true
      expect(collection.reload.members).to eq [curation_concern]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
curation_concerns-0.12.0.pre4 spec/actors/curation_concerns/add_to_collections_actor_spec.rb
curation_concerns-0.12.0.pre3 spec/actors/curation_concerns/add_to_collections_actor_spec.rb
curation_concerns-0.12.0.pre2 spec/actors/curation_concerns/add_to_collections_actor_spec.rb
curation_concerns-0.12.0.pre1 spec/actors/curation_concerns/add_to_collections_actor_spec.rb