hydra-access-controls 11.0.0 → 11.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f31fcebaf724bb3c6c85d7b57a09f64de643f5dc665885efa2c9b934a3bd0466
4
- data.tar.gz: 1e7c95962c8ae4d971d75ed0a123ab1635dc0a1c1dabe2e26dc9a3780b4d0147
3
+ metadata.gz: e4b22da24ea67d1fdb58bfce4044fa0d7c7167640bd7fb7c89bce988e0571595
4
+ data.tar.gz: 6adce22a2c6036385cd97550dfb51e11e23eea2b72b11076fcd0e54bb96f0ee6
5
5
  SHA512:
6
- metadata.gz: 53b789e51356d804eee597220cde26ac8ea01ea4c2d0f20cd95a351e4924ed65d29cd33bea517d7280a719d86074e8b196302accb7066ec20336343675dc4b65
7
- data.tar.gz: bc3e90b4894cc39e1e8783ab3d594f0b26b217890627140ef5aacd7ee017f36be66740dd6e381cabbf0cf2f00dc71c48d68aabe6f0e36f002d3fb3f970c0d514
6
+ metadata.gz: 17ae9693da60445afd084147a730c0cb86d585d5402ca8e88f4483d6cfd8b75cae3a41f4b241121dafba1d2ef6e868a33cf887cc8ba4d9cbf2e02deae415bd35
7
+ data.tar.gz: 0e4891b4c48b83db40d5e9e95da32630807a964dfbdd9ea84c5687adbf1092d319682c3fa5e006c1c4b76dc423ce5b50a77c2baae25916830a5b3ae0b5a44396
@@ -8,8 +8,8 @@ module Hydra
8
8
  validates :lease_expiration_date, :'hydra/future_date' => true, if: :enforce_future_date_for_lease?
9
9
  validates :embargo_release_date, :'hydra/future_date' => true, if: :enforce_future_date_for_embargo?
10
10
 
11
- belongs_to :embargo, predicate: Hydra::ACL.hasEmbargo, class_name: 'Hydra::AccessControls::Embargo'
12
- belongs_to :lease, predicate: Hydra::ACL.hasLease, class_name: 'Hydra::AccessControls::Lease'
11
+ belongs_to :embargo, predicate: Hydra::ACL.hasEmbargo, class_name: 'Hydra::AccessControls::Embargo', autosave: true
12
+ belongs_to :lease, predicate: Hydra::ACL.hasLease, class_name: 'Hydra::AccessControls::Lease', autosave: true
13
13
 
14
14
  delegate :visibility_during_embargo, :visibility_during_embargo=, :visibility_after_embargo, :visibility_after_embargo=, :embargo_release_date, :embargo_release_date=, :embargo_history, :embargo_history=, to: :existing_or_new_embargo
15
15
  delegate :visibility_during_lease, :visibility_during_lease=, :visibility_after_lease, :visibility_after_lease=, :lease_expiration_date, :lease_expiration_date=, :lease_history, :lease_history=, to: :existing_or_new_lease
@@ -19,6 +19,59 @@ describe Hydra::AccessControls::Embargoable do
19
19
  let(:model) { TestModel.new }
20
20
  subject { model }
21
21
 
22
+ describe 'an object under embargo/lease' do
23
+ before do
24
+ class ModelWithPersistence < ActiveFedora::Base
25
+ include Hydra::AccessControls::Embargoable
26
+ end
27
+ end
28
+ after { Object.send(:remove_const, :ModelWithPersistence) }
29
+ let(:original_date) { 7.days.from_now }
30
+ let(:updated_date) { 14.days.from_now }
31
+ subject { ModelWithPersistence.new }
32
+ context 'saved with a new embargo release date' do
33
+ it 'will persist the new date' do
34
+ subject.visibility_during_embargo = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
35
+ subject.visibility_after_embargo = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
36
+ subject.embargo_release_date = original_date
37
+ subject.save
38
+
39
+ # These next three lines are to verify the round-trip for saves.
40
+ persisted_object = subject.class.find(subject.id)
41
+ expect(persisted_object).to be_under_embargo
42
+ expect(persisted_object.embargo_release_date).to eq(original_date)
43
+
44
+ expect do
45
+ persisted_object.embargo_release_date = updated_date
46
+ persisted_object.save
47
+ end.to change { persisted_object.class.find(persisted_object.id).embargo_release_date }
48
+ .from(original_date)
49
+ .to(updated_date)
50
+ end
51
+ end
52
+
53
+ context 'saved with a new lease expiration date' do
54
+ it 'will persist the new date' do
55
+ subject.visibility_during_lease = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
56
+ subject.visibility_after_lease = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
57
+ subject.lease_expiration_date = original_date
58
+ subject.save
59
+
60
+ # These next three lines are to verify the round-trip for saves.
61
+ persisted_object = subject.class.find(subject.id)
62
+ expect(persisted_object).to be_active_lease
63
+ expect(persisted_object.lease_expiration_date).to eq(original_date)
64
+
65
+ expect do
66
+ persisted_object.lease_expiration_date = updated_date
67
+ persisted_object.save
68
+ end.to change { persisted_object.class.find(persisted_object.id).lease_expiration_date }
69
+ .from(original_date)
70
+ .to(updated_date)
71
+ end
72
+ end
73
+ end
74
+
22
75
  describe '#embargo_indexer_class' do
23
76
  subject { model.embargo_indexer_class }
24
77
  it { is_expected.to eq Hydra::AccessControls::EmbargoIndexer }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-access-controls
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.0
4
+ version: 11.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-01-31 00:00:00.000000000 Z
13
+ date: 2020-10-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubygems_version: 3.0.4
233
+ rubygems_version: 3.1.2
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: Access controls for project hydra