Commit bf2d029a authored by Stan Hu's avatar Stan Hu

Add spec for pull request activity

parent e47cf67e
...@@ -3,16 +3,12 @@ ...@@ -3,16 +3,12 @@
module BitbucketServer module BitbucketServer
module Representation module Representation
class Activity < Representation::Base class Activity < Representation::Base
def action
raw['action']
end
def comment? def comment?
action == 'COMMENTED' action == 'COMMENTED'
end end
def inline_comment? def inline_comment?
comment? && comment_anchor !!(comment? && comment_anchor)
end end
def comment def comment
...@@ -26,57 +22,41 @@ module BitbucketServer ...@@ -26,57 +22,41 @@ module BitbucketServer
end end
end end
# XXX Move this into MergeEvent # TODO Move this into MergeEvent
def merge_event? def merge_event?
action == 'MERGED' action == 'MERGED'
end end
def committer_user def committer_user
commit.fetch('committer', {})['displayName'] raw.dig('commit', 'committer', 'displayName')
end end
def committer_email def committer_email
commit.fetch('committer', {})['emailAddress'] raw.dig('commit', 'committer', 'emailAddress')
end end
def merge_timestamp def merge_timestamp
timestamp = commit.fetch('committer', {})['commiterTimestamp'] timestamp = raw.dig('commit', 'committerTimestamp')
Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer) Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer)
end end
def commit
raw.fetch('commit', {})
end
def created_at def created_at
Time.at(created_date / 1000) if created_date.is_a?(Integer) Time.at(created_date / 1000) if created_date.is_a?(Integer)
end end
def updated_at
Time.at(updated_date / 1000) if created_date.is_a?(Integer)
end
private private
def raw_comment def action
raw.fetch('comment', {}) raw['action']
end end
def comment_anchor def comment_anchor
raw['commentAnchor'] raw['commentAnchor']
end end
def author
raw_comment.fetch('author', {})
end
def created_date def created_date
comment['createdDate'] raw.dig('createdDate')
end
def updated_date
comment['updatedDate']
end end
end end
end end
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment