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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BitbucketServer::Representation::Activity, feature_category: :importers do
let(:activities) { Gitlab::Json.parse(fixture_file('importers/bitbucket_server/activities.json'))['values'] }
let(:inline_comment) { activities.first }
let(:comment) { activities[3] }
let(:merge_event) { activities[4] }
let(:approved_event) { activities[8] }
let(:declined_event) { activities[9] }
describe 'regular comment' do
subject { described_class.new(comment) }
it { expect(subject.id).to eq(11) }
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) }
describe '#to_hash' do
it do
expect(subject.to_hash).to match(a_hash_including(id: 11))
end
end
end
describe 'inline comment' do
subject { described_class.new(inline_comment) }
it { expect(subject.id).to eq(19) }
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) }
describe '#to_hash' do
it do
expect(subject.to_hash).to match(a_hash_including(id: 19))
end
end
end
describe 'merge event' do
subject { described_class.new(merge_event) }
it { expect(subject.id).to eq(7) }
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_name).to eq('root') }
it { expect(subject.committer_username).to eq('slug') }
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') }
describe '#to_hash' do
it do
expect(subject.to_hash).to match(
a_hash_including(
id: 7,
committer_user: 'root',
committer_name: 'root',
committer_username: 'slug',
committer_email: 'test.user@example.com',
merge_commit: '839fa9a2d434eb697815b8fcafaecc51accfdbbc'
)
)
end
end
end
describe 'approved event' do
subject { described_class.new(approved_event) }
it { expect(subject.id).to eq(15) }
it { expect(subject.comment?).to be_falsey }
it { expect(subject.inline_comment?).to be_falsey }
it { expect(subject.merge_event?).to be_falsey }
it { expect(subject.approved_event?).to be_truthy }
it { expect(subject.approver_name).to eq('root') }
it { expect(subject.approver_username).to eq('slug') }
it { expect(subject.approver_email).to eq('test.user@example.com') }
it { expect(subject.created_at).to be_a(Time) }
describe '#to_hash' do
it do
expect(subject.to_hash).to match(
a_hash_including(
id: 15,
approver_name: 'root',
approver_username: 'slug',
approver_email: 'test.user@example.com'
)
)
end
end
end
describe 'declined event' do
subject { described_class.new(declined_event) }
it { expect(subject.id).to eq(18) }
it { expect(subject.comment?).to be_falsey }
it { expect(subject.inline_comment?).to be_falsey }
it { expect(subject.merge_event?).to be_falsey }
it { expect(subject.declined_event?).to be_truthy }
it { expect(subject.decliner_name).to eq('root') }
it { expect(subject.decliner_username).to eq('slug') }
it { expect(subject.decliner_email).to eq('test.user@example.com') }
it { expect(subject.created_at).to be_a(Time) }
describe '#to_hash' do
it do
expect(subject.to_hash).to match(
a_hash_including(
id: 18,
decliner_name: 'root',
decliner_username: 'slug',
decliner_email: 'test.user@example.com'
)
)
end
end
end
end
|