Skip to content

Commit

Permalink
Update to curation_concerns 0.12.0.pre5
Browse files Browse the repository at this point in the history
Fixes #1776
  • Loading branch information
jcoyne committed Apr 13, 2016
1 parent 94d2948 commit 0f11111
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 32 deletions.
14 changes: 0 additions & 14 deletions app/controllers/concerns/sufia/works_controller_behavior.rb
Expand Up @@ -18,20 +18,6 @@ def new
super
end

def actor
@actor ||= CurationConcerns::CurationConcern::ActorStack.new(
curation_concern,
current_user,
[CreateWithFilesActor,
CurationConcerns::AddToCollectionActor,
CurationConcerns::AssignRepresentativeActor,
CurationConcerns::AttachFilesActor,
CurationConcerns::ApplyOrderActor,
CurationConcerns::InterpretVisibilityActor,
CurationConcerns::CurationConcern.model_actor(curation_concern),
CurationConcerns::AssignIdentifierActor])
end

# Override the default behavior from curation_concerns in order to add uploaded_files to the parameters received by the actor.
def attributes_for_actor
super.merge(params.slice(:uploaded_files))
Expand Down
13 changes: 1 addition & 12 deletions app/jobs/batch_create_job.rb
Expand Up @@ -58,17 +58,6 @@ def create_work(user, attributes)
end

def work_actor(work, user)
# TODO: merge this with the actor method from works_controller.
CurationConcerns::CurationConcern::ActorStack.new(
work,
user,
[Sufia::CreateWithFilesActor,
CurationConcerns::AddToCollectionActor,
CurationConcerns::AssignRepresentativeActor,
CurationConcerns::AttachFilesActor,
CurationConcerns::ApplyOrderActor,
CurationConcerns::InterpretVisibilityActor,
CurationConcerns::CurationConcern.model_actor(work),
CurationConcerns::AssignIdentifierActor])
CurationConcerns::CurationConcern.actor(work, user)
end
end
14 changes: 14 additions & 0 deletions app/services/sufia/actor_factory.rb
@@ -0,0 +1,14 @@
module Sufia
class ActorFactory < CurationConcerns::ActorFactory
def self.stack_actors(curation_concern)
[CreateWithFilesActor,
CurationConcerns::AddToCollectionActor,
CurationConcerns::AssignRepresentativeActor,
CurationConcerns::AttachFilesActor,
CurationConcerns::ApplyOrderActor,
CurationConcerns::InterpretVisibilityActor,
model_actor(curation_concern),
CurationConcerns::AssignIdentifierActor]
end
end
end
2 changes: 2 additions & 0 deletions lib/sufia/engine.rb
Expand Up @@ -44,6 +44,8 @@ class Engine < ::Rails::Engine
ActiveFedora::Noid.config.template = c.noid_template
ActiveFedora::Noid.config.statefile = c.minter_statefile
end

CurationConcerns::CurationConcern.actor_factory = Sufia::ActorFactory
end

initializer 'sufia.assets.precompile' do |app|
Expand Down
4 changes: 1 addition & 3 deletions spec/actors/create_with_files_actor_spec.rb
Expand Up @@ -4,10 +4,8 @@
let(:create_actor) { double('create actor', create: true,
curation_concern: work,
user: user) }
# let(:actor) { described_class.new(create_actor, uploaded_file_ids) }
let(:actor) do
CurationConcerns::CurationConcern::ActorStack.new(
work, user, [described_class])
CurationConcerns::ActorStack.new(work, user, [described_class])
end
let(:user) { create(:user) }
let(:uploaded_file1) { UploadedFile.create(user: user) }
Expand Down
40 changes: 40 additions & 0 deletions spec/factories/sufia/actor_factory_spec.rb
@@ -0,0 +1,40 @@
require 'spec_helper'

describe Sufia::ActorFactory do
let(:work) { GenericWork.new }
let(:user) { double }

describe '.stack_actors' do
subject { described_class.stack_actors(work) }
it { is_expected.to eq [Sufia::CreateWithFilesActor,
CurationConcerns::AddToCollectionActor,
CurationConcerns::AssignRepresentativeActor,
CurationConcerns::AttachFilesActor,
CurationConcerns::ApplyOrderActor,
CurationConcerns::InterpretVisibilityActor,
CurationConcerns::GenericWorkActor,
CurationConcerns::AssignIdentifierActor] }
end

describe '.build' do
subject { described_class.build(work, user) }
it "has the correct stack frames" do
expect(subject.more_actors).to eq [
CurationConcerns::AddToCollectionActor,
CurationConcerns::AssignRepresentativeActor,
CurationConcerns::AttachFilesActor,
CurationConcerns::ApplyOrderActor,
CurationConcerns::InterpretVisibilityActor,
CurationConcerns::GenericWorkActor,
CurationConcerns::AssignIdentifierActor]
expect(subject.first_actor_class).to eq Sufia::CreateWithFilesActor
end
end

describe 'CurationConcerns::CurationConcern.actor' do
it "calls the Sufia::ActorFactory" do
expect(described_class).to receive(:build)
CurationConcerns::CurationConcern.actor(work, user)
end
end
end
4 changes: 2 additions & 2 deletions spec/jobs/batch_create_job_spec.rb
Expand Up @@ -29,7 +29,7 @@
subject { described_class.perform_now(user, title, uploaded_files, metadata) }

it "updates work metadata" do
expect(CurationConcerns::CurationConcern::ActorStack).to receive(:new).and_return(actor).twice
expect(CurationConcerns::CurationConcern).to receive(:actor).and_return(actor).twice
expect(actor).to receive(:create).with(tag: [], title: ['File One'], uploaded_files: [1]).and_return(true)
expect(actor).to receive(:create).with(tag: [], title: ['File Two'], uploaded_files: [2]).and_return(true)
expect(CurationConcerns.config.callback).to receive(:run).with(:after_batch_create_success, user)
Expand Down Expand Up @@ -60,7 +60,7 @@

context "when user does not have permission to edit all of the works" do
it "sends the failure message" do
expect(CurationConcerns::CurationConcern::ActorStack).to receive(:new).and_return(actor).twice
expect(CurationConcerns::CurationConcern).to receive(:actor).and_return(actor).twice
expect(actor).to receive(:create).and_return(true, false)
expect(CurationConcerns.config.callback).to receive(:run).with(:after_batch_create_failure, user)
subject
Expand Down
2 changes: 1 addition & 1 deletion sufia.gemspec
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.version = Sufia::VERSION
spec.license = 'Apache2'

spec.add_dependency 'curation_concerns', '~> 0.12.0.pre4'
spec.add_dependency 'curation_concerns', '~> 0.12.0.pre5'
spec.add_dependency 'active-fedora', '~> 9.10'
spec.add_dependency 'hydra-works', '~> 0.7'
spec.add_dependency 'hydra-batch-edit', '~> 1.1'
Expand Down

0 comments on commit 0f11111

Please sign in to comment.