# HG changeset patch # User luisf # Date 1291821242 0 # Node ID 7c828d63cb0684999af663b50a96efbc19a788dd # Parent 35c1d1c098e6f73b0ad199742a263e882c84ff00 Feature #31: the assigned user is made a watcher of the issue. diff -r 35c1d1c098e6 -r 7c828d63cb06 app/controllers/issues_controller.rb --- a/app/controllers/issues_controller.rb Tue Dec 07 17:42:09 2010 +0000 +++ b/app/controllers/issues_controller.rb Wed Dec 08 15:14:02 2010 +0000 @@ -138,6 +138,13 @@ # Adds user to watcher's list @issue.add_watcher(User.current) + # Also adds the assignee to the watcher's list + if params[:issue][:assigned_to_id] && !params[:issue][:assigned_to_id].empty?: + unless @issue.watcher_ids.include?(params[:issue][:assigned_to_id]): + @issue.add_watcher(User.find(params[:issue][:assigned_to_id])) + end + end + respond_to do |format| format.html { redirect_to(params[:continue] ? { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } : @@ -279,6 +286,18 @@ @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) @issue.init_journal(User.current, @notes) @issue.safe_attributes = params[:issue] + + # tests if the the user assigned_to_id + # is in this issues watcher's list + # if not, adds it. + + if params[:issue][:assigned_to_id] && !params[:issue][:assigned_to_id].empty?: + unless @issue.watcher_ids.include?(params[:issue][:assigned_to_id]): + @issue.add_watcher(User.find(params[:issue][:assigned_to_id])) + end + end + + end # TODO: Refactor, lots of extra code in here