-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
publication_workflow_spec
for reusable setup
We're going to need to reuse the workflow setup here elsewhere, so I'm making it as repeatable as possible. This removes the `before` block from the setup entirely, opting for spec metadata and a custom factory build strategy to handle the behaviors captured there before.
- Loading branch information
Tom Johnson
committed
Nov 22, 2017
1 parent
47ae91d
commit 35ec446
Showing
4 changed files
with
37 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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,25 @@ | ||
class ActorCreate | ||
def initialize | ||
@association_strategy = FactoryGirl.strategy_by_name(:create).new | ||
end | ||
|
||
delegate :association, to: :@association_strategy | ||
|
||
def result(evaluation) | ||
evaluation.object.tap do |instance| | ||
evaluation.notify(:after_build, instance) | ||
|
||
evaluator = evaluation.instance_variable_get(:@attribute_assigner) | ||
.instance_variable_get(:@evaluator) | ||
|
||
ability = Ability.new(evaluator.user) | ||
env = Hyrax::Actors::Environment.new(instance, ability, {}) | ||
|
||
evaluation.notify(:before_create, instance) | ||
evaluation.notify(:before_actor_create, instance) | ||
Hyrax::CurationConcern.actor.create(env) | ||
evaluation.notify(:after_create, instance) | ||
evaluation.notify(:after_actor_create, instance) | ||
end | ||
end | ||
end |