]> source.dussan.org Git - redmine.git/commitdiff
Fixed that Project.uniq.visible errors under certain conditions (#21182).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 9 Nov 2015 18:01:04 +0000 (18:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 9 Nov 2015 18:01:04 +0000 (18:01 +0000)
Patch by Redmine CRM.

git-svn-id: http://svn.redmine.org/redmine/trunk@14857 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/principal.rb
test/unit/project_test.rb

index c7addd9dffa885cf1ed10288b7c113f5a9387da0..f3c8835329146c3406205ec406bf3cf89e520dea 100644 (file)
@@ -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
index ffb514aa3a0b7d3f27ff5fe9b47315cdd0a02140..b6b578a9e50f1a38860e83d98e01d82bd9579c4b 100644 (file)
@@ -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