]> source.dussan.org Git - redmine.git/commitdiff
Adding a principal to 2 projects with member inheritance leads to an error (#25289).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 8 Mar 2017 20:35:11 +0000 (20:35 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 8 Mar 2017 20:35:11 +0000 (20:35 +0000)
Patch by Felix Schäfer.

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

app/models/member.rb

index 06b90bf5506b3c75a27aadb5483b6dd36e55bbdb..b19f78c6b98a146cc12db740d8563d28a8c79c95 100644 (file)
@@ -184,9 +184,11 @@ class Member < ActiveRecord::Base
       project_ids = Array.wrap(attributes[:project_ids] || attributes[:project_id])
       role_ids = attributes[:role_ids]
       project_ids.each do |project_id|
-        members << Member.new(:principal => principal, :role_ids => role_ids, :project_id => project_id)
+        member = Member.find_or_new(project_id, principal)
+        member.role_ids |= role_ids
+        member.save
+        members << member
       end
-      principal.members << members
     end
     members
   end