hydra-access-controls 7.1.0.rc2 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/hydra/access_controls/embargoable.rb +1 -1
- data/app/validators/hydra/future_date_validator.rb +3 -3
- data/config/{locale → locales}/hydra-access-controls.en.yml +0 -0
- data/spec/support/rails.rb +1 -1
- data/spec/unit/ability_spec.rb +36 -36
- data/spec/unit/admin_policy_spec.rb +20 -20
- data/spec/unit/embargoable_spec.rb +9 -0
- data/spec/unit/policy_aware_ability_spec.rb +12 -12
- data/spec/unit/with_access_right_spec.rb +20 -20
- data/spec/validators/future_date_validator_spec.rb +22 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d571199bff2f9ddd36d310d407cf91ca6ae8ee39
|
4
|
+
data.tar.gz: f0b1fbb7e08b80ca95f65f7482b88a4663d845ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff1a99172103f63cb660eec1df2b1cce4e9b5b69fac5c3a76d6c26dd3c1db95726a4f3b7125b8a1361d8a60042169bc0e91d45ac6ddddda978d58a603eafebec
|
7
|
+
data.tar.gz: f28021dffed759533327bc3a360d1f5b208779fa639f4137b27258154b9afcb2b831dbc1b1dd9e10bf0ed87bf8a8d0b39af7b898f86d12a39f2ce717045ec7ab
|
@@ -5,7 +5,7 @@ module Hydra
|
|
5
5
|
include Hydra::AccessControls::WithAccessRight
|
6
6
|
|
7
7
|
included do
|
8
|
-
validates :embargo_release_date, :'hydra/future_date' => true
|
8
|
+
validates :embargo_release_date, :lease_expiration_date, :'hydra/future_date' => true
|
9
9
|
|
10
10
|
has_attributes :visibility_during_embargo, :visibility_after_embargo, :embargo_release_date,
|
11
11
|
:visibility_during_lease, :visibility_after_lease, :lease_expiration_date,
|
@@ -6,13 +6,13 @@ module Hydra
|
|
6
6
|
begin
|
7
7
|
if date = value.to_date
|
8
8
|
if date <= Date.today
|
9
|
-
record.errors[
|
9
|
+
record.errors[attribute] << "Must be a future date"
|
10
10
|
end
|
11
11
|
else
|
12
|
-
record.errors[
|
12
|
+
record.errors[attribute] << "Invalid Date Format"
|
13
13
|
end
|
14
14
|
rescue ArgumentError, NoMethodError
|
15
|
-
record.errors[
|
15
|
+
record.errors[attribute] << "Invalid Date Format"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
File without changes
|
data/spec/support/rails.rb
CHANGED
data/spec/unit/ability_spec.rb
CHANGED
@@ -52,12 +52,12 @@ describe Ability do
|
|
52
52
|
end
|
53
53
|
subject { Ability.new(nil) }
|
54
54
|
it "should be able to view the asset" do
|
55
|
-
subject.can?(:read, @asset).should
|
55
|
+
subject.can?(:read, @asset).should be true
|
56
56
|
end
|
57
57
|
it "should not be able to edit, update and destroy the asset" do
|
58
|
-
subject.can?(:edit, @asset).should
|
59
|
-
subject.can?(:update, @asset).should
|
60
|
-
subject.can?(:destroy, @asset).should
|
58
|
+
subject.can?(:edit, @asset).should be false
|
59
|
+
subject.can?(:update, @asset).should be false
|
60
|
+
subject.can?(:destroy, @asset).should be false
|
61
61
|
end
|
62
62
|
end
|
63
63
|
context "Then a registered user" do
|
@@ -66,12 +66,12 @@ describe Ability do
|
|
66
66
|
end
|
67
67
|
subject { Ability.new(@user) }
|
68
68
|
it "should be able to view the asset" do
|
69
|
-
subject.can?(:read, @asset).should
|
69
|
+
subject.can?(:read, @asset).should be true
|
70
70
|
end
|
71
71
|
it "should not be able to edit, update and destroy the asset" do
|
72
|
-
subject.can?(:edit, @asset).should
|
73
|
-
subject.can?(:update, @asset).should
|
74
|
-
subject.can?(:destroy, @asset).should
|
72
|
+
subject.can?(:edit, @asset).should be false
|
73
|
+
subject.can?(:update, @asset).should be false
|
74
|
+
subject.can?(:destroy, @asset).should be false
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -119,15 +119,15 @@ describe Ability do
|
|
119
119
|
subject { Ability.new(@user) }
|
120
120
|
|
121
121
|
it "should be able to view the asset" do
|
122
|
-
subject.can?(:read, @asset).should
|
122
|
+
subject.can?(:read, @asset).should be true
|
123
123
|
end
|
124
124
|
it "should not be able to edit, update and destroy the asset" do
|
125
|
-
subject.can?(:edit, @asset).should
|
126
|
-
subject.can?(:update, @asset).should
|
127
|
-
subject.can?(:destroy, @asset).should
|
125
|
+
subject.can?(:edit, @asset).should be false
|
126
|
+
subject.can?(:update, @asset).should be false
|
127
|
+
subject.can?(:destroy, @asset).should be false
|
128
128
|
end
|
129
129
|
it "should not be able to see the admin view of the asset" do
|
130
|
-
subject.can?(:admin, @asset).should
|
130
|
+
subject.can?(:admin, @asset).should be false
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
@@ -142,15 +142,15 @@ describe Ability do
|
|
142
142
|
subject { Ability.new(@user) }
|
143
143
|
|
144
144
|
it "should be able to view the asset" do
|
145
|
-
subject.can?(:read, @asset).should
|
145
|
+
subject.can?(:read, @asset).should be true
|
146
146
|
end
|
147
147
|
it "should be able to edit, update and destroy the asset" do
|
148
|
-
subject.can?(:edit, @asset).should
|
149
|
-
subject.can?(:update, @asset).should
|
150
|
-
subject.can?(:destroy, @asset).should
|
148
|
+
subject.can?(:edit, @asset).should be true
|
149
|
+
subject.can?(:update, @asset).should be true
|
150
|
+
subject.can?(:destroy, @asset).should be true
|
151
151
|
end
|
152
152
|
it "should not be able to see the admin view of the asset" do
|
153
|
-
subject.can?(:admin, @asset).should
|
153
|
+
subject.can?(:admin, @asset).should be false
|
154
154
|
end
|
155
155
|
end
|
156
156
|
context "Then a collaborator with edit access (group permision)" do
|
@@ -161,7 +161,7 @@ describe Ability do
|
|
161
161
|
subject { Ability.new(@user) }
|
162
162
|
|
163
163
|
it "should be able to view the asset" do
|
164
|
-
subject.can?(:read, @asset).should
|
164
|
+
subject.can?(:read, @asset).should be true
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
@@ -178,15 +178,15 @@ describe Ability do
|
|
178
178
|
subject { Ability.new(@user) }
|
179
179
|
|
180
180
|
it "should not be able to view the asset" do
|
181
|
-
subject.can?(:read, @asset).should
|
181
|
+
subject.can?(:read, @asset).should be false
|
182
182
|
end
|
183
183
|
it "should not be able to edit, update and destroy the asset" do
|
184
|
-
subject.can?(:edit, @asset).should
|
185
|
-
subject.can?(:update, @asset).should
|
186
|
-
subject.can?(:destroy, @asset).should
|
184
|
+
subject.can?(:edit, @asset).should be false
|
185
|
+
subject.can?(:update, @asset).should be false
|
186
|
+
subject.can?(:destroy, @asset).should be false
|
187
187
|
end
|
188
188
|
it "should not be able to see the admin view of the asset" do
|
189
|
-
subject.can?(:admin, @asset).should
|
189
|
+
subject.can?(:admin, @asset).should be false
|
190
190
|
end
|
191
191
|
end
|
192
192
|
context "Then someone whose role/group has read access" do
|
@@ -197,15 +197,15 @@ describe Ability do
|
|
197
197
|
subject { Ability.new(@user) }
|
198
198
|
|
199
199
|
it "should be able to view the asset" do
|
200
|
-
subject.can?(:read, @asset).should
|
200
|
+
subject.can?(:read, @asset).should be true
|
201
201
|
end
|
202
202
|
it "should not be able to edit, update and destroy the asset" do
|
203
|
-
subject.can?(:edit, @asset).should
|
204
|
-
subject.can?(:update, @asset).should
|
205
|
-
subject.can?(:destroy, @asset).should
|
203
|
+
subject.can?(:edit, @asset).should be false
|
204
|
+
subject.can?(:update, @asset).should be false
|
205
|
+
subject.can?(:destroy, @asset).should be false
|
206
206
|
end
|
207
207
|
it "should not be able to see the admin view of the asset" do
|
208
|
-
subject.can?(:admin, @asset).should
|
208
|
+
subject.can?(:admin, @asset).should be false
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
@@ -231,7 +231,7 @@ describe Ability do
|
|
231
231
|
subject { MyAbility.new(@user) }
|
232
232
|
|
233
233
|
it "should be set the custom permission" do
|
234
|
-
subject.can?(:accept, ActiveFedora::Base).should
|
234
|
+
subject.can?(:accept, ActiveFedora::Base).should be true
|
235
235
|
end
|
236
236
|
|
237
237
|
end
|
@@ -249,8 +249,8 @@ describe Ability do
|
|
249
249
|
subject { Ability.new(@user) }
|
250
250
|
it "should be readable in the first instance and not in the second instance" do
|
251
251
|
# We had a bug around this where it keeps returning the access for the first object queried
|
252
|
-
subject.can?(:edit, @asset1).should
|
253
|
-
subject.can?(:edit, @asset2).should
|
252
|
+
subject.can?(:edit, @asset1).should be true
|
253
|
+
subject.can?(:edit, @asset2).should be false
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
@@ -267,17 +267,17 @@ describe Ability do
|
|
267
267
|
@asset.save
|
268
268
|
end
|
269
269
|
it "should permit the user to download the object's datastreams" do
|
270
|
-
subject.can?(:read, @asset).should
|
270
|
+
subject.can?(:read, @asset).should be true
|
271
271
|
@asset.datastreams.each_value do |ds|
|
272
|
-
subject.can?(:download, ds).should
|
272
|
+
subject.can?(:download, ds).should be true
|
273
273
|
end
|
274
274
|
end
|
275
275
|
end
|
276
276
|
context "user lacks read permission on the object" do
|
277
277
|
it "should not permit the user to download the object's datastreams" do
|
278
|
-
subject.can?(:read, @asset).should
|
278
|
+
subject.can?(:read, @asset).should be false
|
279
279
|
@asset.datastreams.each_value do |ds|
|
280
|
-
subject.can?(:download, ds).should
|
280
|
+
subject.can?(:download, ds).should be false
|
281
281
|
end
|
282
282
|
end
|
283
283
|
end
|
@@ -137,12 +137,12 @@ describe Hydra::AdminPolicy do
|
|
137
137
|
end
|
138
138
|
after { @asset.delete }
|
139
139
|
it "Then I should be able to view the asset" do
|
140
|
-
subject.can?(:read, @asset).should
|
140
|
+
subject.can?(:read, @asset).should be true
|
141
141
|
end
|
142
142
|
it "Then I should not be able to edit, update and destroy the asset" do
|
143
|
-
subject.can?(:edit, @asset).should
|
144
|
-
subject.can?(:update, @asset).should
|
145
|
-
subject.can?(:destroy, @asset).should
|
143
|
+
subject.can?(:edit, @asset).should be false
|
144
|
+
subject.can?(:update, @asset).should be false
|
145
|
+
subject.can?(:destroy, @asset).should be false
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
@@ -161,12 +161,12 @@ describe Hydra::AdminPolicy do
|
|
161
161
|
end
|
162
162
|
after { @asset.delete }
|
163
163
|
it "Then I should be able to view the asset" do
|
164
|
-
subject.can?(:read, @asset).should
|
164
|
+
subject.can?(:read, @asset).should be true
|
165
165
|
end
|
166
166
|
it "Then I should be able to edit/update/destroy the asset" do
|
167
|
-
subject.can?(:edit, @asset).should
|
168
|
-
subject.can?(:update, @asset).should
|
169
|
-
subject.can?(:destroy, @asset).should
|
167
|
+
subject.can?(:edit, @asset).should be true
|
168
|
+
subject.can?(:update, @asset).should be true
|
169
|
+
subject.can?(:destroy, @asset).should be true
|
170
170
|
end
|
171
171
|
end
|
172
172
|
context "And a subscribing asset grants read access to me as an individual" do
|
@@ -178,12 +178,12 @@ describe Hydra::AdminPolicy do
|
|
178
178
|
end
|
179
179
|
after { @asset.delete }
|
180
180
|
it "Then I should be able to view the asset" do
|
181
|
-
subject.can?(:read, @asset).should
|
181
|
+
subject.can?(:read, @asset).should be true
|
182
182
|
end
|
183
183
|
it "Then I should be able to edit/update/destroy the asset" do
|
184
|
-
subject.can?(:edit, @asset).should
|
185
|
-
subject.can?(:update, @asset).should
|
186
|
-
subject.can?(:destroy, @asset).should
|
184
|
+
subject.can?(:edit, @asset).should be true
|
185
|
+
subject.can?(:update, @asset).should be true
|
186
|
+
subject.can?(:destroy, @asset).should be true
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
@@ -202,12 +202,12 @@ describe Hydra::AdminPolicy do
|
|
202
202
|
end
|
203
203
|
after { @asset.delete }
|
204
204
|
it "Then I should not be able to view the asset" do
|
205
|
-
subject.can?(:read, @asset).should
|
205
|
+
subject.can?(:read, @asset).should be false
|
206
206
|
end
|
207
207
|
it "Then I should not be able to edit/update/destroy the asset" do
|
208
|
-
subject.can?(:edit, @asset).should
|
209
|
-
subject.can?(:update, @asset).should
|
210
|
-
subject.can?(:destroy, @asset).should
|
208
|
+
subject.can?(:edit, @asset).should be false
|
209
|
+
subject.can?(:update, @asset).should be false
|
210
|
+
subject.can?(:destroy, @asset).should be false
|
211
211
|
end
|
212
212
|
end
|
213
213
|
context "And a subscribing asset grants read access to me as an individual" do
|
@@ -219,12 +219,12 @@ describe Hydra::AdminPolicy do
|
|
219
219
|
end
|
220
220
|
after { @asset.delete }
|
221
221
|
it "Then I should be able to view the asset" do
|
222
|
-
subject.can?(:read, @asset).should
|
222
|
+
subject.can?(:read, @asset).should be true
|
223
223
|
end
|
224
224
|
it "Then I should not be able to edit/update/destroy the asset" do
|
225
|
-
subject.can?(:edit, @asset).should
|
226
|
-
subject.can?(:update, @asset).should
|
227
|
-
subject.can?(:destroy, @asset).should
|
225
|
+
subject.can?(:edit, @asset).should be false
|
226
|
+
subject.can?(:update, @asset).should be false
|
227
|
+
subject.can?(:destroy, @asset).should be false
|
228
228
|
end
|
229
229
|
end
|
230
230
|
end
|
@@ -20,6 +20,15 @@ describe Hydra::AccessControls::Embargoable do
|
|
20
20
|
|
21
21
|
subject { model.new }
|
22
22
|
|
23
|
+
context 'validations' do
|
24
|
+
subject { ModsAsset.new(lease_expiration_date: past_date, embargo_release_date: past_date) }
|
25
|
+
it "validates embargo_release_date and lease_expiration_date" do
|
26
|
+
expect(subject).to_not be_valid
|
27
|
+
expect(subject.errors[:lease_expiration_date]).to eq ['Must be a future date']
|
28
|
+
expect(subject.errors[:embargo_release_date]).to eq ['Must be a future date']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
23
32
|
context 'visibility=' do
|
24
33
|
it "when changing from embargo, wipes out associated embargo metadata" do
|
25
34
|
subject.embargo_release_date = future_date.to_s
|
@@ -86,37 +86,37 @@ describe Hydra::PolicyAwareAbility do
|
|
86
86
|
context "public user" do
|
87
87
|
it "should return false" do
|
88
88
|
subject.stub(:user_groups).and_return(["public"])
|
89
|
-
subject.test_edit_from_policy(@asset.pid).should
|
89
|
+
subject.test_edit_from_policy(@asset.pid).should be false
|
90
90
|
end
|
91
91
|
end
|
92
92
|
context "registered user" do
|
93
93
|
it "should return false" do
|
94
94
|
subject.user_groups.should include("registered")
|
95
|
-
subject.test_edit_from_policy(@asset.pid).should
|
95
|
+
subject.test_edit_from_policy(@asset.pid).should be false
|
96
96
|
end
|
97
97
|
end
|
98
98
|
context "user with policy read access only" do
|
99
99
|
it "should return false" do
|
100
100
|
subject.current_user.stub(:user_key).and_return("nero")
|
101
|
-
subject.test_edit_from_policy(@asset.pid).should
|
101
|
+
subject.test_edit_from_policy(@asset.pid).should be false
|
102
102
|
end
|
103
103
|
end
|
104
104
|
context "user with policy edit access" do
|
105
105
|
it "should return true" do
|
106
106
|
subject.current_user.stub(:user_key).and_return("julius_caesar")
|
107
|
-
subject.test_edit_from_policy(@asset.pid).should
|
107
|
+
subject.test_edit_from_policy(@asset.pid).should be true
|
108
108
|
end
|
109
109
|
end
|
110
110
|
context "user in group with policy read access" do
|
111
111
|
it "should return false" do
|
112
112
|
subject.stub(:user_groups).and_return(["africana-faculty"])
|
113
|
-
subject.test_edit_from_policy(@asset.pid).should
|
113
|
+
subject.test_edit_from_policy(@asset.pid).should be false
|
114
114
|
end
|
115
115
|
end
|
116
116
|
context "user in group with policy edit access" do
|
117
117
|
it "should return true" do
|
118
118
|
subject.stub(:user_groups).and_return(["cool_kids"])
|
119
|
-
subject.test_edit_from_policy(@asset.pid).should
|
119
|
+
subject.test_edit_from_policy(@asset.pid).should be true
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
@@ -124,37 +124,37 @@ describe Hydra::PolicyAwareAbility do
|
|
124
124
|
context "public user" do
|
125
125
|
it "should return false" do
|
126
126
|
subject.stub(:user_groups).and_return(["public"])
|
127
|
-
subject.test_read_from_policy(@asset.pid).should
|
127
|
+
subject.test_read_from_policy(@asset.pid).should be false
|
128
128
|
end
|
129
129
|
end
|
130
130
|
context "registered user" do
|
131
131
|
it "should return false" do
|
132
132
|
subject.user_groups.should include("registered")
|
133
|
-
subject.test_read_from_policy(@asset.pid).should
|
133
|
+
subject.test_read_from_policy(@asset.pid).should be false
|
134
134
|
end
|
135
135
|
end
|
136
136
|
context "user with policy read access only" do
|
137
137
|
it "should return false" do
|
138
138
|
subject.current_user.stub(:user_key).and_return("nero")
|
139
|
-
subject.test_read_from_policy(@asset.pid).should
|
139
|
+
subject.test_read_from_policy(@asset.pid).should be true
|
140
140
|
end
|
141
141
|
end
|
142
142
|
context "user with policy edit access" do
|
143
143
|
it "should return true" do
|
144
144
|
subject.current_user.stub(:user_key).and_return("julius_caesar")
|
145
|
-
subject.test_read_from_policy(@asset.pid).should
|
145
|
+
subject.test_read_from_policy(@asset.pid).should be true
|
146
146
|
end
|
147
147
|
end
|
148
148
|
context "user in group with policy read access" do
|
149
149
|
it "should return false" do
|
150
150
|
subject.stub(:user_groups).and_return(["africana-faculty"])
|
151
|
-
subject.test_read_from_policy(@asset.pid).should
|
151
|
+
subject.test_read_from_policy(@asset.pid).should be true
|
152
152
|
end
|
153
153
|
end
|
154
154
|
context "user in group with policy edit access" do
|
155
155
|
it "should return true" do
|
156
156
|
subject.stub(:user_groups).and_return(["cool_kids"])
|
157
|
-
subject.test_read_from_policy(@asset.pid).should
|
157
|
+
subject.test_read_from_policy(@asset.pid).should be true
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
@@ -18,18 +18,18 @@ describe "WithAccessRight" do
|
|
18
18
|
context "not persisted" do
|
19
19
|
context "when it is public" do
|
20
20
|
before { subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC}
|
21
|
-
its(:authenticated_only_access?) { should
|
22
|
-
its(:private_access?) { should
|
23
|
-
its(:open_access?) { should
|
24
|
-
its(:open_access_with_embargo_release_date?) { should
|
21
|
+
its(:authenticated_only_access?) { should be false}
|
22
|
+
its(:private_access?) { should be false}
|
23
|
+
its(:open_access?) { should be true}
|
24
|
+
its(:open_access_with_embargo_release_date?) { should be false}
|
25
25
|
end
|
26
26
|
|
27
27
|
context "when it is private" do
|
28
28
|
before { subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
|
29
|
-
its(:authenticated_only_access?) { should
|
30
|
-
its(:private_access?) { should
|
31
|
-
its(:open_access?) { should
|
32
|
-
its(:open_access_with_embargo_release_date?) { should
|
29
|
+
its(:authenticated_only_access?) { should be false}
|
30
|
+
its(:private_access?) { should be true}
|
31
|
+
its(:open_access?) { should be false}
|
32
|
+
its(:open_access_with_embargo_release_date?) { should be false}
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -39,30 +39,30 @@ describe "WithAccessRight" do
|
|
39
39
|
before do
|
40
40
|
subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
41
41
|
end
|
42
|
-
its(:authenticated_only_access?) { should
|
43
|
-
its(:private_access?) { should
|
44
|
-
its(:open_access?) { should
|
45
|
-
its(:open_access_with_embargo_release_date?) { should
|
42
|
+
its(:authenticated_only_access?) { should be false}
|
43
|
+
its(:private_access?) { should be false}
|
44
|
+
its(:open_access?) { should be true}
|
45
|
+
its(:open_access_with_embargo_release_date?) { should be false}
|
46
46
|
end
|
47
47
|
|
48
48
|
context "when it is private" do
|
49
49
|
before do
|
50
50
|
subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
51
51
|
end
|
52
|
-
its(:authenticated_only_access?) { should
|
53
|
-
its(:private_access?) { should
|
54
|
-
its(:open_access?) { should
|
55
|
-
its(:open_access_with_embargo_release_date?) { should
|
52
|
+
its(:authenticated_only_access?) { should be false}
|
53
|
+
its(:private_access?) { should be true}
|
54
|
+
its(:open_access?) { should be false}
|
55
|
+
its(:open_access_with_embargo_release_date?) { should be false}
|
56
56
|
end
|
57
57
|
|
58
58
|
context "when it is authenticated access" do
|
59
59
|
before do
|
60
60
|
subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
61
61
|
end
|
62
|
-
its(:authenticated_only_access?) { should
|
63
|
-
its(:private_access?) { should
|
64
|
-
its(:open_access?) { should
|
65
|
-
its(:open_access_with_embargo_release_date?) { should
|
62
|
+
its(:authenticated_only_access?) { should be true}
|
63
|
+
its(:private_access?) { should be false}
|
64
|
+
its(:open_access?) { should be false}
|
65
|
+
its(:open_access_with_embargo_release_date?) { should be false}
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::FutureDateValidator do
|
4
|
+
let(:future_date) { Date.today + 2 }
|
5
|
+
let(:past_date) { Date.today - 2 }
|
6
|
+
let(:validator) { Hydra::FutureDateValidator.new(attributes: [:embargo_release_date, :lease_expiration_date]) }
|
7
|
+
before do
|
8
|
+
validator.validate(subject)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when date is valid" do
|
12
|
+
subject { ModsAsset.new(embargo_release_date: future_date) }
|
13
|
+
its(:errors) { should be_empty }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when date is invalid" do
|
17
|
+
subject { ModsAsset.new(lease_expiration_date: past_date) }
|
18
|
+
it "has errors" do
|
19
|
+
expect(subject.errors[:lease_expiration_date]).to eq ['Must be a future date']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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: 7.1.0
|
4
|
+
version: 7.1.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: 2014-06-
|
13
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -167,7 +167,7 @@ files:
|
|
167
167
|
- app/services/hydra/lease_service.rb
|
168
168
|
- app/validators/hydra/future_date_validator.rb
|
169
169
|
- config/fedora.yml
|
170
|
-
- config/
|
170
|
+
- config/locales/hydra-access-controls.en.yml
|
171
171
|
- config/solr.yml
|
172
172
|
- hydra-access-controls.gemspec
|
173
173
|
- lib/active_fedora/accessible_by.rb
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- spec/unit/role_mapper_spec.rb
|
215
215
|
- spec/unit/visibility_spec.rb
|
216
216
|
- spec/unit/with_access_right_spec.rb
|
217
|
+
- spec/validators/future_date_validator_spec.rb
|
217
218
|
- tasks/hydra-access-controls.rake
|
218
219
|
homepage: http://projecthydra.org
|
219
220
|
licenses:
|
@@ -230,9 +231,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
231
|
version: 1.9.3
|
231
232
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
233
|
requirements:
|
233
|
-
- - "
|
234
|
+
- - ">="
|
234
235
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
236
|
+
version: '0'
|
236
237
|
requirements: []
|
237
238
|
rubyforge_project:
|
238
239
|
rubygems_version: 2.2.2
|
@@ -267,4 +268,5 @@ test_files:
|
|
267
268
|
- spec/unit/role_mapper_spec.rb
|
268
269
|
- spec/unit/visibility_spec.rb
|
269
270
|
- spec/unit/with_access_right_spec.rb
|
271
|
+
- spec/validators/future_date_validator_spec.rb
|
270
272
|
has_rdoc:
|