diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-08 12:09:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-08 12:09:56 +0300 |
commit | e612fbe905cf0eacf7e34dbd72d8be98ce5d4eb7 (patch) | |
tree | ab64e82813abf51c9fa5f0a8e55a0354151772fb /spec/serializers/merge_request_diff_entity_spec.rb | |
parent | fe30598cbd0756ba0c6326178f64b68e5ae8a30d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/merge_request_diff_entity_spec.rb')
-rw-r--r-- | spec/serializers/merge_request_diff_entity_spec.rb | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/spec/serializers/merge_request_diff_entity_spec.rb b/spec/serializers/merge_request_diff_entity_spec.rb index a3b356505b8..5bc7eea92a8 100644 --- a/spec/serializers/merge_request_diff_entity_spec.rb +++ b/spec/serializers/merge_request_diff_entity_spec.rb @@ -11,7 +11,13 @@ RSpec.describe MergeRequestDiffEntity do let(:merge_request_diff) { merge_request_diffs.first } let(:entity) do - described_class.new(merge_request_diff, request: request, merge_request: merge_request, merge_request_diffs: merge_request_diffs) + described_class.new( + merge_request_diff, + request: request, + merge_request: merge_request, + merge_request_diff: merge_request_diff, + merge_request_diffs: merge_request_diffs + ) end subject { entity.as_json } @@ -26,6 +32,46 @@ RSpec.describe MergeRequestDiffEntity do end end + describe '#version_index' do + shared_examples 'version_index is nil' do + it 'returns nil' do + expect(subject[:version_index]).to be_nil + end + end + + context 'when diff is not present' do + let(:entity) do + described_class.new( + merge_request_diff, + request: request, + merge_request: merge_request, + merge_request_diffs: merge_request_diffs + ) + end + + it_behaves_like 'version_index is nil' + end + + context 'when diff is not included in @merge_request_diffs' do + let(:merge_request_diff) { create(:merge_request_diff) } + let(:merge_request_diff_2) { create(:merge_request_diff) } + + before do + merge_request_diffs << merge_request_diff_2 + end + + it_behaves_like 'version_index is nil' + end + + context 'when @merge_request_diffs.size <= 1' do + before do + expect(merge_request_diffs.size).to eq(1) + end + + it_behaves_like 'version_index is nil' + end + end + describe '#short_commit_sha' do it 'returns short sha' do expect(subject[:short_commit_sha]).to eq('b83d6e39') |