Sha256: fd384f0c7583385c4d9d8e6fcc23d16e95b277b1668709256193ca9c84dd76ba

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

class YouTrack::Client::ApplyIssueCommand < YouTrack::Client::Request
  def real(params={})
    id = params.delete("id")

    service.request(
      :path   => "/issue/#{id}/execute",
      :query  => params,
      :method => :post,
    )
  end

  def mock(params={})
    id         = params.delete("id")
    issue      = find(:issues, id)
    comment_id = "#{Cistern::Mock.random_numbers(2)}-#{Cistern::Mock.random_numbers(5)}"

    if params["comment"]
      comment = {
        "id"             => comment_id,
        "author"         => service.username,
        "deleted"        => false,
        "text"           => params["comment"],
        "shownForIssuer" => false,
        "created"        => Time.now.to_i * 1000,
        "issueId"        => id,
      }
      service.data[:comments][comment_id] = comment
    end

    if params["command"]
      commands = params["command"].split.each_slice(2).map { |a| [a[0], a[1]] }
      commands.each do |command|
        issue["custom_fields"].detect { |f| f[0] == command[0] }[1] = command[1]
      end
    end

    service.response
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
you_track-0.4.4 lib/you_track/client/requests/apply_issue_command.rb
you_track-0.4.2 lib/you_track/client/requests/apply_issue_command.rb
you_track-0.4.1 lib/you_track/client/requests/apply_issue_command.rb
you_track-0.4.0 lib/you_track/client/requests/apply_issue_command.rb
you_track-0.3.0 lib/you_track/client/requests/apply_issue_command.rb
you_track-0.2.2 lib/you_track/client/apply_issue_command.rb
you_track-0.2.1 lib/you_track/client/apply_issue_command.rb
you_track-0.2.0 lib/you_track/client/apply_issue_command.rb