diff options
author | Stan Hu <stanhu@gmail.com> | 2018-07-25 15:38:45 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-25 15:39:39 -0700 |
commit | bf2d029a3d7a347cafbca4e2d5d879940d91cb90 (patch) | |
tree | 4b7c25157d3c6e09fd989f302170a7d69e2b8948 /lib/bitbucket_server | |
parent | e47cf67e80f0b18d8938f918ed373f59eeddbb14 (diff) | |
download | gitlab-ce-bf2d029a3d7a347cafbca4e2d5d879940d91cb90.tar.gz |
Add spec for pull request activity
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r-- | lib/bitbucket_server/representation/activity.rb | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/lib/bitbucket_server/representation/activity.rb b/lib/bitbucket_server/representation/activity.rb index 8c2b0be559e..fab4b426ae2 100644 --- a/lib/bitbucket_server/representation/activity.rb +++ b/lib/bitbucket_server/representation/activity.rb @@ -3,16 +3,12 @@ module BitbucketServer module Representation class Activity < Representation::Base - def action - raw['action'] - end - def comment? action == 'COMMENTED' end def inline_comment? - comment? && comment_anchor + !!(comment? && comment_anchor) end def comment @@ -26,57 +22,41 @@ module BitbucketServer end end - # XXX Move this into MergeEvent + # TODO Move this into MergeEvent def merge_event? action == 'MERGED' end def committer_user - commit.fetch('committer', {})['displayName'] + raw.dig('commit', 'committer', 'displayName') end def committer_email - commit.fetch('committer', {})['emailAddress'] + raw.dig('commit', 'committer', 'emailAddress') end def merge_timestamp - timestamp = commit.fetch('committer', {})['commiterTimestamp'] + timestamp = raw.dig('commit', 'committerTimestamp') Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer) end - def commit - raw.fetch('commit', {}) - end - def created_at Time.at(created_date / 1000) if created_date.is_a?(Integer) end - def updated_at - Time.at(updated_date / 1000) if created_date.is_a?(Integer) - end - private - def raw_comment - raw.fetch('comment', {}) + def action + raw['action'] end def comment_anchor raw['commentAnchor'] end - def author - raw_comment.fetch('author', {}) - end - def created_date - comment['createdDate'] - end - - def updated_date - comment['updatedDate'] + raw.dig('createdDate') end end end |