]> source.dussan.org Git - redmine.git/commitdiff
Merged r13334 (#17486).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Sep 2014 10:08:42 +0000 (10:08 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Sep 2014 10:08:42 +0000 (10:08 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13389 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/member.rb
test/unit/member_test.rb

index 6ec22d4223a994b290668dd7ab8b1a22f2d9200d..85562dbd75203732e23d1516001f4c64b89492ea 100644 (file)
@@ -94,9 +94,9 @@ class Member < ActiveRecord::Base
   end
 
   def set_issue_category_nil
-    if user
+    if user_id && project_id
       # remove category based auto assignments for this member
-      IssueCategory.where(["project_id = ? AND assigned_to_id = ?", project.id, user.id]).
+      IssueCategory.where(["project_id = ? AND assigned_to_id = ?", project_id, user_id]).
         update_all("assigned_to_id = NULL")
     end
   end
index 6ba9717c464aba9a4acdca0923f9b3e7113f1f48..124aa37197b058440428cd948754891f3d2b36ef 100644 (file)
@@ -94,6 +94,16 @@ class MemberTest < ActiveSupport::TestCase
     assert !member.save
   end
 
+  def test_set_issue_category_nil_should_handle_nil_values
+    m = Member.new
+    assert_nil m.user
+    assert_nil m.project
+
+    assert_nothing_raised do
+      m.set_issue_category_nil
+    end
+  end
+
   def test_destroy
     category1 = IssueCategory.find(1)
     assert_equal @jsmith.user.id, category1.assigned_to_id