diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-10 12:06:19 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-10 12:06:19 +0000 |
commit | 69849c280c5525d132ebaddb1200c390a42ecc06 (patch) | |
tree | 2c6ffc6fd6dc4fa719305f25b475391730389747 /spec/serializers | |
parent | c157f963db87a40a3ba7b94b339530ee83194bc8 (diff) | |
download | gitlab-ce-69849c280c5525d132ebaddb1200c390a42ecc06.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/diffs_metadata_entity_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/serializers/diffs_metadata_entity_spec.rb b/spec/serializers/diffs_metadata_entity_spec.rb new file mode 100644 index 00000000000..aaca393ec27 --- /dev/null +++ b/spec/serializers/diffs_metadata_entity_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe DiffsMetadataEntity do + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + let(:request) { EntityRequest.new(project: project, current_user: user) } + let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } + let(:merge_request_diffs) { merge_request.merge_request_diffs } + let(:merge_request_diff) { merge_request_diffs.last } + + let(:entity) do + described_class.new(merge_request_diff.diffs, + request: request, + merge_request: merge_request, + merge_request_diffs: merge_request_diffs) + end + + context 'as json' do + subject { entity.as_json } + + it 'contain only required attributes' do + expect(subject.keys).to contain_exactly( + # Inherited attributes + :real_size, :size, :branch_name, + :target_branch_name, :commit, :merge_request_diff, + :start_version, :latest_diff, :latest_version_path, + :added_lines, :removed_lines, :render_overflow_warning, + :email_patch_path, :plain_diff_path, + :merge_request_diffs, + # Attributes + :diff_files + ) + end + + describe 'diff_files' do + it 'returns diff files metadata' do + payload = + DiffFileMetadataEntity.represent(merge_request_diff.diffs.diff_files).as_json + + expect(subject[:diff_files]).to eq(payload) + end + end + end +end |