From 85dc423f7090da0a52c73eb66faf22ddb20efff9 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Sat, 19 Sep 2020 01:45:44 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-4-stable-ee --- .../representation/comment_spec.rb | 25 +++++++++++++++++++- .../representation/pull_request_spec.rb | 27 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'spec/lib/bitbucket_server') diff --git a/spec/lib/bitbucket_server/representation/comment_spec.rb b/spec/lib/bitbucket_server/representation/comment_spec.rb index b568789bd97..41cdaab7a00 100644 --- a/spec/lib/bitbucket_server/representation/comment_spec.rb +++ b/spec/lib/bitbucket_server/representation/comment_spec.rb @@ -13,7 +13,30 @@ RSpec.describe BitbucketServer::Representation::Comment do end describe '#author_username' do - it { expect(subject.author_username).to eq('root' ) } + it 'returns username' do + expect(subject.author_username).to eq('username') + end + + context 'when username is absent' do + before do + comment['comment']['author'].delete('username') + end + + it 'returns slug' do + expect(subject.author_username).to eq('slug') + end + end + + context 'when slug and username are absent' do + before do + comment['comment']['author'].delete('username') + comment['comment']['author'].delete('slug') + end + + it 'returns displayName' do + expect(subject.author_username).to eq('root') + end + end end describe '#author_email' do diff --git a/spec/lib/bitbucket_server/representation/pull_request_spec.rb b/spec/lib/bitbucket_server/representation/pull_request_spec.rb index a05d98f0d4a..d7b893e8081 100644 --- a/spec/lib/bitbucket_server/representation/pull_request_spec.rb +++ b/spec/lib/bitbucket_server/representation/pull_request_spec.rb @@ -15,6 +15,33 @@ RSpec.describe BitbucketServer::Representation::PullRequest do it { expect(subject.author_email).to eq('joe.montana@49ers.com') } end + describe '#author_username' do + it 'returns username' do + expect(subject.author_username).to eq('username') + end + + context 'when username is absent' do + before do + sample_data['author']['user'].delete('username') + end + + it 'returns slug' do + expect(subject.author_username).to eq('slug') + end + end + + context 'when slug and username are absent' do + before do + sample_data['author']['user'].delete('username') + sample_data['author']['user'].delete('slug') + end + + it 'returns displayName' do + expect(subject.author_username).to eq('displayName') + end + end + end + describe '#description' do it { expect(subject.description).to eq('Test') } end -- cgit v1.2.3