Skip to content

Commit

Permalink
refactor Hyrax::LeaseHelper specs to work under koppie (#6197)
Browse files Browse the repository at this point in the history
* refactor Hyrax::LeaseHelper specs to work under koppie

some of these tests ensure interactions with AF models, these can be disabled.

others needed to be refactored to use Valkyrie for setup.

* Apply the lease

---------

Co-authored-by: Daniel Pierce <[email protected]>
  • Loading branch information
tamsin johnson and dlpierce authored Sep 8, 2023
1 parent 0f2da9d commit 53fffda
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions spec/helpers/hyrax/lease_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Hyrax::LeaseHelper do
let(:resource) { build(:monograph) }
let(:resource) { FactoryBot.build(:monograph) }

describe 'lease_enforced?' do
# Including this stub to preserve the spec structure before the #4845 change
Expand Down Expand Up @@ -77,7 +77,7 @@
end
end

context 'with an ActiveFedora resource' do
context 'with an ActiveFedora resource', :active_fedora do
let(:resource) { build(:work) }

it 'returns false' do
Expand Down Expand Up @@ -106,7 +106,7 @@
end
end

context 'with a HydraEditor::Form' do
context 'with a HydraEditor::Form', :active_fedora do
let(:resource) { Hyrax::GenericWorkForm.new(model, ability, form_controller) }
let(:model) { build(:work) }
let(:ability) { :FAKE_ABILITY }
Expand All @@ -129,17 +129,17 @@

context 'with a Hyrax::Forms::FailedSubmissionFormWrapper' do
let(:resource) { Hyrax::Forms::FailedSubmissionFormWrapper.new(form: form, input_params: {}, permitted_params: {}) }
let(:model) { build(:work) }
let(:form) { Hyrax::GenericWorkForm.new(model, ability, form_controller) }
let(:ability) { :FAKE_ABILITY }
let(:form_controller) { :FAKE_CONTROLLER }
let(:model) { FactoryBot.build(:hyrax_work) }
let(:form) { Hyrax::Forms::ResourceForm.for(model) }

it 'returns false' do
expect(lease_enforced?(resource)).to be false
end

context 'when the wrapped work is under embargo' do
let(:model) { build(:leased_work) }
let(:model) { FactoryBot.build(:hyrax_work, :under_lease) }

before { Hyrax::LeaseManager.apply_lease_for!(resource: resource.model) }

it 'returns true' do
# This allow call is a tweak to preserve spec for pre #4845 patch
Expand All @@ -151,7 +151,7 @@
end

describe '#lease_history' do
context 'with an ActiveFedora resource' do
context 'with an ActiveFedora resource', :active_fedora do
let(:resource) { FactoryBot.build(:work) }

it 'is empty' do
Expand Down

0 comments on commit 53fffda

Please sign in to comment.