hydra-access-controls 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  module Hydra
2
2
  module Access
3
3
  module Controls
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
6
6
  end
7
7
  end
@@ -15,11 +15,11 @@ module Hydra::RoleMapperBehavior
15
15
  if user_or_uid.kind_of?(String)
16
16
  user = ::User.find_by_user_key(user_or_uid)
17
17
  user_id = user_or_uid
18
- elsif user_or_uid.kind_of?(::User) && !user_or_uid.uid.nil?
18
+ elsif user_or_uid.kind_of?(::User) && user_or_uid.user_key
19
19
  user = user_or_uid
20
20
  user_id = user.user_key
21
21
  end
22
- array = byname[user_id]||[]
22
+ array = byname[user_id].dup || []
23
23
  array = array << 'registered' unless (user.nil? || user.new_record?)
24
24
  array
25
25
  end
data/spec/support/user.rb CHANGED
@@ -6,6 +6,7 @@ class User
6
6
 
7
7
  def initialize(params={})
8
8
  self.email = params[:email] if params[:email]
9
+ self.uid = params[:uid] if params[:uid]
9
10
  end
10
11
 
11
12
  def new_record?
@@ -16,6 +16,13 @@ describe RoleMapper do
16
16
  RoleMapper.roles('archivist2@example.com').should == ['archivist']
17
17
  end
18
18
 
19
+ it "should not change it's response when it's called repeatedly" do
20
+ u = User.new(:uid=>'leland_himself@example.com')
21
+ u.stub(:new_record?).and_return(false)
22
+ RoleMapper.roles(u).sort.should == ['archivist', 'donor', 'patron', "registered"]
23
+ RoleMapper.roles(u).sort.should == ['archivist', 'donor', 'patron', "registered"]
24
+ end
25
+
19
26
  it "should return an empty array if there are no roles" do
20
27
  RoleMapper.roles('zeus@olympus.mt').empty?.should == true
21
28
  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: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -225,4 +225,3 @@ test_files:
225
225
  - spec/unit/policy_aware_access_controls_enforcement_spec.rb
226
226
  - spec/unit/rights_metadata_spec.rb
227
227
  - spec/unit/role_mapper_spec.rb
228
- has_rdoc: