summaryrefslogtreecommitdiff
path: root/spec/lib/bitbucket_server/representation/activity_spec.rb
blob: 15c50e40472ae8052f43df66b90198e02a159087 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'spec_helper'

describe BitbucketServer::Representation::Activity do
  let(:activities) { JSON.parse(fixture_file('importers/bitbucket_server/activities.json'))['values'] }
  let(:inline_comment) { activities.first }
  let(:comment) { activities[3] }
  let(:merge_event) { activities[4] }

  describe 'regular comment' do
    subject { described_class.new(comment) }

    it { expect(subject.comment?).to be_truthy }
    it { expect(subject.inline_comment?).to be_falsey }
    it { expect(subject.comment).to be_a(BitbucketServer::Representation::Comment) }
    it { expect(subject.created_at).to be_a(Time) }
  end

  describe 'inline comment' do
    subject { described_class.new(inline_comment) }

    it { expect(subject.comment?).to be_truthy }
    it { expect(subject.inline_comment?).to be_truthy }
    it { expect(subject.comment).to be_a(BitbucketServer::Representation::PullRequestComment) }
    it { expect(subject.created_at).to be_a(Time) }
  end

  describe 'merge event' do
    subject { described_class.new(merge_event) }

    it { expect(subject.comment?).to be_falsey }
    it { expect(subject.inline_comment?).to be_falsey }
    it { expect(subject.committer_user).to eq('root') }
    it { expect(subject.committer_email).to eq('test.user@example.com') }
    it { expect(subject.merge_timestamp).to be_a(Time) }
    it { expect(subject.created_at).to be_a(Time) }
    it { expect(subject.merge_commit).to eq('839fa9a2d434eb697815b8fcafaecc51accfdbbc') }
  end
end