Class: YouTrack::Client::CreateIssue

Inherits:
Request
  • Object
show all
Defined in:
lib/you_track/client/requests/create_issue.rb

Instance Method Summary collapse

Methods inherited from Request

#find, #require_parameters

Instance Method Details

#mock(_params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/you_track/client/requests/create_issue.rb', line 10

def mock(_params)
  params = Cistern::Hash.stringify_keys(_params)

  issue = Cistern::Hash.slice(params, "project", "description", "summary")

  project = issue["projectShortName"] = issue.delete("project")

  index = service.data[:issues].size + 1
  project_index = service.data[:issues].values.select { |i| i["projectShortName"] == project }.size

  identity = "#{project}-#{index}"

  issue.merge!(
    "id"               => identity,
    "tag"              => "",
    "numberInProject"  => project_index,
    "created"          => Time.now.to_i * 1000,
    "updated"          => Time.now.to_i * 1000,
    "updaterName"      => service.username,
    "updaterFullName"  => service.username.capitalize,
    "reporterName"     => service.username,
    "reporterFullName" => service.username.capitalize,
    "commentsCount"    => "0",
    "votes"            => "0",
    "custom_fields"    => [
      ["State", "Open"],
    ], # @fixme need these
    "attachments"      => [],
  )

  service.data[:issues][identity] = issue

  service.response(
    :response_headers => {
      "Location" => service.url_for("/issue/#{identity}"),
    },
    :status => 201,
  )
end

#real(params) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/you_track/client/requests/create_issue.rb', line 2

def real(params)
  service.request(
    :path   => "/issue",
    :method => :put,
    :params => params,
  )
end