-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide deprecation on ProxyDepositListener
- Loading branch information
1 parent
628457c
commit 2d97e0f
Showing
4 changed files
with
52 additions
and
0 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
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 and unregister this listener \ | ||
in config/initializers/listeners.rb' | ||
) | ||
end | ||
end | ||
end | ||
end |
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
22 changes: 22 additions & 0 deletions
22
spec/services/hyrax/listeners/proxy_deposit_listener_spec.rb
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,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 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 |