ddr-models 2.4.14 → 2.4.15

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
  SHA1:
3
- metadata.gz: 89463db1599ed9a7f4707c36efed6b90edc54d43
4
- data.tar.gz: ed8918d41b6176c00516bfadcc317593d0466255
3
+ metadata.gz: b36660eee0bd55bbbbbe5ec8ee9c0b69291bd46e
4
+ data.tar.gz: b0b5714f775e92d23fa50f1cfd2d0286dce8c17f
5
5
  SHA512:
6
- metadata.gz: 19c5b9b657b4d755822ba5877016095264a6ee4c49751d87013d685571a5bf24d8568c2ebe75624aebfc3275f03fb180aa925451bae862832076a47692df0941
7
- data.tar.gz: 499b13e8195943a1d4d9754a2ffe6965b275c14da27c47d9044f842ec9959e913335ee1b7b7b6b85173cf6c81d122728b41892bb1ea8a2b9539b3b592135f629
6
+ metadata.gz: 894ff0cff82bc9bb72102b741a4959e69d06bd3d8a0c62f8322d9ff5478834b95fdab8491eb2829230c9f466ec099e3c3f6d7d96bf923f62f5815ed149f750ec
7
+ data.tar.gz: 4656487fb2cce3c1c5a62150b0733a4ccb22ae0c19f38f2e7407b87762c995c6f17cd3fe56077452651509c916e61a225f9ba702eb62b8f0edbc8502f99fcbdb
@@ -6,6 +6,22 @@ module Ddr
6
6
  if member_of? Ddr::Auth.collection_creators_group
7
7
  can :create, ::Collection
8
8
  end
9
+ can :export, ::Collection do |obj|
10
+ has_policy_permission?(obj, Permissions::READ)
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def policy_permissions(obj)
17
+ obj.roles
18
+ .in_policy_scope
19
+ .agent(agents)
20
+ .permissions
21
+ end
22
+
23
+ def has_policy_permission?(obj, perm)
24
+ policy_permissions(obj).include?(perm)
9
25
  end
10
26
 
11
27
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "2.4.14"
3
+ VERSION = "2.4.15"
4
4
  end
5
5
  end
@@ -57,21 +57,38 @@ module Ddr::Auth
57
57
  end
58
58
 
59
59
  describe "Collection abilities" do
60
- before do
61
- allow(Ddr::Auth).to receive(:collection_creators_group) { "collection_creators" }
62
- end
63
- describe "when the user is a collection creator" do
60
+ describe "create" do
64
61
  before do
65
- allow(auth_context).to receive(:member_of?).with("collection_creators") { true }
62
+ allow(Ddr::Auth).to receive(:collection_creators_group) { "collection_creators" }
63
+ end
64
+ describe "when the user is a collection creator" do
65
+ before do
66
+ allow(auth_context).to receive(:member_of?).with("collection_creators") { true }
67
+ end
68
+ it { should be_able_to(:create, Collection) }
66
69
  end
67
- it { should be_able_to(:create, Collection) }
68
- end
69
70
 
70
- describe "when the user is not a collection creator" do
71
- before do
72
- allow(auth_context).to receive(:member_of?).with("collection_creators") { false }
71
+ describe "when the user is not a collection creator" do
72
+ before do
73
+ allow(auth_context).to receive(:member_of?).with("collection_creators") { false }
74
+ end
75
+ it { should_not be_able_to(:create, Collection) }
76
+ end
77
+ end
78
+ describe "export" do
79
+ let(:collection) { FactoryGirl.build(:collection) }
80
+ describe "when the user has read permission via policy scope role" do
81
+ before {
82
+ collection.roles.grant role_type: "Viewer", agent: auth_context.user.to_s, scope: "policy"
83
+ }
84
+ it { is_expected.to be_able_to(:export, collection) }
85
+ end
86
+ describe "when the user does not have read permission via policy scope role" do
87
+ before {
88
+ collection.roles.grant role_type: "Viewer", agent: auth_context.user.to_s
89
+ }
90
+ it { is_expected.not_to be_able_to(:export, collection) }
73
91
  end
74
- it { should_not be_able_to(:create, Collection) }
75
92
  end
76
93
  end
77
94
 
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.14
4
+ version: 2.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble