Class: Gitlab::Triage::Action::Issue

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/triage/action/issue.rb

Direct Known Subclasses

Dry

Defined Under Namespace

Classes: Dry

Instance Attribute Summary

Attributes inherited from Base

#network, #policy

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Triage::Action::Base

Instance Method Details

#actObject



27
28
29
30
31
32
33
# File 'lib/gitlab/triage/action/issue.rb', line 27

def act
  policy.resources.each do |resource|
    issue = policy.build_issue(resource)

    perform(resource, issue) if issue.valid?
  end
end

#build_post_url(resource, issue) ⇒ Object (private)



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gitlab/triage/action/issue.rb', line 41

def build_post_url(resource, issue)
  # POST /projects/:id/issues
  # https://docs.gitlab.com/ee/api/issues.html#new-issue
  post_url = UrlBuilders::UrlBuilder.new(
    network_options: network.options,
    source_id: issue.destination || resource[policy.source_id_sym],
    resource_type: 'issues'
  ).build

  puts Gitlab::Triage::UI.debug "post_issue_url: #{post_url}" if network.options.debug

  post_url
end

#perform(resource, issue) ⇒ Object (private)



37
38
39
# File 'lib/gitlab/triage/action/issue.rb', line 37

def perform(resource, issue)
  network.post_api(build_post_url(resource, issue), post_issue_body(issue))
end

#post_issue_body(issue) ⇒ Object (private)



55
56
57
58
59
60
# File 'lib/gitlab/triage/action/issue.rb', line 55

def post_issue_body(issue)
  {
    title: issue.title,
    description: issue.description
  }
end