Permalink
Browse files

VOV-1138 (NU Test) When I add someone to the archivist group - they d…

…isappear after a minute or so.
  • Loading branch information...
1 parent 0f8efe4 commit 2a9cadb0dada1d18b4a50ba130d454388e5bc622 @mbklein mbklein committed Feb 11, 2013
Showing with 19 additions and 9 deletions.
  1. +1 −1 app/controllers/admin/groups_controller.rb
  2. +6 −0 app/models/role_map.rb
  3. +1 −1 felix
  4. +6 −6 lib/role_controls.rb
  5. +1 −1 red5
  6. +4 −0 spec/models/role_map_spec.rb
@@ -56,7 +56,7 @@ def update
@group = Admin::Group.find(params["id"])
@group.name = new_group_name unless new_group_name.blank?
- @group.users << new_user unless new_user.blank?
+ @group.users += [new_user] unless new_user.blank?
if @group.save
flash[:notice] = "Successfully updated group \"#{@group.name}\""
View
@@ -39,4 +39,10 @@ def map
RoleMap.reset! if RoleMap.count == 0
RoleMap.load
end
+
+ def update
+ m = map
+ yield m
+ RoleMap.replace_with! m
+ end
end
2 felix
Submodule felix updated from 819f0a to bf7430
View
@@ -29,12 +29,12 @@ def role_exists? role
end
def assign_users(new_users, role)
- RoleMapper.map[role] = new_users.reject { |u| u.blank? }
+ RoleMapper.update { |map| map[role] = new_users.reject { |u| u.blank? } }
end
def add_role(role)
if RoleMapper.map[role].nil?
- RoleMapper.map[role] = []
+ RoleMapper.update { |map| map[role] = [] }
else
raise RoleExists, "Cannot add role \"#{role}\", it already exists"
end
@@ -44,7 +44,7 @@ def remove_role(role)
if RoleMapper.map[role].nil?
raise RoleNotExist, "Cannot remove role \"#{role}\", it does not exist"
else
- RoleMapper.map.delete(role)
+ RoleMapper.update { |map| map.delete(role) }
end
end
@@ -54,7 +54,7 @@ def remove_user_role(user, role)
elsif !RoleMapper.map[role].include? user
raise UserRoleExists, "Cannot remove user-role \"#{user}\" - \"#{role}\", relationship does not exist"
else
- RoleMapper.map[role].delete(user)
+ RoleMapper.update { |map| map[role].delete(user) }
end
end
@@ -64,12 +64,12 @@ def add_user_role(user, role)
elsif RoleMapper.map[role].include? user
raise UserRoleExists, "Cannot add user \"#{user}\" to role \"#{role}\", relationship already exists"
else
- RoleMapper.map[role] << user
+ RoleMapper.update { |map| map[role] << user }
end
end
def save_changes
- RoleMap.replace_with! RoleMapper.map
+ # noop!
end
end
end
2 red5
Submodule red5 updated from 9d332d to d75454
@@ -10,6 +10,10 @@
RoleMap.all.each &:destroy
end
+ after :all do
+ RoleMap.reset!
+ end
+
it "should properly initialize the map" do
RoleMapper.map.should == YAML.load(File.read(File.join(Rails.root, "config/role_map_#{Rails.env}.yml")))
end

0 comments on commit 2a9cadb

Please sign in to comment.