hydra-access-controls 6.0.0.pre1 → 6.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.required_ruby_version = '>= 1.9.3'
19
19
 
20
20
  gem.add_dependency 'activesupport'
21
- gem.add_dependency 'active-fedora'
21
+ gem.add_dependency 'active-fedora', '6.0.0.pre2'
22
22
  gem.add_dependency 'cancan'
23
23
  gem.add_dependency 'deprecation'
24
24
  gem.add_dependency 'blacklight'
@@ -119,9 +119,11 @@ module Hydra::AccessControlsEnforcement
119
119
  # @param [Hash] opts (optional, not currently used)
120
120
  def enforce_show_permissions(opts={})
121
121
  load_permissions_from_solr
122
- unless @permissions_solr_document['access_t'] && (@permissions_solr_document['access_t'].first == "public" || @permissions_solr_document['access_t'].first == "Public")
123
- if @permissions_solr_document["embargo_release_date_dt"]
124
- embargo_date = Date.parse(@permissions_solr_document["embargo_release_date_dt"].split(/T/)[0])
122
+ access_key = ActiveFedora::SolrService.solr_name("access", Hydra::Datastream::RightsMetadata.indexer)
123
+ embargo_key = ActiveFedora::SolrService.solr_name("embargo_release_date", Hydra::Datastream::RightsMetadata.date_indexer)
124
+ unless @permissions_solr_document[access_key] && (@permissions_solr_document[access_key].first == "public" || @permissions_solr_document[access_key].first == "Public")
125
+ if @permissions_solr_document[embargo_key]
126
+ embargo_date = Date.parse(@permissions_solr_document[embargo_key].split(/T/)[0])
125
127
  if embargo_date > Date.parse(Time.now.to_s)
126
128
  unless can?(:edit, params[:id])
127
129
  raise Hydra::AccessDenied.new("This item is under embargo. You do not have sufficient access privileges to read this document.", :edit, params[:id])
@@ -216,7 +218,7 @@ module Hydra::AccessControlsEnforcement
216
218
  user_access_filters = []
217
219
 
218
220
  permission_types.each do |type|
219
- user_access_filters << "#{type}_access_group_t:public"
221
+ user_access_filters << ActiveFedora::SolrService.solr_name("#{type}_access_group", Hydra::Datastream::RightsMetadata.indexer) + ":public"
220
222
  end
221
223
 
222
224
  # Grant access based on user id & role
@@ -232,7 +234,7 @@ module Hydra::AccessControlsEnforcement
232
234
  user_access_filters = []
233
235
  current_ability.user_groups.each_with_index do |role, i|
234
236
  permission_types.each do |type|
235
- user_access_filters << escape_filter("#{type}_access_group_t", role)
237
+ user_access_filters << escape_filter(ActiveFedora::SolrService.solr_name("#{type}_access_group", Hydra::Datastream::RightsMetadata.indexer), role)
236
238
  end
237
239
  end
238
240
  user_access_filters
@@ -245,9 +247,9 @@ module Hydra::AccessControlsEnforcement
245
247
  def apply_individual_permissions(permission_types)
246
248
  # for individual person access
247
249
  user_access_filters = []
248
- if user_key.present?
250
+ if current_user && current_user.user_key.present?
249
251
  permission_types.each do |type|
250
- user_access_filters << escape_filter("#{type}_access_person_t", user_key)
252
+ user_access_filters << escape_filter(ActiveFedora::SolrService.solr_name("#{type}_access_person", Hydra::Datastream::RightsMetadata.indexer), current_user.user_key)
251
253
  end
252
254
  end
253
255
  user_access_filters
@@ -274,6 +276,6 @@ module Hydra::AccessControlsEnforcement
274
276
  # @param user_parameters the current user-subitted parameters
275
277
  def exclude_unwanted_models(solr_parameters, user_parameters)
276
278
  solr_parameters[:fq] ||= []
277
- solr_parameters[:fq] << "-has_model_s:\"info:fedora/afmodel:FileAsset\""
279
+ solr_parameters[:fq] << "-#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:\"info:fedora/afmodel:FileAsset\""
278
280
  end
279
281
  end
@@ -9,7 +9,10 @@ class Hydra::AdminPolicy < ActiveFedora::Base
9
9
  # Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
10
10
  has_metadata :name => "rightsMetadata", :type => Hydra::Datastream::RightsMetadata
11
11
 
12
- has_metadata :name =>'descMetadata', :type => ActiveFedora::QualifiedDublinCoreDatastream
12
+ has_metadata :name =>'descMetadata', :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
13
+ m.title :type=> :text, :index_as=>[:searchable]
14
+
15
+ end
13
16
 
14
17
  delegate_to :descMetadata, [:title, :description], :unique=>true
15
18
  delegate :license_title, :to=>'rightsMetadata', :at=>[:license, :title], :unique=>true
@@ -31,11 +34,11 @@ class Hydra::AdminPolicy < ActiveFedora::Base
31
34
  or_query = []
32
35
  RoleMapper.roles(user).each do |group|
33
36
  permissions.each do |permission|
34
- or_query << "#{permission}_access_group_t:#{group}"
37
+ or_query << ActiveFedora::SolrService.solr_name("#{permission}_access_group", indexer)+":#{group}"
35
38
  end
36
39
  end
37
40
  permissions.each do |permission|
38
- or_query << "#{permission}_access_person_t:#{user.user_key}"
41
+ or_query << ActiveFedora::SolrService.solr_name("#{permission}_access_person", indexer)+":#{user.user_key}"
39
42
  end
40
43
  find_with_conditions(or_query.join(" OR "))
41
44
  end
@@ -73,9 +76,4 @@ class Hydra::AdminPolicy < ActiveFedora::Base
73
76
 
74
77
  end
75
78
 
76
- def to_solr(solr_doc = {})
77
- super
78
- solr_doc['title_display'] = solr_doc['title_t'].first if solr_doc['title_t']
79
- solr_doc
80
- end
81
79
  end
@@ -7,13 +7,13 @@ module Hydra
7
7
  @terminology = Hydra::Datastream::RightsMetadata.terminology
8
8
 
9
9
  def to_solr(solr_doc=Hash.new)
10
- solr_doc["inheritable_discover_access_group_t"] = discover_access.machine.group
11
- solr_doc["inheritable_discover_access_person_t"] = discover_access.machine.person
12
- solr_doc["inheritable_read_access_group_t"] = read_access.machine.group
13
- solr_doc["inheritable_read_access_person_t"] = read_access.machine.person
14
- solr_doc["inheritable_edit_access_group_t"] = edit_access.machine.group
15
- solr_doc["inheritable_edit_access_person_t"] = edit_access.machine.person
16
- solr_doc["inheritable_embargo_release_date_dt"] = embargo_release_date
10
+ solr_doc[ActiveFedora::SolrService.solr_name('inheritable_discover_access_group', indexer)] = discover_access.machine.group
11
+ solr_doc[ActiveFedora::SolrService.solr_name('inheritable_discover_access_person', indexer)] = discover_access.machine.person
12
+ solr_doc[ActiveFedora::SolrService.solr_name('inheritable_read_access_group', indexer)] = read_access.machine.group
13
+ solr_doc[ActiveFedora::SolrService.solr_name('inheritable_read_access_person', indexer)] = read_access.machine.person
14
+ solr_doc[ActiveFedora::SolrService.solr_name('inheritable_edit_access_group', indexer)] = edit_access.machine.group
15
+ solr_doc[ActiveFedora::SolrService.solr_name('inheritable_edit_access_person', indexer)] = edit_access.machine.person
16
+ solr_doc[ActiveFedora::SolrService.solr_name('inheritable_embargo_release_date', date_indexer)] = embargo_release_date
17
17
  return solr_doc
18
18
  end
19
19
  end
@@ -175,22 +175,38 @@ module Hydra
175
175
  def to_solr(solr_doc=Hash.new)
176
176
  super(solr_doc)
177
177
  vals = edit_access.machine.group
178
- solr_doc['edit_access_group_t'] = vals unless vals.empty?
178
+ solr_doc[ActiveFedora::SolrService.solr_name('edit_access_group', indexer)] = vals unless vals.empty?
179
179
  vals = discover_access.machine.group
180
- solr_doc['discover_access_group_t'] = vals unless vals.empty?
180
+ solr_doc[ActiveFedora::SolrService.solr_name('discover_access_group', indexer)] = vals unless vals.empty?
181
181
  vals = read_access.machine.group
182
- solr_doc['read_access_group_t'] = vals unless vals.empty?
182
+ solr_doc[ActiveFedora::SolrService.solr_name('read_access_group', indexer)] = vals unless vals.empty?
183
183
  vals = edit_access.machine.person
184
- solr_doc['edit_access_person_t'] = vals unless vals.empty?
184
+ solr_doc[ActiveFedora::SolrService.solr_name('edit_access_person', indexer)] = vals unless vals.empty?
185
185
  vals = discover_access.machine.person
186
- solr_doc['discover_access_person_t'] = vals unless vals.empty?
186
+ solr_doc[ActiveFedora::SolrService.solr_name('discover_access_person', indexer)] = vals unless vals.empty?
187
187
  vals = read_access.machine.person
188
- solr_doc['read_access_person_t'] = vals unless vals.empty?
188
+ solr_doc[ActiveFedora::SolrService.solr_name('read_access_person', indexer)] = vals unless vals.empty?
189
189
 
190
190
  ::Solrizer::Extractor.insert_solr_field_value(solr_doc, "embargo_release_date_dt", embargo_release_date(:format=>:solr_date)) if embargo_release_date
191
191
  solr_doc
192
192
  end
193
193
 
194
+ def indexer
195
+ self.class.indexer
196
+ end
197
+
198
+ def self.indexer
199
+ @indexer ||= Solrizer::Descriptor.new(:text, :stored, :indexed, :multivalued)
200
+ end
201
+
202
+ def date_indexer
203
+ self.class.date_indexer
204
+ end
205
+
206
+ def self.date_indexer
207
+ @date_indexer ||= Solrizer::Descriptor.new(:date, :stored, :indexed)
208
+ end
209
+
194
210
  # Completely clear the permissions
195
211
  def clear_permissions!
196
212
  remove_all_permissions({:person=>true})
@@ -26,9 +26,10 @@ module Hydra::PolicyAwareAbility
26
26
  # Returns nil if no policy associated with the object
27
27
  def policy_pid_for(object_pid)
28
28
  return @policy_pid if @policy_pid
29
- solr_result = ActiveFedora::Base.find_with_conditions({:id=>object_pid}, :fl=>'is_governed_by_s')
29
+ #is_governed_by_ssim
30
+ solr_result = ActiveFedora::Base.find_with_conditions({:id=>object_pid}, :fl=>ActiveFedora::SolrService.solr_name('is_governed_by', :symbol))
30
31
  begin
31
- @policy_pid = value_from_solr_field(solr_result, 'is_governed_by_s').first.gsub("info:fedora/", "")
32
+ @policy_pid = value_from_solr_field(solr_result, ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)).first.gsub("info:fedora/", "")
32
33
  rescue NoMethodError
33
34
  @policy_pid = nil
34
35
  end
@@ -16,7 +16,7 @@ module Hydra::PolicyAwareAccessControlsEnforcement
16
16
  def policy_clauses
17
17
  policy_pids = policies_with_access
18
18
  return nil if policy_pids.empty?
19
- '(' + policy_pids.map {|pid| "is_governed_by_s:info\\:fedora/#{pid.gsub(/:/, '\\\\:')}"}.join(' OR ') + ')'
19
+ '(' + policy_pids.map {|pid| ActiveFedora::SolrService.solr_name("is_governed_by", :symbol) + ":info\\:fedora/#{pid.gsub(/:/, '\\\\:')}"}.join(' OR ') + ')'
20
20
  end
21
21
 
22
22
 
@@ -39,7 +39,7 @@ module Hydra::PolicyAwareAccessControlsEnforcement
39
39
  user_access_filters = []
40
40
  current_ability.user_groups.each_with_index do |role, i|
41
41
  discovery_permissions.each do |type|
42
- user_access_filters << "inheritable_#{type}_access_group_t:#{role}"
42
+ user_access_filters << ActiveFedora::SolrService.solr_name("inheritable_#{type}_access_group", Hydra::Datastream::RightsMetadata.indexer ) + ":#{role}"
43
43
  end
44
44
  end
45
45
  user_access_filters
@@ -49,7 +49,7 @@ module Hydra::PolicyAwareAccessControlsEnforcement
49
49
  # for individual person access
50
50
  user_access_filters = []
51
51
  discovery_permissions.each do |type|
52
- user_access_filters << "inheritable_#{type}_access_person_t:#{user_key}"
52
+ user_access_filters << ActiveFedora::SolrService.solr_name("inheritable_#{type}_access_person", Hydra::Datastream::RightsMetadata.indexer ) + ":#{current_user.user_key}"
53
53
  end
54
54
  user_access_filters
55
55
  end
@@ -4,18 +4,18 @@ describe Ability do
4
4
  before do
5
5
  Hydra.stub(:config).and_return({
6
6
  :permissions=>{
7
- :discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
8
- :read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
9
- :edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
7
+ :discover => {:group =>"discover_access_group_tsim", :individual=>"discover_access_person_tsim"},
8
+ :read => {:group =>"read_access_group_tsim", :individual=>"read_access_person_tsim"},
9
+ :edit => {:group =>"edit_access_group_tsim", :individual=>"edit_access_person_tsim"},
10
10
  :owner => "depositor_t",
11
- :embargo_release_date => "embargo_release_date_dt",
11
+ :embargo_release_date => "embargo_release_date_dtsi",
12
12
 
13
13
  :inheritable => {
14
- :discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
15
- :read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
16
- :edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
17
- :owner => "inheritable_depositor_t",
18
- :embargo_release_date => "inheritable_embargo_release_date_dt"
14
+ :discover => {:group =>"inheritable_discover_access_group_tsim", :individual=>"inheritable_discover_access_person_tsim"},
15
+ :read => {:group =>"inheritable_read_access_group_tsim", :individual=>"inheritable_read_access_person_tsim"},
16
+ :edit => {:group =>"inheritable_edit_access_group_tsim", :individual=>"inheritable_edit_access_person_tsim"},
17
+ :owner => "inheritable_depositor_tsim",
18
+ :embargo_release_date => "inheritable_embargo_release_date_dtsi"
19
19
  }
20
20
  }})
21
21
  end
@@ -10,10 +10,6 @@ describe Hydra::AccessControlsEnforcement do
10
10
  @current_ability ||= Ability.new(current_user)
11
11
  end
12
12
 
13
- def user_key
14
- current_user.user_key
15
- end
16
-
17
13
  def session
18
14
  end
19
15
  end
@@ -32,7 +28,7 @@ describe Hydra::AccessControlsEnforcement do
32
28
  end
33
29
  it "Then I should be treated as a member of the 'public' group" do
34
30
  ["discover","edit","read"].each do |type|
35
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:public/)
31
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:public/)
36
32
  end
37
33
  end
38
34
  it "Then I should not be treated as a member of the 'registered' group" do
@@ -52,19 +48,19 @@ describe Hydra::AccessControlsEnforcement do
52
48
  end
53
49
  it "Then I should be treated as a member of the 'public' and 'registered' groups" do
54
50
  ["discover","edit","read"].each do |type|
55
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:public/)
56
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:registered/)
51
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:public/)
52
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:registered/)
57
53
  end
58
54
  end
59
55
  it "Then I should see assets that I have discover, read, or edit access to" do
60
56
  ["discover","edit","read"].each do |type|
61
- @solr_parameters[:fq].first.should match(/#{type}_access_person_t\:#{@user.user_key}/)
57
+ @solr_parameters[:fq].first.should match(/#{type}_access_person_tsim\:#{@user.user_key}/)
62
58
  end
63
59
  end
64
60
  it "Then I should see assets that my groups have discover, read, or edit access to" do
65
61
  ["faculty", "africana-faculty"].each do |group_id|
66
62
  ["discover","edit","read"].each do |type|
67
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:#{group_id}/)
63
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:#{group_id}/)
68
64
  end
69
65
  end
70
66
  end
@@ -94,7 +90,7 @@ describe Hydra::AccessControlsEnforcement do
94
90
  subject.stub(:current_user).and_return(user)
95
91
  subject.should_receive(:can?).with(:edit, nil).and_return(true)
96
92
  subject.stub(:can?).with(:read, nil).and_return(true)
97
- subject.instance_variable_set :@permissions_solr_document, SolrDocument.new({"edit_access_person_t"=>["testuser@example.com"], "embargo_release_date_dt"=>(Date.parse(Time.now.to_s)+2).to_s})
93
+ subject.instance_variable_set :@permissions_solr_document, SolrDocument.new({"edit_access_person_tsim"=>["testuser@example.com"], "embargo_release_date_dtsi"=>(Date.parse(Time.now.to_s)+2).to_s})
98
94
 
99
95
  subject.params = {}
100
96
  subject.should_receive(:load_permissions_from_solr) #This is what normally sets @permissions_solr_document
@@ -107,7 +103,7 @@ describe Hydra::AccessControlsEnforcement do
107
103
  subject.should_receive(:can?).with(:edit, nil).and_return(false)
108
104
  subject.stub(:can?).with(:read, nil).and_return(true)
109
105
  subject.params = {}
110
- subject.instance_variable_set :@permissions_solr_document, SolrDocument.new({"edit_access_person_t"=>["testuser@example.com"], "embargo_release_date_dt"=>(Date.parse(Time.now.to_s)+2).to_s})
106
+ subject.instance_variable_set :@permissions_solr_document, SolrDocument.new({"edit_access_person_tsim"=>["testuser@example.com"], "embargo_release_date_dtsi"=>(Date.parse(Time.now.to_s)+2).to_s})
111
107
  subject.should_receive(:load_permissions_from_solr) #This is what normally sets @permissions_solr_document
112
108
  lambda {subject.send(:enforce_show_permissions, {})}.should raise_error Hydra::AccessDenied, "This item is under embargo. You do not have sufficient access privileges to read this document."
113
109
  end
@@ -123,14 +119,14 @@ describe Hydra::AccessControlsEnforcement do
123
119
  it "should set query fields for the user id checking against the discover, access, read fields" do
124
120
  subject.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
125
121
  ["discover","edit","read"].each do |type|
126
- @solr_parameters[:fq].first.should match(/#{type}_access_person_t\:#{@stub_user.user_key}/)
122
+ @solr_parameters[:fq].first.should match(/#{type}_access_person_tsim\:#{@stub_user.user_key}/)
127
123
  end
128
124
  end
129
125
  it "should set query fields for all roles the user is a member of checking against the discover, access, read fields" do
130
126
  subject.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
131
127
  ["discover","edit","read"].each do |type|
132
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:archivist/)
133
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:researcher/)
128
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:archivist/)
129
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:researcher/)
134
130
  end
135
131
  end
136
132
 
@@ -138,8 +134,8 @@ describe Hydra::AccessControlsEnforcement do
138
134
  RoleMapper.stub(:roles).with(@stub_user.user_key).and_return(["abc/123","cde/567"])
139
135
  subject.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
140
136
  ["discover","edit","read"].each do |type|
141
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:abc\\\/123/)
142
- @solr_parameters[:fq].first.should match(/#{type}_access_group_t\:cde\\\/567/)
137
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:abc\\\/123/)
138
+ @solr_parameters[:fq].first.should match(/#{type}_access_group_tsim\:cde\\\/567/)
143
139
  end
144
140
  end
145
141
  end
@@ -153,7 +149,7 @@ describe Hydra::AccessControlsEnforcement do
153
149
  end
154
150
  it "should set solr query parameters to filter out FileAssets" do
155
151
  subject.send(:exclude_unwanted_models, @solr_parameters, @user_parameters)
156
- @solr_parameters[:fq].should include("-has_model_s:\"info:fedora/afmodel:FileAsset\"")
152
+ @solr_parameters[:fq].should include("-#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:\"info:fedora/afmodel:FileAsset\"")
157
153
  end
158
154
  end
159
155
 
@@ -3,18 +3,18 @@ require 'spec_helper'
3
3
  describe Hydra::AdminPolicy do
4
4
  before do
5
5
  Hydra.stub(:config).and_return({:permissions=>{
6
- :discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
7
- :read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
8
- :edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
9
- :owner => "depositor_t",
10
- :embargo_release_date => "embargo_release_date_dt",
6
+ :discover => {:group =>"discover_access_group_tsim", :individual=>"discover_access_person_tsim"},
7
+ :read => {:group =>"read_access_group_tsim", :individual=>"read_access_person_tsim"},
8
+ :edit => {:group =>"edit_access_group_tsim", :individual=>"edit_access_person_tsim"},
9
+ :owner => "depositor_tsim",
10
+ :embargo_release_date => "embargo_release_date_dtsi",
11
11
 
12
12
  :inheritable => {
13
- :discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
14
- :read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
15
- :edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
16
- :owner => "inheritable_depositor_t",
17
- :embargo_release_date => "inheritable_embargo_release_date_dt"
13
+ :discover => {:group =>"inheritable_discover_access_group_tsim", :individual=>"inheritable_discover_access_person_tsim"},
14
+ :read => {:group =>"inheritable_read_access_group_tsim", :individual=>"inheritable_read_access_person_tsim"},
15
+ :edit => {:group =>"inheritable_edit_access_group_tsim", :individual=>"inheritable_edit_access_person_tsim"},
16
+ :owner => "inheritable_depositor_tsim",
17
+ :embargo_release_date => "inheritable_embargo_release_date_dtsi"
18
18
  }
19
19
  }})
20
20
  end
@@ -40,11 +40,8 @@ describe Hydra::AdminPolicy do
40
40
 
41
41
  describe "to_solr" do
42
42
  subject { Hydra::AdminPolicy.new(:title=>"Foobar").to_solr }
43
- it "should have title_t" do
44
- subject["title_t"].should == ['Foobar']
45
- end
46
- it "should have title_display" do
47
- subject["title_display"].should == 'Foobar'
43
+ it "should have title_tsim" do
44
+ subject[ActiveFedora::SolrService.solr_name('title', type: :string)].should == ["Foobar"]
48
45
  end
49
46
  end
50
47
 
@@ -153,10 +153,10 @@ describe Hydra::Datastream::RightsMetadata do
153
153
  @sample.update_values(params)
154
154
  solr_doc = @sample.to_solr
155
155
 
156
- solr_doc["edit_access_person_t"].should == ["Lil Kim"]
157
- solr_doc["edit_access_group_t"].sort.should == ["group1", "group2"]
158
- solr_doc["discover_access_person_t"].should == ["Joe Schmoe"]
159
- solr_doc["discover_access_group_t"].should == ["public"]
156
+ solr_doc["edit_access_person_tsim"].should == ["Lil Kim"]
157
+ solr_doc["edit_access_group_tsim"].sort.should == ["group1", "group2"]
158
+ solr_doc["discover_access_person_tsim"].should == ["Joe Schmoe"]
159
+ solr_doc["discover_access_group_tsim"].should == ["public"]
160
160
  end
161
161
  it "should solrize fixture content correctly" do
162
162
  lsample = Hydra::Datastream::RightsMetadata.new(nil, nil)
@@ -164,10 +164,10 @@ describe Hydra::Datastream::RightsMetadata do
164
164
  'group' => {'archivist' => 'edit', 'public' =>'read', 'bob'=>'discover'}})
165
165
 
166
166
  solr_doc = lsample.to_solr
167
- solr_doc["edit_access_person_t"].should == ["researcher1"]
168
- solr_doc["edit_access_group_t"].should == ["archivist"]
169
- solr_doc["read_access_group_t"].should == ["public"]
170
- solr_doc["discover_access_group_t"].should == ["bob"]
167
+ solr_doc["edit_access_person_tsim"].should == ["researcher1"]
168
+ solr_doc["edit_access_group_tsim"].should == ["archivist"]
169
+ solr_doc["read_access_group_tsim"].should == ["public"]
170
+ solr_doc["discover_access_group_tsim"].should == ["bob"]
171
171
  end
172
172
  end
173
173
  describe "embargo_release_date=" do
@@ -4,18 +4,18 @@ require "nokogiri"
4
4
  describe Hydra::Datastream::InheritableRightsMetadata do
5
5
  before do
6
6
  Hydra.stub(:config).and_return({:permissions=>{
7
- :discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
8
- :read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
9
- :edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
10
- :owner => "depositor_t",
11
- :embargo_release_date => "embargo_release_date_dt",
7
+ :discover => {:group =>"discover_access_group_tsim", :individual=>"discover_access_person_tsim"},
8
+ :read => {:group =>"read_access_group_tsim", :individual=>"read_access_person_tsim"},
9
+ :edit => {:group =>"edit_access_group_tsim", :individual=>"edit_access_person_tsim"},
10
+ :owner => "depositor_tsim",
11
+ :embargo_release_date => "embargo_release_date_dtsi",
12
12
 
13
13
  :inheritable => {
14
- :discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
15
- :read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
16
- :edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
17
- :owner => "inheritable_depositor_t",
18
- :embargo_release_date => "inheritable_embargo_release_date_dt"
14
+ :discover => {:group =>"inheritable_discover_access_group_tsim", :individual=>"inheritable_discover_access_person_tsim"},
15
+ :read => {:group =>"inheritable_read_access_group_tsim", :individual=>"inheritable_read_access_person_tsim"},
16
+ :edit => {:group =>"inheritable_edit_access_group_tsim", :individual=>"inheritable_edit_access_person_tsim"},
17
+ :owner => "inheritable_depositor_tsim",
18
+ :embargo_release_date => "inheritable_embargo_release_date_dtsi"
19
19
  }
20
20
  }})
21
21
  end
@@ -4,18 +4,18 @@ describe Hydra::PolicyAwareAbility do
4
4
  before do
5
5
  Hydra.stub(:config).and_return({
6
6
  :permissions=>{
7
- :discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
8
- :read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
9
- :edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
10
- :owner => "depositor_t",
11
- :embargo_release_date => "embargo_release_date_dt",
7
+ :discover => {:group =>"discover_access_group_tsim", :individual=>"discover_access_person_tsim"},
8
+ :read => {:group =>"read_access_group_tsim", :individual=>"read_access_person_tsim"},
9
+ :edit => {:group =>"edit_access_group_tsim", :individual=>"edit_access_person_tsim"},
10
+ :owner => "depositor_tsim",
11
+ :embargo_release_date => "embargo_release_date_dtsi",
12
12
 
13
13
  :inheritable => {
14
- :discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
15
- :read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
16
- :edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
17
- :owner => "inheritable_depositor_t",
18
- :embargo_release_date => "inheritable_embargo_release_date_dt"
14
+ :discover => {:group =>"inheritable_discover_access_group_tsim", :individual=>"inheritable_discover_access_person_tsim"},
15
+ :read => {:group =>"inheritable_read_access_group_tsim", :individual=>"inheritable_read_access_person_tsim"},
16
+ :edit => {:group =>"inheritable_edit_access_group_tsim", :individual=>"inheritable_edit_access_person_tsim"},
17
+ :owner => "inheritable_depositor_tsim",
18
+ :embargo_release_date => "inheritable_embargo_release_date_dtsi"
19
19
  }
20
20
  }})
21
21
  end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe Hydra::PolicyAwareAccessControlsEnforcement do
4
4
  before(:all) do
5
- class MockController
5
+ class PolicyMockController
6
6
  include Hydra::AccessControlsEnforcement
7
7
  include Hydra::PolicyAwareAccessControlsEnforcement
8
8
  attr_accessor :params
9
9
 
10
- def user_key
11
- current_user.user_key
10
+ def current_ability
11
+ @current_ability ||= Ability.new(current_user)
12
12
  end
13
13
 
14
14
  def session
@@ -64,7 +64,7 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
64
64
  @sample_policies.each {|p| p.delete }
65
65
  end
66
66
 
67
- subject { MockController.new }
67
+ subject { PolicyMockController.new }
68
68
 
69
69
  before do
70
70
  @solr_parameters = {}
@@ -96,12 +96,12 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
96
96
  policy_pids = (1..6).map {|n| "test:policy#{n}"}
97
97
  subject.should_receive(:policies_with_access).and_return(policy_pids)
98
98
  subject.apply_gated_discovery(@solr_parameters, @user_parameters)
99
- @solr_parameters[:fq].first.should include(" OR (is_governed_by_s:info\\:fedora/test\\:policy1 OR is_governed_by_s:info\\:fedora/test\\:policy2 OR is_governed_by_s:info\\:fedora/test\\:policy3 OR is_governed_by_s:info\\:fedora/test\\:policy4 OR is_governed_by_s:info\\:fedora/test\\:policy5 OR is_governed_by_s:info\\:fedora/test\\:policy6)")
99
+ @solr_parameters[:fq].first.should include(" OR (#{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy1 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy2 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy3 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy4 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy5 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy6)")
100
100
  end
101
101
  it "should not change anything if there are no clauses to add" do
102
102
  subject.stub(:policy_clauses).and_return(nil)
103
103
  subject.apply_gated_discovery(@solr_parameters, @user_parameters)
104
- @solr_parameters[:fq].first.should_not include(" OR (is_governed_by_s:info\\:fedora/test\\:policy1 OR is_governed_by_s:info\\:fedora/test\\:policy2 OR is_governed_by_s:info\\:fedora/test\\:policy3 OR is_governed_by_s:info\\:fedora/test\\:policy4 OR is_governed_by_s:info\\:fedora/test\\:policy5 OR is_governed_by_s:info\\:fedora/test\\:policy6)")
104
+ @solr_parameters[:fq].first.should_not include(" OR (#{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy1 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy2 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy3 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy4 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy5 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora/test\\:policy6)")
105
105
  end
106
106
  end
107
107
  end
@@ -61,11 +61,11 @@ describe Hydra::ModelMixins::RightsMetadata do
61
61
  result = subject.rightsMetadata.to_solr
62
62
  result.size.should == 4
63
63
  ## Wrote the test in this way, because the implementation uses a hash, and the hash order is not deterministic (especially in ruby 1.8.7)
64
- result['read_access_group_t'].size.should == 2
65
- result['read_access_group_t'].should include('group-6', 'group-7')
66
- result['edit_access_group_t'].should == ['group-8']
67
- result['discover_access_person_t'].should == ['person2']
68
- result['read_access_person_t'].should == ['person1']
64
+ result['read_access_group_tsim'].size.should == 2
65
+ result['read_access_group_tsim'].should include('group-6', 'group-7')
66
+ result['edit_access_group_tsim'].should == ['group-8']
67
+ result['discover_access_person_tsim'].should == ['person2']
68
+ result['read_access_person_tsim'].should == ['person1']
69
69
  end
70
70
  end
71
71
 
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.0.0.pre1
4
+ version: 6.0.0.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -34,17 +34,17 @@ dependencies:
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  none: false
36
36
  requirements:
37
- - - ! '>='
37
+ - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: 6.0.0.pre2
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
- - - ! '>='
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 6.0.0.pre2
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: cancan
50
50
  requirement: !ruby/object:Gem::Requirement