Class: Gitlab::SlashCommands::IssueClose

Inherits:
IssueCommand show all
Defined in:
lib/gitlab/slash_commands/issue_close.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::QUERY_LIMIT

Instance Attribute Summary

Attributes inherited from BaseCommand

#chat_name, #current_user, #params, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IssueCommand

available?, #collection

Methods inherited from BaseCommand

available?, can?, #collection, #initialize

Constructor Details

This class inherits a constructor from Gitlab::SlashCommands::BaseCommand

Class Method Details

.allowed?(project, user) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/gitlab/slash_commands/issue_close.rb', line 14

def self.allowed?(project, user)
  can?(user, :update_issue, project)
end

.help_messageObject



10
11
12
# File 'lib/gitlab/slash_commands/issue_close.rb', line 10

def self.help_message
  "issue close <id>"
end

.match(text) ⇒ Object



6
7
8
# File 'lib/gitlab/slash_commands/issue_close.rb', line 6

def self.match(text)
  /\Aissue\s+close\s+#{Issue.reference_prefix}?(?<iid>\d+)/.match(text)
end

Instance Method Details

#execute(match) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/slash_commands/issue_close.rb', line 18

def execute(match)
  issue = find_by_iid(match[:iid])

  return not_found unless issue
  return presenter(issue).already_closed if issue.closed?

  close_issue(issue: issue)

  presenter(issue).present
end