summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/principal.rb3
-rw-r--r--test/unit/project_test.rb9
2 files changed, 10 insertions, 2 deletions
diff --git a/app/models/principal.rb b/app/models/principal.rb
index c7addd9df..f3c883532 100644
--- a/app/models/principal.rb
+++ b/app/models/principal.rb
@@ -28,8 +28,7 @@ class Principal < ActiveRecord::Base
has_many :memberships,
lambda {preload(:project, :roles).
joins(:project).
- where("#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}").
- order("#{Project.table_name}.name")},
+ where("#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}")},
:class_name => 'Member',
:foreign_key => 'user_id'
has_many :projects, :through => :memberships
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index ffb514aa3..b6b578a9e 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -991,4 +991,13 @@ class ProjectTest < ActiveSupport::TestCase
p.status = Project::STATUS_CLOSED
assert_include 'closed', p.css_classes.split
end
+
+ def test_combination_of_visible_and_uniq_scopes_in_case_anonymous_group_has_memberships_should_not_error
+ project = Project.find(1)
+ member = Member.create!(:project => project, :principal => Group.anonymous, :roles => [Role.generate!])
+ project.members << member
+ assert_nothing_raised do
+ Project.uniq.visible.to_a
+ end
+ end
end