2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'diff file base entity' do
|
2019-02-15 15:39:39 +05:30
|
|
|
it 'exposes essential attributes' do
|
|
|
|
expect(subject).to include(:content_sha, :submodule, :submodule_link,
|
|
|
|
:submodule_tree_url, :old_path_html,
|
|
|
|
:new_path_html, :blob, :can_modify_blob,
|
|
|
|
:file_hash, :file_path, :old_path, :new_path,
|
2019-07-07 11:18:12 +05:30
|
|
|
:viewer, :diff_refs, :stored_externally,
|
2019-02-15 15:39:39 +05:30
|
|
|
:external_storage, :renamed_file, :deleted_file,
|
2020-06-23 00:09:42 +05:30
|
|
|
:a_mode, :b_mode, :new_file, :file_identifier_hash)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
# Converted diff files from GitHub import does not contain blob file
|
|
|
|
# and content sha.
|
|
|
|
context 'when diff file does not have a blob and content sha' do
|
|
|
|
it 'exposes some attributes as nil' do
|
|
|
|
allow(diff_file).to receive(:content_sha).and_return(nil)
|
|
|
|
allow(diff_file).to receive(:blob).and_return(nil)
|
|
|
|
|
|
|
|
expect(subject[:context_lines_path]).to be_nil
|
|
|
|
expect(subject[:view_path]).to be_nil
|
|
|
|
expect(subject[:highlighted_diff_lines]).to be_nil
|
|
|
|
expect(subject[:can_modify_blob]).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'diff file entity' do
|
2019-02-15 15:39:39 +05:30
|
|
|
it_behaves_like 'diff file base entity'
|
|
|
|
|
|
|
|
it 'exposes correct attributes' do
|
2019-07-07 11:18:12 +05:30
|
|
|
expect(subject).to include(:added_lines, :removed_lines,
|
2019-12-26 22:10:19 +05:30
|
|
|
:context_lines_path)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes viewer' do
|
|
|
|
expect(subject[:viewer].with_indifferent_access)
|
|
|
|
.to match_schema('entities/diff_viewer')
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
context 'diff files' do
|
|
|
|
context 'when diff_view is parallel' do
|
|
|
|
let(:options) { { diff_view: :parallel } }
|
|
|
|
|
|
|
|
it 'contains only the parallel diff lines', :aggregate_failures do
|
|
|
|
expect(subject).to include(:parallel_diff_lines)
|
|
|
|
expect(subject).not_to include(:highlighted_diff_lines)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when diff_view is parallel' do
|
|
|
|
let(:options) { { diff_view: :inline } }
|
|
|
|
|
|
|
|
it 'contains only the inline diff lines', :aggregate_failures do
|
|
|
|
expect(subject).not_to include(:parallel_diff_lines)
|
|
|
|
expect(subject).to include(:highlighted_diff_lines)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the `single_mr_diff_view` feature is disabled' do
|
|
|
|
before do
|
2020-05-24 23:13:21 +05:30
|
|
|
stub_feature_flags(single_mr_diff_view: false)
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains both kinds of diffs' do
|
|
|
|
expect(subject).to include(:highlighted_diff_lines, :parallel_diff_lines)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'diff file discussion entity' do
|
2019-02-15 15:39:39 +05:30
|
|
|
it_behaves_like 'diff file base entity'
|
|
|
|
end
|