Skip to content

Commit

Permalink
Merge pull request #6587 from samvera/abel-fix_transfers_presenter_sp…
Browse files Browse the repository at this point in the history
…ec.rb

Valkyrization: Fix failing tests in `transfers_presenter_spec.rb`
  • Loading branch information
dlpierce authored Jan 8, 2024
2 parents 8dc9fdb + ab45391 commit 38ecd88
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions spec/presenters/hyrax/transfers_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
RSpec.describe Hyrax::TransfersPresenter do
let(:context) { ActionView::TestCase::TestController.new.view_context }
let(:user) { create(:user) }
let(:another_user) { create(:user) }
let(:instance) { described_class.new(user, context) }

describe "#incoming_proxy_deposits" do
subject(:incoming_proxy_deposits) { instance.send(:incoming_proxy_deposits) }

let(:another_user) { create(:user) }
let!(:incoming_work) do
create(:work, user: another_user).tap do |w|
w.request_transfer_to(user)
if Hyrax.config.use_valkyrie?
valkyrie_create(:hyrax_work, depositor: another_user.user_key)
else
create(:work, user: another_user)
end
end

before do
if Hyrax.config.use_valkyrie?
ProxyDepositRequest.create!(work_id: incoming_work.id, receiving_user: user, sending_user: another_user)
else
incoming_work.request_transfer_to(user)
end
end

Expand All @@ -20,7 +30,15 @@
end

context "When the incoming request is for a deleted work" do
before { incoming_work.destroy }
before do
if Hyrax.config.use_valkyrie?
transaction = Hyrax::Transactions::WorkDestroy.new
transaction.with_step_args('work_resource.delete_all_file_sets' => { user: another_user }).call(incoming_work)
else
incoming_work.destroy
end
end

it "does not show that work" do
expect(incoming_proxy_deposits).to be_empty
end
Expand All @@ -30,10 +48,19 @@
describe "#outgoing_proxy_deposits" do
subject { instance.send(:outgoing_proxy_deposits) }

let(:another_user) { create(:user) }
let!(:outgoing_work) do
create(:work, user: user).tap do |w|
w.request_transfer_to(another_user)
if Hyrax.config.use_valkyrie?
valkyrie_create(:hyrax_work, depositor: user.user_key)
else
create(:work, user: user)
end
end

before do
if Hyrax.config.use_valkyrie?
ProxyDepositRequest.create!(work_id: outgoing_work.id, receiving_user: another_user, sending_user: user)
else
outgoing_work.request_transfer_to(another_user)
end
end

Expand Down

0 comments on commit 38ecd88

Please sign in to comment.