1 # frozen_string_literal: true
3 class IssueCommentsController < ApplicationController
6 before_action :authorize_web
7 before_action :set_locale
8 before_action :check_database_readable
12 before_action :check_database_writable, :only => [:create]
15 @issue = Issue.find(params[:issue_id])
16 comment = @issue.comments.build(issue_comment_params)
17 comment.user = current_user
21 reassign_issue(@issue)
22 flash[:notice] = t ".issue_reassigned"
24 if current_user.role? @issue.assigned_role
27 redirect_to issues_path(:status => "open")
30 flash[:notice] = t(".comment_created")
37 def issue_comment_params
38 params.expect(:issue_comment => [:body])
41 # This sort of assumes there are only two roles
42 def reassign_issue(issue)
43 role = (Issue::ASSIGNED_ROLES - [issue.assigned_role]).first
44 issue.assigned_role = role