diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-15 21:09:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-15 21:09:57 +0300 |
commit | a8476fe0cd764ac054763032b7cf6e63b0b493c5 (patch) | |
tree | ba2685026667de0b5d67c75bf98bb87014f01b32 /spec/serializers/merge_request_diff_entity_spec.rb | |
parent | 68d7192881c41305da9c6aa1e3f7dd8b47f286a7 (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 | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/serializers/merge_request_diff_entity_spec.rb b/spec/serializers/merge_request_diff_entity_spec.rb index 5bc7eea92a8..9bf95e68874 100644 --- a/spec/serializers/merge_request_diff_entity_spec.rb +++ b/spec/serializers/merge_request_diff_entity_spec.rb @@ -10,7 +10,9 @@ RSpec.describe MergeRequestDiffEntity do let(:merge_request_diffs) { merge_request.merge_request_diffs } let(:merge_request_diff) { merge_request_diffs.first } - let(:entity) do + let(:entity) { initialize_entity(merge_request, merge_request_diff) } + + def initialize_entity(merge_request, merge_request_diff) described_class.new( merge_request_diff, request: request, @@ -70,6 +72,22 @@ RSpec.describe MergeRequestDiffEntity do it_behaves_like 'version_index is nil' end + + context 'when @merge_request_diffs.size > 1' do + let(:merge_request) { create(:merge_request_with_multiple_diffs) } + + it 'returns difference between size and diff index' do + expect(merge_request_diffs.size).to eq(2) + + # diff index: 0 + subject = initialize_entity(merge_request, merge_request_diffs.first) + expect(subject.as_json[:version_index]).to eq(2) + + # diff index: 1 + subject = initialize_entity(merge_request, merge_request_diffs.last) + expect(subject.as_json[:version_index]).to eq(1) + end + end end describe '#short_commit_sha' do |