Sha256: 4b8160ee5c00281aad90a2b48322ba56f5e7d5f7664d9403f065c7766afddccf

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

class YouTrack::Client::CreateIssue < YouTrack::Client::Request
  def real(params)
    service.request(
      :path   => "/issue",
      :method => :put,
      :params => params,
      :parser => YouTrack::Parser::IssueParser,
    )
  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(
      :body   => issue,
      :status => 201,
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
you_track-0.2.2 lib/you_track/client/create_issue.rb
you_track-0.2.1 lib/you_track/client/create_issue.rb
you_track-0.2.0 lib/you_track/client/create_issue.rb