Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-21 08:30:28 +0300
committerStan Hu <stanhu@gmail.com>2018-07-21 08:30:28 +0300
commit3fd704b239cbf008f48ca3ca2e6119ca993794b7 (patch)
treeb20828d5f1b6d00d54d0fe484e120d310cc2cf26 /lib/bitbucket_server
parent7c1aaf68f82f05fd34f567be2481b8283e3328c2 (diff)
Add spec for BitBucketServer pull reuest parsing
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r--lib/bitbucket_server/representation/pull_request.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/bitbucket_server/representation/pull_request.rb b/lib/bitbucket_server/representation/pull_request.rb
index 3e460f04064..344b6806a91 100644
--- a/lib/bitbucket_server/representation/pull_request.rb
+++ b/lib/bitbucket_server/representation/pull_request.rb
@@ -2,11 +2,11 @@ module BitbucketServer
module Representation
class PullRequest < Representation::Base
def author
- raw.fetch('author', {}).fetch('user', {}).fetch('name')
+ raw.dig('author', 'user', 'name')
end
def author_email
- raw.fetch('author', {}).fetch('user', {}).fetch('emailAddress')
+ raw.dig('author', 'user', 'emailAddress')
end
def description
@@ -32,11 +32,11 @@ module BitbucketServer
end
def created_at
- raw['createdDate']
+ Time.at(created_date / 1000) if created_date.is_a?(Integer)
end
def updated_at
- raw['updatedDate']
+ Time.at(updated_date / 1000) if created_date.is_a?(Integer)
end
def title
@@ -44,29 +44,29 @@ module BitbucketServer
end
def source_branch_name
- source_branch['id']
+ dig('fromRef', 'id')
end
def source_branch_sha
- source_branch['latestCommit']
+ dig('fromRef', 'latestCommit')
end
def target_branch_name
- target_branch['id']
+ dig('toRef', 'id')
end
def target_branch_sha
- target_branch['latestCommit']
+ dig('toRef', 'latestCommit')
end
private
- def source_branch
- raw['fromRef'] || {}
+ def created_date
+ raw['createdDate']
end
- def target_branch
- raw['toRef'] || {}
+ def updated_date
+ raw['updatedDate']
end
end
end