Role#copy_from should copy managed roles.

git-svn-id: http://svn.redmine.org/redmine/trunk@15913 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2016-10-20 17:00:04 +00:00
parent a2b17dae6e
commit d8df8c8bcb
3 changed files with 9 additions and 1 deletions

View File

@@ -109,6 +109,7 @@ class Role < ActiveRecord::Base
role = arg.is_a?(Role) ? arg : Role.find_by_id(arg.to_s)
self.attributes = role.attributes.dup.except("id", "name", "position", "builtin", "permissions")
self.permissions = role.permissions.dup
self.managed_role_ids = role.managed_role_ids.dup
self
end

View File

@@ -129,7 +129,7 @@ class RolesControllerTest < Redmine::ControllerTest
assert_response 302
end
assert_equal false, role.all_roles_managed
assert_equal [2, 3], role.managed_role_ids
assert_equal [2, 3], role.managed_role_ids.sort
end
def test_edit

View File

@@ -45,6 +45,13 @@ class RoleTest < ActiveSupport::TestCase
assert copy.save
end
def test_copy_from_should_copy_managed_roles
orig = Role.generate!(:all_roles_managed => false, :managed_role_ids => [2, 3])
role = Role.new
role.copy_from orig
assert_equal [2, 3], role.managed_role_ids.sort
end
def test_copy_workflows
source = Role.find(1)
rule_count = source.workflow_rules.count