ddr-models 2.4.9 → 2.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ddr/auth.rb +1 -0
- data/lib/ddr/auth/ability.rb +2 -1
- data/lib/ddr/auth/ability_definitions/lock_ability_definitions.rb +13 -0
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +3 -0
- data/lib/ddr/index/fields.rb +1 -0
- data/lib/ddr/models/has_admin_metadata.rb +23 -0
- data/lib/ddr/models/indexing.rb +1 -0
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/vocab/asset.rb +3 -0
- data/spec/auth/ability_spec.rb +20 -1
- data/spec/models/has_admin_metadata_spec.rb +65 -11
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdb63bca20c6403cb271efc0fbef7a69e9639bd0
|
4
|
+
data.tar.gz: a2ed58e92914138708aee15495f447396fbc1242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d6f7995169176b2705b96e2503af57a18e16c4490d6a3940b20b35881b5e1fdfa0d4655be1cbddd56217c42b4a3e2341f946cb3081651a9a395385dca757bdf
|
7
|
+
data.tar.gz: 44ec9729ef02ac1bba6dd9a3390fded3583ea656c58936138498e03f8ca3695cb252120b41a5290102d8c8faded0bb1ad0222217ed309e3519949cd8956ea2f5
|
data/lib/ddr/auth.rb
CHANGED
data/lib/ddr/auth/ability.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ddr
|
2
|
+
module Auth
|
3
|
+
class LockAbilityDefinitions < AbilityDefinitions
|
4
|
+
|
5
|
+
DENIED_WHEN_LOCKED = [ :add_children, :update, :replace, :arrange, :grant ]
|
6
|
+
|
7
|
+
def call
|
8
|
+
cannot DENIED_WHEN_LOCKED, Ddr::Models::Base, :locked? => true
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/ddr/index/fields.rb
CHANGED
@@ -35,6 +35,7 @@ module Ddr::Index
|
|
35
35
|
IS_ATTACHED_TO = Field.new :is_attached_to, :symbol
|
36
36
|
IS_EXTERNAL_TARGET_FOR = Field.new :is_external_target_for, :symbol
|
37
37
|
IS_GOVERNED_BY = Field.new :is_governed_by, :symbol
|
38
|
+
IS_LOCKED = Field.new :is_locked, :stored_sortable
|
38
39
|
IS_MEMBER_OF = Field.new :is_member_of, :symbol
|
39
40
|
IS_MEMBER_OF_COLLECTION = Field.new :is_member_of_collection, :symbol
|
40
41
|
IS_PART_OF = Field.new :is_part_of, :symbol
|
@@ -21,6 +21,7 @@ module Ddr::Models
|
|
21
21
|
:workflow_state,
|
22
22
|
:ead_id,
|
23
23
|
:aspace_id,
|
24
|
+
:is_locked,
|
24
25
|
datastream: "adminMetadata",
|
25
26
|
multiple: false
|
26
27
|
|
@@ -82,6 +83,28 @@ module Ddr::Models
|
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
86
|
+
def locked?
|
87
|
+
!!is_locked
|
88
|
+
end
|
89
|
+
|
90
|
+
def lock
|
91
|
+
self.is_locked = true
|
92
|
+
end
|
93
|
+
|
94
|
+
def unlock
|
95
|
+
self.is_locked = false
|
96
|
+
end
|
97
|
+
|
98
|
+
def lock!
|
99
|
+
lock
|
100
|
+
save
|
101
|
+
end
|
102
|
+
|
103
|
+
def unlock!
|
104
|
+
unlock
|
105
|
+
save
|
106
|
+
end
|
107
|
+
|
85
108
|
private
|
86
109
|
|
87
110
|
def update_permanent_id_on_destroy
|
data/lib/ddr/models/indexing.rb
CHANGED
@@ -33,6 +33,7 @@ module Ddr
|
|
33
33
|
FORMAT_FACET => format,
|
34
34
|
IDENTIFIER_ALL => all_identifiers,
|
35
35
|
INTERNAL_URI => internal_uri,
|
36
|
+
IS_LOCKED => is_locked,
|
36
37
|
LICENSE => license,
|
37
38
|
LICENSE_DESCRIPTION => rightsMetadata.license.description.first,
|
38
39
|
LICENSE_TITLE => rightsMetadata.license.title.first,
|
data/lib/ddr/models/version.rb
CHANGED
data/lib/ddr/vocab/asset.rb
CHANGED
data/spec/auth/ability_spec.rb
CHANGED
@@ -2,7 +2,7 @@ module Ddr::Auth
|
|
2
2
|
RSpec.describe Ability, type: :model, abilities: true do
|
3
3
|
|
4
4
|
subject { described_class.new(auth_context) }
|
5
|
-
|
5
|
+
|
6
6
|
let(:auth_context) { FactoryGirl.build(:auth_context) }
|
7
7
|
|
8
8
|
describe "aliases" do
|
@@ -144,6 +144,25 @@ module Ddr::Auth
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
describe "locks" do
|
148
|
+
let(:obj) { Ddr::Models::Base.new }
|
149
|
+
|
150
|
+
describe "effects of locks on abilities" do
|
151
|
+
before do
|
152
|
+
allow(obj).to receive(:effective_permissions) { Permissions::ALL }
|
153
|
+
allow(obj).to receive(:locked?) { true }
|
154
|
+
end
|
155
|
+
it { should be_able_to(:read, obj) }
|
156
|
+
it { should be_able_to(:download, obj) }
|
157
|
+
it { should_not be_able_to(:add_children, obj) }
|
158
|
+
it { should_not be_able_to(:update, obj) }
|
159
|
+
it { should_not be_able_to(:replace, obj) }
|
160
|
+
it { should_not be_able_to(:arrange, obj) }
|
161
|
+
it { should be_able_to(:audit, obj) }
|
162
|
+
it { should_not be_able_to(:grant, obj) }
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
147
166
|
describe "role based abilities" do
|
148
167
|
shared_examples "it has role based abilities" do
|
149
168
|
describe "when permissions are cached" do
|
@@ -190,23 +190,77 @@ module Ddr::Models
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
193
|
+
end
|
194
|
+
|
195
|
+
describe "contacts" do
|
196
|
+
|
197
|
+
subject { FactoryGirl.build(:item) }
|
198
|
+
|
199
|
+
before do
|
200
|
+
allow(Ddr::Models::Contact).to receive(:get).with(:find, slug: 'xa') do
|
201
|
+
{'id'=>1, 'slug'=>'xa', 'name'=>'Contact A', 'short_name'=>'A'}
|
202
|
+
end
|
203
|
+
allow(Ddr::Models::Contact).to receive(:get).with(:find, slug: 'yb') do
|
204
|
+
{'id'=>1, 'slug'=>'yb', 'name'=>'Contact B', 'short_name'=>'B'}
|
205
|
+
end
|
206
|
+
end
|
207
|
+
describe "#research_help" do
|
208
|
+
before { subject.research_help_contact = 'yb' }
|
209
|
+
it "should return the appropriate contact" do
|
210
|
+
expect(subject.research_help.slug).to eq('yb')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe "locking" do
|
216
|
+
|
217
|
+
subject { FactoryGirl.build(:item) }
|
218
|
+
|
219
|
+
describe "#locked?" do
|
220
|
+
context "object is locked" do
|
221
|
+
before { subject.is_locked = true }
|
222
|
+
it "should be true" do
|
223
|
+
expect(subject.locked?).to be true
|
200
224
|
end
|
201
225
|
end
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
expect(subject.research_help.slug).to eq('yb')
|
226
|
+
context "object is not locked" do
|
227
|
+
it "should be false" do
|
228
|
+
expect(subject.locked?).to be false
|
206
229
|
end
|
207
230
|
end
|
208
231
|
end
|
209
232
|
|
233
|
+
describe "lock" do
|
234
|
+
it "should lock the object" do
|
235
|
+
expect { subject.lock }.to change(subject, :locked?).from(false).to(true)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe "unlock" do
|
240
|
+
before { subject.lock }
|
241
|
+
it "should unlock the object" do
|
242
|
+
expect { subject.unlock }.to change(subject, :locked?).from(true).to(false)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe "lock!" do
|
247
|
+
it "should lock and save the object" do
|
248
|
+
subject.lock!
|
249
|
+
subject.reload
|
250
|
+
expect(subject.locked?).to be true
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
describe "unlock!" do
|
255
|
+
before { subject.lock! }
|
256
|
+
it "should unlock and save the object" do
|
257
|
+
subject.unlock!
|
258
|
+
subject.reload
|
259
|
+
expect(subject.locked?).to be false
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
210
263
|
end
|
264
|
+
|
211
265
|
end
|
212
266
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddr-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Coble
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -405,6 +405,7 @@ files:
|
|
405
405
|
- lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb
|
406
406
|
- lib/ddr/auth/ability_definitions/event_ability_definitions.rb
|
407
407
|
- lib/ddr/auth/ability_definitions/item_ability_definitions.rb
|
408
|
+
- lib/ddr/auth/ability_definitions/lock_ability_definitions.rb
|
408
409
|
- lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb
|
409
410
|
- lib/ddr/auth/ability_definitions/superuser_ability_definitions.rb
|
410
411
|
- lib/ddr/auth/ability_factory.rb
|