hydra-access-controls 13.1.0 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/hydra/access_controls/embargo.rb +1 -1
- data/app/models/hydra/access_controls/lease.rb +1 -1
- data/hydra-access-controls.gemspec +1 -1
- data/spec/unit/embargo_spec.rb +119 -0
- data/spec/unit/lease_spec.rb +119 -0
- metadata +8 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 07efef2c0eade2fd801ec1991064ba1c91a1c908c4246fc9616b3505db65a11d
|
|
4
|
+
data.tar.gz: 713ac1e13a8e0145e4a695d5d7d57b1e9c43ebfd6772f63ecdee5a90dbe9586e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3f13844c5831ffffcb8f547390c2d53f5911d8270ef1315f78a83f6d31e1b5d5074b88211790440f63c0a02e76eaa619ec97eb19350622876473249762e81cb
|
|
7
|
+
data.tar.gz: e84d27c37c4744c92c6ca0114ddb303143706f6a617d057e252b7c433855552d07a55b43a43cf68bf3f3fb9debcf4cd622ce9c4170b8da7ae308892a5af5a6d9
|
|
@@ -11,7 +11,7 @@ module Hydra::AccessControls
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def active?
|
|
14
|
-
(embargo_release_date.present? && Date.
|
|
14
|
+
(embargo_release_date.present? && Date.yesterday.end_of_day < embargo_release_date)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# Deactivates the embargo and logs a message to the embargo_history property
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
|
19
19
|
|
|
20
20
|
gem.required_ruby_version = '>= 3.1'
|
|
21
21
|
|
|
22
|
-
gem.add_dependency 'activesupport', '>= 6.1', '<
|
|
22
|
+
gem.add_dependency 'activesupport', '>= 6.1', '< 9'
|
|
23
23
|
gem.add_dependency 'active-fedora', '>= 10.0.0'
|
|
24
24
|
gem.add_dependency 'blacklight-access_controls', '~> 6.0'
|
|
25
25
|
gem.add_dependency 'cancancan', '>= 1.8', '< 4'
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Hydra::AccessControls::Embargo do
|
|
4
|
+
let(:embargo) { described_class.new }
|
|
5
|
+
|
|
6
|
+
describe '#active?' do
|
|
7
|
+
context 'when embargo_release_date is not present' do
|
|
8
|
+
it 'returns false' do
|
|
9
|
+
embargo.embargo_release_date = nil
|
|
10
|
+
expect(embargo.active?).to be false
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'when embargo_release_date is present' do
|
|
15
|
+
context 'with a future date' do
|
|
16
|
+
it 'returns true' do
|
|
17
|
+
embargo.embargo_release_date = 1.day.from_now
|
|
18
|
+
expect(embargo.active?).to be true
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'with a past date' do
|
|
23
|
+
it 'returns false' do
|
|
24
|
+
embargo.embargo_release_date = 2.days.ago
|
|
25
|
+
expect(embargo.active?).to be false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context 'with today\'s date' do
|
|
30
|
+
it 'returns true when set to today at end of day' do
|
|
31
|
+
embargo.embargo_release_date = Date.today.end_of_day
|
|
32
|
+
expect(embargo.active?).to be true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'returns true when set to today at beginning of day' do
|
|
36
|
+
embargo.embargo_release_date = Date.today.beginning_of_day
|
|
37
|
+
expect(embargo.active?).to be true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'returns true when set to today at noon' do
|
|
41
|
+
embargo.embargo_release_date = Date.today.noon
|
|
42
|
+
expect(embargo.active?).to be true
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context 'with yesterday\'s date' do
|
|
47
|
+
it 'returns false when set to yesterday at end of day' do
|
|
48
|
+
embargo.embargo_release_date = Date.yesterday.end_of_day
|
|
49
|
+
expect(embargo.active?).to be false
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'returns false when set to yesterday at beginning of day' do
|
|
53
|
+
embargo.embargo_release_date = Date.yesterday.beginning_of_day
|
|
54
|
+
expect(embargo.active?).to be false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context 'edge case: exactly at the boundary' do
|
|
59
|
+
it 'returns false when release date equals yesterday end_of_day' do
|
|
60
|
+
boundary_time = Date.yesterday.end_of_day
|
|
61
|
+
embargo.embargo_release_date = boundary_time
|
|
62
|
+
expect(embargo.active?).to be false
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'returns true when release date is one second after yesterday end_of_day' do
|
|
66
|
+
boundary_time = Date.yesterday.end_of_day + 1.second
|
|
67
|
+
embargo.embargo_release_date = boundary_time
|
|
68
|
+
expect(embargo.active?).to be true
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe '#deactivate!' do
|
|
75
|
+
context 'when embargo is active' do
|
|
76
|
+
before do
|
|
77
|
+
embargo.embargo_release_date = 1.day.from_now
|
|
78
|
+
embargo.visibility_during_embargo = 'private'
|
|
79
|
+
embargo.visibility_after_embargo = 'public'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'clears embargo fields and logs history' do
|
|
83
|
+
expect(embargo.active?).to be true
|
|
84
|
+
embargo.deactivate!
|
|
85
|
+
|
|
86
|
+
expect(embargo.embargo_release_date).to be_nil
|
|
87
|
+
expect(embargo.visibility_during_embargo).to be_nil
|
|
88
|
+
expect(embargo.visibility_after_embargo).to be_nil
|
|
89
|
+
expect(embargo.embargo_history).to include(a_string_matching(/active embargo was deactivated/))
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context 'when embargo is expired' do
|
|
94
|
+
before do
|
|
95
|
+
embargo.embargo_release_date = 1.day.ago
|
|
96
|
+
embargo.visibility_during_embargo = 'private'
|
|
97
|
+
embargo.visibility_after_embargo = 'public'
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'clears embargo fields and logs history' do
|
|
101
|
+
expect(embargo.active?).to be false
|
|
102
|
+
embargo.deactivate!
|
|
103
|
+
|
|
104
|
+
expect(embargo.embargo_release_date).to be_nil
|
|
105
|
+
expect(embargo.visibility_during_embargo).to be_nil
|
|
106
|
+
expect(embargo.visibility_after_embargo).to be_nil
|
|
107
|
+
expect(embargo.embargo_history).to include(a_string_matching(/expired embargo was deactivated/))
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
context 'when no embargo is set' do
|
|
112
|
+
it 'does nothing' do
|
|
113
|
+
embargo.embargo_release_date = nil
|
|
114
|
+
embargo.deactivate!
|
|
115
|
+
expect(embargo.embargo_history).to be_empty
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Hydra::AccessControls::Lease do
|
|
4
|
+
let(:lease) { described_class.new }
|
|
5
|
+
|
|
6
|
+
describe '#active?' do
|
|
7
|
+
context 'when lease_expiration_date is not present' do
|
|
8
|
+
it 'returns false' do
|
|
9
|
+
lease.lease_expiration_date = nil
|
|
10
|
+
expect(lease.active?).to be false
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'when lease_expiration_date is present' do
|
|
15
|
+
context 'with a future date' do
|
|
16
|
+
it 'returns true' do
|
|
17
|
+
lease.lease_expiration_date = 1.day.from_now
|
|
18
|
+
expect(lease.active?).to be true
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'with a past date' do
|
|
23
|
+
it 'returns false' do
|
|
24
|
+
lease.lease_expiration_date = 2.days.ago
|
|
25
|
+
expect(lease.active?).to be false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context 'with today\'s date' do
|
|
30
|
+
it 'returns false when set to today at end of day' do
|
|
31
|
+
lease.lease_expiration_date = Date.today.end_of_day
|
|
32
|
+
expect(lease.active?).to be false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'returns false when set to today at beginning of day' do
|
|
36
|
+
lease.lease_expiration_date = Date.today.beginning_of_day
|
|
37
|
+
expect(lease.active?).to be false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'returns false when set to today at noon' do
|
|
41
|
+
lease.lease_expiration_date = Date.today.noon
|
|
42
|
+
expect(lease.active?).to be false
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context 'with yesterday\'s date' do
|
|
47
|
+
it 'returns false when set to yesterday at end of day' do
|
|
48
|
+
lease.lease_expiration_date = Date.yesterday.end_of_day
|
|
49
|
+
expect(lease.active?).to be false
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'returns false when set to yesterday at beginning of day' do
|
|
53
|
+
lease.lease_expiration_date = Date.yesterday.beginning_of_day
|
|
54
|
+
expect(lease.active?).to be false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context 'edge case: exactly at the boundary' do
|
|
59
|
+
it 'returns false when expiration date equals today end_of_day' do
|
|
60
|
+
boundary_time = Date.today.end_of_day
|
|
61
|
+
lease.lease_expiration_date = boundary_time
|
|
62
|
+
expect(lease.active?).to be false
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'returns true when expiration date is one second after today end_of_day' do
|
|
66
|
+
boundary_time = Date.today.end_of_day + 1.second
|
|
67
|
+
lease.lease_expiration_date = boundary_time
|
|
68
|
+
expect(lease.active?).to be true
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe '#deactivate!' do
|
|
75
|
+
context 'when lease is active' do
|
|
76
|
+
before do
|
|
77
|
+
lease.lease_expiration_date = 1.day.from_now
|
|
78
|
+
lease.visibility_during_lease = 'public'
|
|
79
|
+
lease.visibility_after_lease = 'private'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'clears lease fields and logs history' do
|
|
83
|
+
expect(lease.active?).to be true
|
|
84
|
+
lease.deactivate!
|
|
85
|
+
|
|
86
|
+
expect(lease.lease_expiration_date).to be_nil
|
|
87
|
+
expect(lease.visibility_during_lease).to be_nil
|
|
88
|
+
expect(lease.visibility_after_lease).to be_nil
|
|
89
|
+
expect(lease.lease_history).to include(a_string_matching(/active lease was deactivated/))
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context 'when lease is expired' do
|
|
94
|
+
before do
|
|
95
|
+
lease.lease_expiration_date = 1.day.ago
|
|
96
|
+
lease.visibility_during_lease = 'public'
|
|
97
|
+
lease.visibility_after_lease = 'private'
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'clears lease fields and logs history' do
|
|
101
|
+
expect(lease.active?).to be false
|
|
102
|
+
lease.deactivate!
|
|
103
|
+
|
|
104
|
+
expect(lease.lease_expiration_date).to be_nil
|
|
105
|
+
expect(lease.visibility_during_lease).to be_nil
|
|
106
|
+
expect(lease.visibility_after_lease).to be_nil
|
|
107
|
+
expect(lease.lease_history).to include(a_string_matching(/expired lease was deactivated/))
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
context 'when no lease is set' do
|
|
112
|
+
it 'does nothing' do
|
|
113
|
+
lease.lease_expiration_date = nil
|
|
114
|
+
lease.deactivate!
|
|
115
|
+
expect(lease.lease_history).to be_empty
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
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: 13.
|
|
4
|
+
version: 13.2.0
|
|
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: 2025-
|
|
13
|
+
date: 2025-11-13 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|
|
@@ -21,7 +21,7 @@ dependencies:
|
|
|
21
21
|
version: '6.1'
|
|
22
22
|
- - "<"
|
|
23
23
|
- !ruby/object:Gem::Version
|
|
24
|
-
version: '
|
|
24
|
+
version: '9'
|
|
25
25
|
type: :runtime
|
|
26
26
|
prerelease: false
|
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -31,7 +31,7 @@ dependencies:
|
|
|
31
31
|
version: '6.1'
|
|
32
32
|
- - "<"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
34
|
+
version: '9'
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
|
36
36
|
name: active-fedora
|
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -191,8 +191,10 @@ files:
|
|
|
191
191
|
- spec/unit/admin_policy_spec.rb
|
|
192
192
|
- spec/unit/collection_relationship_spec.rb
|
|
193
193
|
- spec/unit/config_spec.rb
|
|
194
|
+
- spec/unit/embargo_spec.rb
|
|
194
195
|
- spec/unit/embargoable_spec.rb
|
|
195
196
|
- spec/unit/ip_base_ability_spec.rb
|
|
197
|
+
- spec/unit/lease_spec.rb
|
|
196
198
|
- spec/unit/permission_spec.rb
|
|
197
199
|
- spec/unit/permissions_spec.rb
|
|
198
200
|
- spec/unit/policy_aware_ability_spec.rb
|
|
@@ -246,8 +248,10 @@ test_files:
|
|
|
246
248
|
- spec/unit/admin_policy_spec.rb
|
|
247
249
|
- spec/unit/collection_relationship_spec.rb
|
|
248
250
|
- spec/unit/config_spec.rb
|
|
251
|
+
- spec/unit/embargo_spec.rb
|
|
249
252
|
- spec/unit/embargoable_spec.rb
|
|
250
253
|
- spec/unit/ip_base_ability_spec.rb
|
|
254
|
+
- spec/unit/lease_spec.rb
|
|
251
255
|
- spec/unit/permission_spec.rb
|
|
252
256
|
- spec/unit/permissions_spec.rb
|
|
253
257
|
- spec/unit/policy_aware_ability_spec.rb
|