summaryrefslogtreecommitdiffstats
path: root/test/unit/member_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-12 14:54:30 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-12 14:54:30 +0000
commitd289619c757b52849002e0a78ecc4b45065cb8af (patch)
treea7895d1f3106437a17d492adadc34c4fdd224b79 /test/unit/member_test.rb
parent10a462369b4c59891d60da69876c2d290feb7d58 (diff)
downloadredmine-d289619c757b52849002e0a78ecc4b45065cb8af.tar.gz
redmine-d289619c757b52849002e0a78ecc4b45065cb8af.zip
Fixed potential error when sorting members without role (#10053).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8863 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/member_test.rb')
-rw-r--r--test/unit/member_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/member_test.rb b/test/unit/member_test.rb
index 783ec90b9..5fb8b30ac 100644
--- a/test/unit/member_test.rb
+++ b/test/unit/member_test.rb
@@ -106,6 +106,23 @@ class MemberTest < ActiveSupport::TestCase
assert_nil category1.assigned_to_id
end
+ def test_sort_without_roles
+ a = Member.new(:roles => [Role.first])
+ b = Member.new
+
+ assert_equal -1, a <=> b
+ assert_equal 1, b <=> a
+ end
+
+ def test_sort_without_principal
+ role = Role.first
+ a = Member.new(:roles => [role], :principal => User.first)
+ b = Member.new(:roles => [role])
+
+ assert_equal -1, a <=> b
+ assert_equal 1, b <=> a
+ end
+
context "removing permissions" do
setup do
Watcher.delete_all("user_id = 9")