2021-01-21 19:09:25 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe DiffFileMetadataEntity do
|
|
|
|
let(:merge_request) { create(:merge_request_with_diffs) }
|
2021-07-28 11:09:57 -04:00
|
|
|
let(:diff_file) { merge_request.merge_request_diff.diffs.raw_diff_files.first }
|
|
|
|
let(:options) { {} }
|
|
|
|
let(:entity) { described_class.new(diff_file, options) }
|
2021-01-21 19:09:25 -05:00
|
|
|
|
|
|
|
context 'as json' do
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
|
|
|
it 'exposes the expected fields' do
|
|
|
|
expect(subject.keys).to contain_exactly(
|
|
|
|
:added_lines,
|
|
|
|
:removed_lines,
|
|
|
|
:new_path,
|
|
|
|
:old_path,
|
|
|
|
:new_file,
|
|
|
|
:deleted_file,
|
|
|
|
:submodule,
|
|
|
|
:file_identifier_hash,
|
2021-07-28 11:09:57 -04:00
|
|
|
:file_hash,
|
|
|
|
:conflict_type
|
2021-01-21 19:09:25 -05:00
|
|
|
)
|
|
|
|
end
|
2021-07-28 11:09:57 -04:00
|
|
|
|
|
|
|
it_behaves_like 'diff file with conflict_type'
|
2021-01-21 19:09:25 -05:00
|
|
|
end
|
|
|
|
end
|