Skip to content

Commit

Permalink
automatically convert valkyrie resource to ActiveJobProxy when enqueuing
Browse files Browse the repository at this point in the history
  • Loading branch information
elrayle authored and Tom Johnson committed Oct 22, 2019
1 parent fa94056 commit f59ea4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/jobs/hyrax/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ module Hyrax
# This allows downstream applications to manipulate all the hyrax jobs by
# including modules on this class.
class ApplicationJob < ::ApplicationJob
before_enqueue do |job|
job.arguments.map! do |arg|
arg.is_a?(Valkyrie::Resource) ? Hyrax::ActiveJobProxy.new(resource: arg) : arg
end
end
end
end
5 changes: 3 additions & 2 deletions spec/jobs/visibility_copy_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
let(:resource) { FactoryBot.create(:work_with_files).valkyrie_resource }
let(:queries) { Hyrax.query_service.custom_queries }

it 'serializes proxies' do
expect { described_class.perform_later(proxy) }.not_to raise_error
it 'converts resource to proxy when enqueuing' do
expect { described_class.perform_later(resource) }
.to have_enqueued_job.with("_aj_globalid" => proxy.to_global_id.to_s)
end

it 'copies visibility to file sets' do
Expand Down

0 comments on commit f59ea4d

Please sign in to comment.