diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-03-01 10:24:23 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-03-01 10:24:23 +0000 |
commit | 6803d95a32ab15fcb1f7b34f00ace445166fe882 (patch) | |
tree | e1b28d5d9fe2378f5ebb9b4896a7e633e26f8fed /test/unit/user_test.rb | |
parent | 69657be5348e989d5b5401c08fc473a793cdc55c (diff) | |
download | redmine-6803d95a32ab15fcb1f7b34f00ace445166fe882.tar.gz redmine-6803d95a32ab15fcb1f7b34f00ace445166fe882.zip |
Performance: avoid querying all memberships in User#roles_for_project (#13301).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11508 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/user_test.rb')
-rw-r--r-- | test/unit/user_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 9105dfda0..230e5b140 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -762,6 +762,32 @@ class UserTest < ActiveSupport::TestCase assert_equal true, User.default_admin_account_changed? end + def test_membership_with_project_should_return_membership + project = Project.find(1) + + membership = @jsmith.membership(project) + assert_kind_of Member, membership + assert_equal @jsmith, membership.user + assert_equal project, membership.project + end + + def test_membership_with_project_id_should_return_membership + project = Project.find(1) + + membership = @jsmith.membership(1) + assert_kind_of Member, membership + assert_equal @jsmith, membership.user + assert_equal project, membership.project + end + + def test_membership_for_non_member_should_return_nil + project = Project.find(1) + + user = User.generate! + membership = user.membership(1) + assert_nil membership + end + def test_roles_for_project # user with a role roles = @jsmith.roles_for_project(Project.find(1)) |