Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically convert valkyrie resource to ActiveJobProxy when enqueuing #4124

Merged
merged 1 commit into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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