Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/conflict/file_spec.rb')
-rw-r--r--spec/lib/gitlab/conflict/file_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb
index f8a007cdd75..aac4936b20e 100644
--- a/spec/lib/gitlab/conflict/file_spec.rb
+++ b/spec/lib/gitlab/conflict/file_spec.rb
@@ -17,6 +17,18 @@ RSpec.describe Gitlab::Conflict::File do
let(:raw_conflict_file) { Gitlab::Git::Conflict::File.new(repository, our_commit.oid, rugged_conflict, raw_conflict_content) }
let(:conflict_file) { described_class.new(raw_conflict_file, merge_request: merge_request) }
+ describe 'delegates' do
+ it { expect(conflict_file).to delegate_method(:type).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:content).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:path).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:ancestor_path).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:their_path).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:our_path).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:our_mode).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:our_blob).to(:raw) }
+ it { expect(conflict_file).to delegate_method(:repository).to(:raw) }
+ end
+
describe '#resolve_lines' do
let(:section_keys) { conflict_file.sections.map { |section| section[:id] }.compact }
@@ -324,4 +336,27 @@ RSpec.describe Gitlab::Conflict::File do
end
end
end
+
+ describe '#conflict_type' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:rugged_conflict) { { ancestor: { path: ancestor_path }, theirs: { path: their_path }, ours: { path: our_path } } }
+ let(:diff_file) { double(renamed_file?: renamed_file?) }
+
+ subject(:conflict_type) { conflict_file.conflict_type(diff_file) }
+
+ where(:ancestor_path, :their_path, :our_path, :renamed_file?, :result) do
+ '/ancestor/path' | '/their/path' | '/our/path' | false | :both_modified
+ '/ancestor/path' | '' | '/our/path' | false | :modified_source_removed_target
+ '/ancestor/path' | '/their/path' | '' | false | :modified_target_removed_source
+ '' | '/their/path' | '/our/path' | false | :both_added
+ '' | '' | '/our/path' | false | :removed_target_renamed_source
+ '' | '' | '/our/path' | true | :renamed_same_file
+ '' | '/their/path' | '' | false | :removed_source_renamed_target
+ end
+
+ with_them do
+ it { expect(conflict_type).to eq(result) }
+ end
+ end
end