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
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