-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use a helper for lease/embargo expiration
these views relied on internal knowledge about Embargo and Lease implementations that likely won't hold under Valkyrie models. extracting this knoweldege into a helper method is a first step toward making it implementation agnostic. this is connected to samvera/hydra-head#511.
- Loading branch information
tom johnson
committed
May 7, 2020
1 parent
f63b1f1
commit 54013dd
Showing
6 changed files
with
98 additions
and
4 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
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
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,36 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Hyrax::EmbargoHelper do | ||
let(:resource) { build(:monograph) } | ||
|
||
describe 'embargo_enforced?' do | ||
context 'with an ActiveFedora resource' do | ||
let(:resource) { build(:work) } | ||
|
||
it 'returns false' do | ||
expect(embargo_enforced?(resource)).to be false | ||
end | ||
|
||
context 'when the resource is under embargo' do | ||
let(:resource) { build(:embargoed_work) } | ||
|
||
it 'returns true' do | ||
expect(embargo_enforced?(resource)).to be true | ||
end | ||
|
||
it 'and the embargo is expired returns true' do | ||
resource.embargo.embargo_release_date = Time.zone.today - 1 | ||
|
||
expect(embargo_enforced?(resource)).to be true | ||
end | ||
|
||
it 'and the embargo is deactivated returns false' do | ||
resource.embargo.embargo_release_date = Time.zone.today - 1 | ||
resource.embargo.deactivate! | ||
|
||
expect(embargo_enforced?(resource)).to be false | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Hyrax::LeaseHelper do | ||
let(:resource) { build(:monograph) } | ||
|
||
describe 'lease_enforced?' do | ||
context 'with an ActiveFedora resource' do | ||
let(:resource) { build(:work) } | ||
|
||
it 'returns false' do | ||
expect(lease_enforced?(resource)).to be false | ||
end | ||
|
||
context 'when the resource is under lease' do | ||
let(:resource) { build(:leased_work) } | ||
|
||
it 'returns true' do | ||
expect(lease_enforced?(resource)).to be true | ||
end | ||
|
||
it 'and the lease is expired returns true' do | ||
resource.lease.lease_expiration_date = Time.zone.today - 1 | ||
|
||
expect(lease_enforced?(resource)).to be true | ||
end | ||
|
||
it 'and the lease is deactivated returns false' do | ||
resource.lease.lease_expiration_date = Time.zone.today - 1 | ||
resource.lease.deactivate! | ||
|
||
expect(lease_enforced?(resource)).to be false | ||
end | ||
end | ||
end | ||
end | ||
end |