kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.1 KiB
65 lines
2.1 KiB
14 years ago
|
Given /^there is the global permission "(.+)?" of the module "(.+)?"$/ do |perm_name, perm_module|
|
||
|
Redmine::AccessControl.map do |map|
|
||
|
map.project_module perm_module.to_sym do |mod|
|
||
|
mod.permission perm_name.to_sym, {:dont => :care}, {:project_module => perm_module.to_sym, :global => true}
|
||
|
end
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
14 years ago
|
Given /^the global permission "(.+)?" of the module "(.+)?" is defined$/ do |perm_name, perm_module|
|
||
14 years ago
|
as_admin do
|
||
|
permissions = Redmine::AccessControl.modules_permissions(perm_module)
|
||
|
permissions.detect{|p| p.name == perm_name.to_sym && p.global?}.should_not be_nil
|
||
|
end
|
||
14 years ago
|
end
|
||
|
|
||
|
Given /^there is a global [rR]ole "([^\"]*)"$/ do |name|
|
||
|
GlobalRole.spawn.tap { |r| r.name = name }.save! unless GlobalRole.find_by_name(name)
|
||
|
end
|
||
|
|
||
|
Given /^the global [rR]ole "([^\"]*)" may have the following [rR]ights:$/ do |role, table|
|
||
|
r = GlobalRole.find_by_name(role)
|
||
|
raise "No such role was defined: #{role}" unless r
|
||
|
as_admin do
|
||
|
available_perms = Redmine::AccessControl.permissions.collect(&:name)
|
||
|
r.permissions = []
|
||
|
|
||
|
table.raw.each do |_perm|
|
||
|
perm = _perm.first
|
||
|
unless perm.blank?
|
||
|
perm = perm.gsub(" ", "_").underscore.to_sym
|
||
|
if available_perms.include?(:"#{perm}")
|
||
|
r.permissions << perm
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
r.save!
|
||
|
end
|
||
|
end
|
||
|
|
||
14 years ago
|
Given /^the [Uu]ser (.+) (?:is a|has the global role) (.+)$/ do |user, role|
|
||
|
u = User.find_by_login(user.gsub("\"", ""))
|
||
|
r = GlobalRole.find_by_name(role.gsub("\"", ""))
|
||
|
as_admin do
|
||
|
r.principals << u
|
||
|
end
|
||
|
end
|
||
|
|
||
14 years ago
|
When /^I select the available role (.+)$/ do |role|
|
||
|
r = GlobalRole.find_by_name(role.gsub("\"", ""))
|
||
|
raise "No such role was defined: #{role}" unless r
|
||
|
steps %Q{
|
||
|
When I check "principal_role_role_ids_#{r.id}"
|
||
|
}
|
||
14 years ago
|
end
|
||
|
|
||
|
When /^I delete the assigned role (.+)$/ do |role|
|
||
|
g = GlobalRole.find_by_name(role.gsub("\"", ""))
|
||
|
raise "No such role was defined: #{role}" unless g
|
||
|
raise "More than one or no principal has this role" if g.principal_roles.length != 1
|
||
|
|
||
|
steps %Q{
|
||
|
When I follow "Delete" within "#principal_role_#{g.principal_roles[0].id}"
|
||
|
}
|
||
14 years ago
|
end
|