Sha256: 7d45bb353704f8e60a0891e0c4ffe7c99248d78f666a2a3393106b8ce5fe48fd

Contents?: true

Size: 1.66 KB

Versions: 4

Compression:

Stored size: 1.66 KB

Contents

# https://confluence.jetbrains.com/display/YTD6/PUT+Project
class YouTrack::Client::CreateProject < YouTrack::Client::Request
  def self.accepted_attributes
    # "projectId",        # string  required   Unique identifier of a project to be created. This short name will be used as prefix in issue IDs for this project.
    @_accepted_attributes ||= [
      "projectName",      # string  required   Full name of a new project. Must be unique.
      "startingNumber",   # integer required   Number to assign to the next manually created issue.
      "projectLeadLogin", # string  required   Login name of a user to be assigned as a project leader.
      "description",      # string  Optional   description of the new project.
    ]
  end

  def real(params)
    service.request(
      :path   => "/admin/project/#{params.fetch("projectId")}",
      :method => :put,
      :params => Cistern::Hash.slice(params, *self.class.accepted_attributes),
    )
  end

  def mock(params)
    identity = params.fetch("projectId")

    service.data[:projects][identity] = {
      "isImporting"    => "false",
      "lead"           => params.fetch("projectLeadLogin"), # @todo check user login
      "shortName"      => identity,
      "name"           => params.fetch("projectName"),
      "startingNumber" => params.fetch("startingNumber"),
      "sub"            => { "value" => "No subsystem" },
      "versions"       => [],
    }.merge(Cistern::Hash.slice(params, "description"))

    # @hack
    service.data[:custom_fields][identity] = [
      {"name" => "Fix versions", "url" => service.url_for("/admin/project/#{identity}/customfield/Fix versions")}
    ]

    service.response(status: 201)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
you_track-0.4.4 lib/you_track/client/requests/create_project.rb
you_track-0.4.2 lib/you_track/client/requests/create_project.rb
you_track-0.4.1 lib/you_track/client/requests/create_project.rb
you_track-0.4.0 lib/you_track/client/requests/create_project.rb