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

Provide deprecation on ProxyDepositListener #5550

Merged
merged 2 commits into from
Mar 18, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/services/hyrax/listeners.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Listeners
autoload :MemberCleanupListener
autoload :MetadataIndexListener
autoload :ObjectLifecycleListener
autoload :ProxyDepositListener
autoload :TrophyCleanupListener
autoload :WorkflowListener
end
Expand Down
28 changes: 28 additions & 0 deletions app/services/hyrax/listeners/proxy_deposit_listener.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

module Hyrax
module Listeners
##
# @deprecated transfer requests are now carried out synchronously during
# object save
#
## Listens for deposit events, and checks for proxy situations. When a user
# deposits an item `on_behalf_of` another, ensures transfer is handled.
class ProxyDepositListener
##
# Called when 'object.deposited' event is published
# @param [Dry::Events::Event] _event
# @return [void]
def on_object_deposited(_event)
Deprecation.warn(
"The ProxyDepositListener was deprecated, effective immediately, in \
response to a difficult-to-diagnose race condition bug. This listener \
is now a no-op. To retain functionality ensure that \
DefaultMiddlewareStack is configured to use \
Hyrax::Actors::TransferRequestActor. To quiet this deprecation remove any \
local initializer configuration that subscribes this listener."
)
end
end
end
end
22 changes: 22 additions & 0 deletions spec/services/hyrax/listeners/proxy_deposit_listener_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

RSpec.describe Hyrax::Listeners::ProxyDepositListener do
subject(:listener) { described_class.new }
let(:data) { { object: resource, user: depositor } }
let(:depositor) { FactoryBot.create(:user) }
let(:event) { Dry::Events::Event.new(event_type, data) }
let(:proxied_to) { FactoryBot.create(:user) }
let(:resource) { FactoryBot.valkyrie_create(:hyrax_work, on_behalf_of: proxied_to.user_key) }

describe 'on_object_deposited' do
let(:event_type) { :on_object_deposited }

context 'when object has been deposited as proxy for another user' do
it 'is a deprecated no-op' do
expect(Deprecation).to receive(:warn).at_least(:once)
expect { listener.on_object_deposited(event) }
.not_to have_enqueued_job
end
end
end
end