mirror of
https://github.com/redmine/redmine.git
synced 2026-05-07 23:07:26 +02:00
Do not build a projects_by_role Hash that gets updated when accessing a key that is not present (#11662).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10242 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -744,6 +744,13 @@ class UserTest < ActiveSupport::TestCase
|
||||
assert_equal [2], user.projects_by_role[Role.find(2)].collect(&:id).sort
|
||||
end
|
||||
|
||||
def test_accessing_projects_by_role_with_no_projects_should_return_an_empty_array
|
||||
user = User.find(2)
|
||||
assert_equal [], user.projects_by_role[Role.find(3)]
|
||||
# should not update the hash
|
||||
assert_nil user.projects_by_role.values.detect(&:blank?)
|
||||
end
|
||||
|
||||
def test_projects_by_role_for_user_with_no_role
|
||||
user = User.generate!
|
||||
assert_equal({}, user.projects_by_role)
|
||||
|
||||
Reference in New Issue
Block a user