-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AddToCollectionActor adds collections on create
- Loading branch information
Showing
2 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
curation_concerns-models/app/actors/curation_concerns/add_to_collection_actor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
spec/actors/curation_concerns/add_to_collections_actor_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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 |