hydra-access-controls 9.0.0.rc3 → 9.0.0

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: a64ed79e8667bcdef1d5d26d9fc0a82dc98ae5ae
4
- data.tar.gz: 99da4fafbe99c24a6bc17b5767a036ba4eac9176
3
+ metadata.gz: 9dad3b88eb0367db1735dd5e60f70e163474431f
4
+ data.tar.gz: 19b7d120a816665c354b956e16748f0b21fd0968
5
5
  SHA512:
6
- metadata.gz: d6d2fed2907a52c6fc74badeefa95918742d4c8b33c6e9ca2dbd33dd0dd2010d21083bac9f51187f793c544e82536fad102aabca15f2343c254840555af4d1a1
7
- data.tar.gz: 10d2fcaded37c8e62306cf2203beaf2a1193f5ee44e66e6a13f7e86ffe926bc207357928c63ac845594a4163ba6f03977fa2acf71c5bac56847899563f5e0e0a
6
+ metadata.gz: 2e96001b89dc8f592253781ec5d99de6fe9880b51d7ec92717975c129285f9bde669ff80563dd2b44a96d938928ea314480cf5c837579c8cff5fa2efd7a4ccc7
7
+ data.tar.gz: 42d76b3a6fc9376a2ca65fed28d9139f7333cef47dc89631cf3e112f572b3724db44b3dae152c8f733e13bbec5c048111432df82a59375298a82a022b9b7b083
@@ -0,0 +1,14 @@
1
+ module Hydra::WithDepositor
2
+ # Adds metadata about the depositor to the asset and
3
+ # grants edit permissions to the +depositor+
4
+ # @param [String, #user_key] depositor
5
+ def apply_depositor_metadata(depositor)
6
+ depositor_id = depositor.respond_to?(:user_key) ? depositor.user_key : depositor
7
+
8
+ if respond_to? :depositor
9
+ self.depositor = depositor_id
10
+ end
11
+ self.edit_users += [depositor_id]
12
+ true
13
+ end
14
+ end
@@ -18,10 +18,10 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.required_ruby_version = '>= 1.9.3'
20
20
 
21
- gem.add_dependency 'activesupport'
22
- gem.add_dependency "active-fedora", '~> 9.0.0.rc2'
23
- gem.add_dependency 'cancancan'
24
- gem.add_dependency 'deprecation'
21
+ gem.add_dependency 'activesupport', '~> 4.0'
22
+ gem.add_dependency "active-fedora", '~> 9.0.0'
23
+ gem.add_dependency 'cancancan', '~> 1.8'
24
+ gem.add_dependency 'deprecation', '~> 0.1.0'
25
25
  gem.add_dependency "blacklight", '~> 5.3'
26
26
 
27
27
  # sass-rails is typically generated into the app's gemfile by `rails new`
@@ -30,6 +30,6 @@ Gem::Specification.new do |gem|
30
30
  # declare a dependency on) sass-rails
31
31
  gem.add_dependency 'sass-rails'
32
32
 
33
- gem.add_development_dependency "rake"
34
- gem.add_development_dependency 'rspec'
33
+ gem.add_development_dependency "rake", '~> 10.1'
34
+ gem.add_development_dependency 'rspec' '~> 3.1'
35
35
  end
@@ -10,7 +10,7 @@ module Hydra::AccessControlsEnforcement
10
10
  # CatalogController.include ModuleDefiningNewMethod
11
11
  # CatalogController.solr_access_filters_logic += [:new_method]
12
12
  # CatalogController.solr_access_filters_logic.delete(:we_dont_want)
13
- self.solr_access_filters_logic = [:apply_group_permissions, :apply_user_permissions, :apply_superuser_permissions ]
13
+ self.solr_access_filters_logic = [:apply_group_permissions, :apply_user_permissions]
14
14
 
15
15
  end
16
16
 
@@ -117,9 +117,4 @@ module Hydra::AccessControlsEnforcement
117
117
  end
118
118
  user_access_filters
119
119
  end
120
-
121
- # override to apply super user permissions
122
- def apply_superuser_permissions(permission_types, ability = current_ability)
123
- []
124
- end
125
120
  end
@@ -28,6 +28,7 @@ require_relative '../app/models/hydra/access_controls/access_control_list'
28
28
  require_relative '../app/models/hydra/access_controls/permission'
29
29
  require_relative '../app/models/hydra/access_controls/embargo'
30
30
  require_relative '../app/models/hydra/access_controls/lease'
31
+ require_relative '../app/models/concerns/hydra/with_depositor'
31
32
  require_relative '../app/services/hydra/lease_service'
32
33
  require_relative '../app/services/hydra/embargo_service'
33
34
  require_relative '../app/validators/hydra/future_date_validator'
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hydra::WithDepositor do
4
+ before do
5
+ class TestClass
6
+ include Hydra::WithDepositor
7
+ attr_accessor :edit_users, :depositor
8
+ def initialize
9
+ @edit_users = []
10
+ end
11
+ end
12
+ end
13
+
14
+ after { Object.send(:remove_const, :TestClass) }
15
+
16
+ subject { TestClass.new }
17
+
18
+ describe "#apply_depositor_metadata" do
19
+ it "should add edit access" do
20
+ subject.apply_depositor_metadata('naomi')
21
+ expect(subject.edit_users).to eq ['naomi']
22
+ end
23
+
24
+ it "should not overwrite people with edit access" do
25
+ subject.edit_users = ['jessie']
26
+ subject.apply_depositor_metadata('naomi')
27
+ expect(subject.edit_users).to match_array ['naomi', 'jessie']
28
+ end
29
+
30
+ it "should set depositor" do
31
+ subject.apply_depositor_metadata('chris')
32
+ expect(subject.depositor).to eq 'chris'
33
+ end
34
+
35
+ it "should accept objects that respond_to? :user_key" do
36
+ stub_user = double(:user, user_key: 'monty')
37
+ subject.apply_depositor_metadata(stub_user)
38
+ expect(subject.depositor).to eq 'monty'
39
+ end
40
+ end
41
+ 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: 9.0.0.rc3
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,64 +10,64 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-16 00:00:00.000000000 Z
13
+ date: 2015-01-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '4.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: '4.0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: active-fedora
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 9.0.0.rc2
35
+ version: 9.0.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 9.0.0.rc2
42
+ version: 9.0.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: cancancan
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '0'
49
+ version: '1.8'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ">="
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0'
56
+ version: '1.8'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: deprecation
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0'
63
+ version: 0.1.0
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: 0.1.0
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: blacklight
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -100,18 +100,18 @@ dependencies:
100
100
  name: rake
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ">="
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '0'
105
+ version: '10.1'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ">="
110
+ - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '0'
112
+ version: '10.1'
113
113
  - !ruby/object:Gem::Dependency
114
- name: rspec
114
+ name: rspec~> 3.1
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
@@ -143,6 +143,7 @@ files:
143
143
  - app/models/concerns/hydra/access_controls/with_access_right.rb
144
144
  - app/models/concerns/hydra/admin_policy_behavior.rb
145
145
  - app/models/concerns/hydra/rights.rb
146
+ - app/models/concerns/hydra/with_depositor.rb
146
147
  - app/models/hydra/access_controls/access_control_list.rb
147
148
  - app/models/hydra/access_controls/embargo.rb
148
149
  - app/models/hydra/access_controls/lease.rb
@@ -194,6 +195,7 @@ files:
194
195
  - spec/unit/role_mapper_spec.rb
195
196
  - spec/unit/visibility_spec.rb
196
197
  - spec/unit/with_access_right_spec.rb
198
+ - spec/unit/with_depositor_spec.rb
197
199
  - spec/validators/future_date_validator_spec.rb
198
200
  - tasks/hydra-access-controls.rake
199
201
  homepage: http://projecthydra.org
@@ -211,12 +213,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
213
  version: 1.9.3
212
214
  required_rubygems_version: !ruby/object:Gem::Requirement
213
215
  requirements:
214
- - - ">"
216
+ - - ">="
215
217
  - !ruby/object:Gem::Version
216
- version: 1.3.1
218
+ version: '0'
217
219
  requirements: []
218
220
  rubyforge_project:
219
- rubygems_version: 2.4.3
221
+ rubygems_version: 2.2.2
220
222
  signing_key:
221
223
  specification_version: 4
222
224
  summary: Access controls for project hydra
@@ -245,5 +247,6 @@ test_files:
245
247
  - spec/unit/role_mapper_spec.rb
246
248
  - spec/unit/visibility_spec.rb
247
249
  - spec/unit/with_access_right_spec.rb
250
+ - spec/unit/with_depositor_spec.rb
248
251
  - spec/validators/future_date_validator_spec.rb
249
252
  has_rdoc: