Sha256: 44ecf3d30888da5e95bd6356d666309e357720b963fb6e42f4014ce6d41e23fc

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

class YouTrack::Client::CreateIssue < YouTrack::Client::Request
  def real(params)
    service.request(
      :path   => "/issue",
      :method => :put,
      :params => params,
    )
  end

  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(
      :status => 201,
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
you_track-0.3.0 lib/you_track/client/requests/create_issue.rb