1 class IssueCommentsController < ApplicationController
 
   4   before_action :authorize_web
 
   5   before_action :set_locale
 
   6   before_action :check_database_readable
 
  10   before_action :check_database_writable, :only => [:create]
 
  13     @issue = Issue.find(params[:issue_id])
 
  14     comment = @issue.comments.build(issue_comment_params)
 
  15     comment.user = current_user
 
  19       reassign_issue(@issue)
 
  20       flash[:notice] = t ".issue_reassigned"
 
  22       if current_user.role? @issue.assigned_role
 
  25         redirect_to issues_path(:status => "open")
 
  28       flash[:notice] = t(".comment_created")
 
  35   def issue_comment_params
 
  36     params.expect(:issue_comment => [:body])
 
  39   # This sort of assumes there are only two roles
 
  40   def reassign_issue(issue)
 
  41     role = (Issue::ASSIGNED_ROLES - [issue.assigned_role]).first
 
  42     issue.assigned_role = role