hydra-access-controls 6.4.2 → 6.5.0.rc2

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: d210d30d1d16eaf9fd257ca3e3f4a62ff3366842
4
- data.tar.gz: 77eb224f39e50722244cf75fc32c95ad07546208
3
+ metadata.gz: 58f7fe363bfe546c4b71a9dcbb957f891ed47196
4
+ data.tar.gz: 01cbe8640cdb8da959c7db447f64d68997408225
5
5
  SHA512:
6
- metadata.gz: 073cfb5759b3d8be62cbf3f27804d66279920de562655a2ad94d89136f74cc9134a334bef828837db602e71680a852b79f9d9c5a5400f91d9f6ac1b986305f0c
7
- data.tar.gz: d1e6d9284a74f9776c544060ceb8b401a9f705ad02aabc68d689cad00b0bff4733f403bf01ce16177e5164ff2096ea1fea05f2228d4e66955591aac2845ef30c
6
+ metadata.gz: a1cf8e0953ce0fe6870b7fa74e166615baab44a8fa83fd1018f7b59b4adfac72fd58e0a71edc329018d2f4e03ff7c8a06ddde4402f3aa1b51aa461a67f359f4f
7
+ data.tar.gz: e53f7c53fbd15308bb1aef82966cbb8e73f615e8d832f38dd4e0e9d162a31fd586d506d5e8af79d39b3021dab6b9e0aa71d4d3acb65b5c48ac7bafde3d98def3
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
22
22
  gem.add_dependency "active-fedora", '~> 6.7'
23
23
  gem.add_dependency 'cancan'
24
24
  gem.add_dependency 'deprecation'
25
- gem.add_dependency 'blacklight', '~> 4.0'
25
+ gem.add_dependency 'blacklight', '~> 4.7'
26
26
 
27
27
  gem.add_development_dependency "rake"
28
28
  gem.add_development_dependency 'rspec'
@@ -170,7 +170,7 @@ module Hydra
170
170
  def embargo_release_date=(release_date)
171
171
  release_date = release_date.to_s if release_date.is_a? Date
172
172
  begin
173
- release_date.nil? || Date.parse(release_date)
173
+ Date.parse(release_date)
174
174
  rescue
175
175
  return "INVALID DATE"
176
176
  end
@@ -24,10 +24,8 @@ module Hydra
24
24
  # @param [Hash] extra_controller_params (optional)
25
25
  def get_permissions_solr_response_for_doc_id(id=nil, extra_controller_params={})
26
26
  raise Blacklight::Exceptions::InvalidSolrID.new("The application is trying to retrieve permissions without specifying an asset id") if id.nil?
27
- #solr_response = Blacklight.solr.get permissions_solr_doc_params(id).merge(extra_controller_params)
28
- #path = blacklight_config.solr_path
29
27
  solr_opts = permissions_solr_doc_params(id).merge(extra_controller_params)
30
- response = Blacklight.solr.get('select', :params=> solr_opts)
28
+ response = ActiveFedora::SolrService.instance.conn.get('select', :params=>solr_opts)
31
29
  solr_response = Blacklight::SolrResponse.new(force_to_utf8(response), solr_opts)
32
30
 
33
31
  raise Blacklight::Exceptions::InvalidSolrID.new("The solr permissions search handler didn't return anything for id \"#{id}\"") if solr_response.docs.empty?
data/spec/factories.rb CHANGED
@@ -82,23 +82,23 @@ FactoryGirl.define do
82
82
  end
83
83
 
84
84
  factory :default_access_asset, :parent=>:asset do |a|
85
- permissions [{:name=>"joe_creator", :access=>"edit", :type=>"user"}]
85
+ permissions_attributes [{:name=>"joe_creator", :access=>"edit", :type=>"user"}]
86
86
  end
87
87
 
88
88
  factory :dept_access_asset, :parent=>:asset do |a|
89
- permissions [{:name=>"africana-faculty", :access=>"read", :type=>"group"}, {:name=>"joe_creator", :access=>"edit", :type=>"user"}]
89
+ permissions_attributes [{:name=>"africana-faculty", :access=>"read", :type=>"group"}, {:name=>"joe_creator", :access=>"edit", :type=>"user"}]
90
90
  end
91
91
 
92
92
  factory :group_edit_asset, :parent=>:asset do |a|
93
- permissions [{:name=>"africana-faculty", :access=>"edit", :type=>"group"}, {:name=>"calvin_collaborator", :access=>"edit", :type=>"user"}]
93
+ permissions_attributes [{:name=>"africana-faculty", :access=>"edit", :type=>"group"}, {:name=>"calvin_collaborator", :access=>"edit", :type=>"user"}]
94
94
  end
95
95
 
96
96
  factory :org_read_access_asset, :parent=>:asset do |a|
97
- permissions [{:name=>"registered", :access=>"read", :type=>"group"}, {:name=>"joe_creator", :access=>"edit", :type=>"user"}, {:name=>"calvin_collaborator", :access=>"edit", :type=>"user"}]
97
+ permissions_attributes [{:name=>"registered", :access=>"read", :type=>"group"}, {:name=>"joe_creator", :access=>"edit", :type=>"user"}, {:name=>"calvin_collaborator", :access=>"edit", :type=>"user"}]
98
98
  end
99
99
 
100
100
  factory :open_access_asset, :parent=>:asset do |a|
101
- permissions [{:name=>"public", :access=>"read", :type=>"group"}, {:name=>"joe_creator", :access=>"edit", :type=>"user"}, {:name=>"calvin_collaborator", :access=>"edit", :type=>"user"}]
101
+ permissions_attributes [{:name=>"public", :access=>"read", :type=>"group"}, {:name=>"joe_creator", :access=>"edit", :type=>"user"}, {:name=>"calvin_collaborator", :access=>"edit", :type=>"user"}]
102
102
  end
103
103
 
104
104
  end
@@ -1,8 +1,8 @@
1
1
  require 'active-fedora'
2
+
2
3
  class ModsAsset < ActiveFedora::Base
3
- include Hydra::ModelMixins::RightsMetadata
4
- has_metadata :name => "rightsMetadata", :type => Hydra::Datastream::RightsMetadata
5
-
4
+ include Hydra::AccessControls::Permissions
5
+
6
6
  # This is how we're associating admin policies with assets.
7
7
  # You can associate them however you want, just use the :is_governed_by relationship
8
8
  belongs_to :admin_policy, :class_name=> "Hydra::AdminPolicy", :property=>:is_governed_by
@@ -3,8 +3,7 @@ require 'spec_helper'
3
3
  describe Hydra::Datastream::RightsMetadata do
4
4
  before :all do
5
5
  class RightsTest < ActiveFedora::Base
6
- include Hydra::ModelMixins::RightsMetadata
7
- has_metadata name: 'rightsMetadata', type: Hydra::Datastream::RightsMetadata
6
+ include Hydra::AccessControls::Permissions
8
7
  end
9
8
  end
10
9
 
@@ -176,11 +176,6 @@ describe Hydra::Datastream::RightsMetadata do
176
176
  it "should only accept valid date values" do
177
177
 
178
178
  end
179
- it "should accept a nil value after having a date value" do
180
- @sample.embargo_release_date=("2010-12-01")
181
- @sample.embargo_release_date=(nil)
182
- @sample.embargo_release_date.should == nil
183
- end
184
179
  end
185
180
  describe "embargo_release_date" do
186
181
  it "should return solr formatted date" do
File without changes
@@ -115,6 +115,7 @@ describe Hydra::AccessControls::Permissions do
115
115
  it "should behave like #permissions_attributes=" do
116
116
  foo1 = Foo.new
117
117
  foo2 = Foo.new
118
+ Deprecation.stub(:warn).and_return(nil)
118
119
  foo1.permissions = [{type: "user", access: "edit", name: "editor"}]
119
120
  foo2.permissions_attributes = [{type: "user", access: "edit", name: "editor"}]
120
121
  foo1.permissions.should == foo2.permissions
@@ -6,50 +6,50 @@ describe Hydra::ModelMixins::RightsMetadata do
6
6
  subject.discover_groups=['group1', 'group2']
7
7
  subject.edit_users=['user1']
8
8
  subject.read_users=['user2', 'user3']
9
- subject.permissions.should include({:type=>"group", :access=>"discover", :name=>"group1"},
10
- {:type=>"group", :access=>"discover", :name=>"group2"},
11
- {:type=>"user", :access=>"read", :name=>"user2"},
12
- {:type=>"user", :access=>"read", :name=>"user3"},
13
- {:type=>"user", :access=>"edit", :name=>"user1"})
9
+ subject.permissions.should include(Hydra::AccessControls::Permission.new({:type=>"group", :access=>"discover", :name=>"group1"}),
10
+ Hydra::AccessControls::Permission.new({:type=>"group", :access=>"discover", :name=>"group2"}),
11
+ Hydra::AccessControls::Permission.new({:type=>"user", :access=>"read", :name=>"user2"}),
12
+ Hydra::AccessControls::Permission.new({:type=>"user", :access=>"read", :name=>"user3"}),
13
+ Hydra::AccessControls::Permission.new({:type=>"user", :access=>"edit", :name=>"user1"}))
14
14
  end
15
15
 
16
16
  describe "updating permissions" do
17
17
  it "should create new group permissions" do
18
- subject.permissions = [{:name=>'group1', :access=>'discover', :type=>'group'}]
19
- subject.permissions.should == [{:type=>'group', :access=>'discover', :name=>'group1'}]
18
+ subject.permissions_attributes = [{:name=>'group1', :access=>'discover', :type=>'group'}]
19
+ subject.permissions.should == [Hydra::AccessControls::Permission.new({:type=>'group', :access=>'discover', :name=>'group1'})]
20
20
  end
21
21
  it "should create new user permissions" do
22
- subject.permissions = [{:name=>'user1', :access=>'discover', :type=>'user'}]
23
- subject.permissions.should == [{:type=>'user', :access=>'discover', :name=>'user1'}]
22
+ subject.permissions_attributes = [{:name=>'user1', :access=>'discover', :type=>'user'}]
23
+ subject.permissions.should == [Hydra::AccessControls::Permission.new({:type=>'user', :access=>'discover', :name=>'user1'})]
24
24
  end
25
25
  it "should not replace existing groups" do
26
- subject.permissions = [{:name=>'group1', :access=>'discover', :type=>'group'}]
27
- subject.permissions = [{:name=>'group2', :access=>'discover', :type=>'group'}]
28
- subject.permissions.should == [{:type=>'group', :access=>'discover', :name=>'group1'},
29
- {:type=>'group', :access=>'discover', :name=>'group2'}]
26
+ subject.permissions_attributes = [{:name=>'group1', :access=>'discover', :type=>'group'}]
27
+ subject.permissions_attributes = [{:name=>'group2', :access=>'discover', :type=>'group'}]
28
+ subject.permissions.should == [Hydra::AccessControls::Permission.new({:type=>'group', :access=>'discover', :name=>'group1'}),
29
+ Hydra::AccessControls::Permission.new({:type=>'group', :access=>'discover', :name=>'group2'})]
30
30
  end
31
31
  it "should not replace existing users" do
32
- subject.permissions = [{:name=>'user1', :access=>'discover', :type=>'user'}]
33
- subject.permissions = [{:name=>'user2', :access=>'discover', :type=>'user'}]
34
- subject.permissions.should == [{:type=>'user', :access=>'discover', :name=>'user1'},
35
- {:type=>'user', :access=>'discover', :name=>'user2'}]
32
+ subject.permissions_attributes = [{:name=>'user1', :access=>'discover', :type=>'user'}]
33
+ subject.permissions_attributes = [{:name=>'user2', :access=>'discover', :type=>'user'}]
34
+ subject.permissions.should == [Hydra::AccessControls::Permission.new({:type=>'user', :access=>'discover', :name=>'user1'}),
35
+ Hydra::AccessControls::Permission.new({:type=>'user', :access=>'discover', :name=>'user2'})]
36
36
  end
37
37
  it "should update permissions on existing users" do
38
- subject.permissions = [{:name=>'user1', :access=>'discover', :type=>'user'}]
39
- subject.permissions = [{:name=>'user1', :access=>'edit', :type=>'user'}]
40
- subject.permissions.should == [{:type=>'user', :access=>'edit', :name=>'user1'}]
38
+ subject.permissions_attributes = [{:name=>'user1', :access=>'discover', :type=>'user'}]
39
+ subject.permissions_attributes = [{:name=>'user1', :access=>'edit', :type=>'user'}]
40
+ subject.permissions.should == [Hydra::AccessControls::Permission.new({:type=>'user', :access=>'edit', :name=>'user1'})]
41
41
  end
42
42
  it "should update permissions on existing groups" do
43
- subject.permissions = [{:name=>'group1', :access=>'discover', :type=>'group'}]
44
- subject.permissions = [{:name=>'group1', :access=>'edit', :type=>'group'}]
45
- subject.permissions.should == [{:type=>'group', :access=>'edit', :name=>'group1'}]
43
+ subject.permissions_attributes = [{:name=>'group1', :access=>'discover', :type=>'group'}]
44
+ subject.permissions_attributes = [{:name=>'group1', :access=>'edit', :type=>'group'}]
45
+ subject.permissions.should == [Hydra::AccessControls::Permission.new({:type=>'group', :access=>'edit', :name=>'group1'})]
46
46
  end
47
47
  it "should assign user permissions when :type == 'person'" do
48
- subject.permissions = [{:name=>'user1', :access=>'discover', :type=>'person'}]
49
- subject.permissions.should == [{:type=>'user', :access=>'discover', :name=>'user1'}]
48
+ subject.permissions_attributes = [{:name=>'user1', :access=>'discover', :type=>'person'}]
49
+ subject.permissions.should == [Hydra::AccessControls::Permission.new({:type=>'user', :access=>'discover', :name=>'user1'})]
50
50
  end
51
51
  it "should raise an ArgumentError when the :type hashkey is invalid" do
52
- expect{subject.permissions = [{:name=>'user1', :access=>'read', :type=>'foo'}]}.to raise_error(ArgumentError)
52
+ expect{subject.permissions_attributes = [{:name=>'user1', :access=>'read', :type=>'foo'}]}.to raise_error(ArgumentError)
53
53
  end
54
54
  end
55
55
 
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: 6.4.2
4
+ version: 6.5.0.rc2
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-05-05 00:00:00.000000000 Z
13
+ date: 2014-02-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -74,14 +74,14 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '4.0'
77
+ version: '4.7'
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ~>
83
83
  - !ruby/object:Gem::Version
84
- version: '4.0'
84
+ version: '4.7'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rake
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -163,7 +163,7 @@ files:
163
163
  - spec/unit/hydra_rights_metadata_persistence_spec.rb
164
164
  - spec/unit/hydra_rights_metadata_spec.rb
165
165
  - spec/unit/inheritable_rights_metadata_spec.rb
166
- - spec/unit/permission.rb
166
+ - spec/unit/permission_spec.rb
167
167
  - spec/unit/permissions_spec.rb
168
168
  - spec/unit/policy_aware_ability_spec.rb
169
169
  - spec/unit/policy_aware_access_controls_enforcement_spec.rb
@@ -187,12 +187,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  version: 1.9.3
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - '>='
190
+ - - '>'
191
191
  - !ruby/object:Gem::Version
192
- version: '0'
192
+ version: 1.3.1
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.0.14
195
+ rubygems_version: 2.2.2
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Access controls for project hydra
@@ -213,7 +213,7 @@ test_files:
213
213
  - spec/unit/hydra_rights_metadata_persistence_spec.rb
214
214
  - spec/unit/hydra_rights_metadata_spec.rb
215
215
  - spec/unit/inheritable_rights_metadata_spec.rb
216
- - spec/unit/permission.rb
216
+ - spec/unit/permission_spec.rb
217
217
  - spec/unit/permissions_spec.rb
218
218
  - spec/unit/policy_aware_ability_spec.rb
219
219
  - spec/unit/policy_aware_access_controls_enforcement_spec.rb