Class: Hyrax::Spec::ActorCreate
- Inherits:
-
Object
- Object
- Hyrax::Spec::ActorCreate
- Defined in:
- lib/hyrax/spec/factory_bot/build_strategies/actor_create.rb
Overview
A FactoryBot build strategy for creating Hyrax Works and running them through the actor stack.
In a normal RSpec Rails environment, this will enqueue (but not perform) several background jobs (charactarization, derivatives, etc…). If you want to perform the jobs, configure that with:
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true
If you only want to perform specific job classes, you can do:
ActiveJob::Base.queue_adapter.filter = [SpecificJobClassYouWantToRun]
Instance Method Summary collapse
-
#initialize ⇒ ActorCreate
constructor
A new instance of ActorCreate.
- #result(evaluation) ⇒ Object
Constructor Details
#initialize ⇒ ActorCreate
Returns a new instance of ActorCreate.
26 27 28 |
# File 'lib/hyrax/spec/factory_bot/build_strategies/actor_create.rb', line 26 def initialize @association_strategy = FactoryBot.strategy_by_name(:create).new end |
Instance Method Details
#result(evaluation) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hyrax/spec/factory_bot/build_strategies/actor_create.rb', line 32 def result(evaluation) evaluation.object.tap do |instance| evaluation.notify(:after_build, instance) # @todo: is there a better way to get the evaluator at this stage? # how should we handle a missing user? ability = ::Ability.new(evaluation.instance_variable_get(:@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 |