Commit cf4cbb01 authored by Douwe Maan's avatar Douwe Maan Committed by Fatih Acet
Browse files

Rename `can_resolve_conflicts_in_ui?` to `conflicts_can_be_resolved_in_ui?`

parent b43d85e00a39
......@@ -135,7 +135,7 @@ def conflicts
format.html { define_discussion_vars }
format.json do
if @merge_request.can_resolve_conflicts_in_ui?
if @merge_request.conflicts_can_be_resolved_in_ui?
render json: @merge_request.conflicts
else
render json: {
......
......@@ -720,14 +720,16 @@ def conflicts
@conflicts ||= Gitlab::Conflict::FileCollection.new(self)
end
def can_resolve_conflicts_in_ui?
return false unless cannot_be_merged?
return false unless has_complete_diff_refs?
def conflicts_can_be_resolved_in_ui?
return @conflicts_can_be_resolved_in_ui if defined?(@conflicts_can_be_resolved_in_ui)
return @conflicts_can_be_resolved_in_ui = false unless cannot_be_merged?
return @conflicts_can_be_resolved_in_ui = false unless has_complete_diff_refs?
begin
conflicts.files.each(&:lines)
@conflicts_can_be_resolved_in_ui = conflicts.files.each(&:lines)
rescue Gitlab::Conflict::Parser::ParserError, Gitlab::Conflict::FileCollection::ConflictSideMissing
false
@conflicts_can_be_resolved_in_ui = false
end
end
end
......@@ -4,7 +4,7 @@
%p
Please
- if @merge_request.can_resolve_conflicts_in_ui?
- if @merge_request.conflicts_can_be_resolved_in_ui?
= link_to "resolve these conflicts", conflicts_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
or
- if @merge_request.can_be_merged_via_command_line_by?(current_user)
......
......@@ -742,7 +742,7 @@
end
end
describe '#can_resolve_conflicts_in_ui?' do
describe '#conflicts_can_be_resolved_in_ui?' do
def create_merge_request(source_branch)
create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start') do |mr|
mr.mark_as_unmergeable
......@@ -753,44 +753,44 @@ def create_merge_request(source_branch)
merge_request = create_merge_request('master')
merge_request.mark_as_mergeable
expect(merge_request.can_resolve_conflicts_in_ui?).to be_falsey
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a falsey value when the MR does not support new diff notes' do
merge_request = create_merge_request('conflict-resolvable')
merge_request.merge_request_diff.update_attributes(start_commit_sha: nil)
expect(merge_request.can_resolve_conflicts_in_ui?).to be_falsey
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a falsey value when the conflicts contain a large file' do
merge_request = create_merge_request('conflict-too-large')
expect(merge_request.can_resolve_conflicts_in_ui?).to be_falsey
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a falsey value when the conflicts contain a binary file' do
merge_request = create_merge_request('conflict-binary-file')
expect(merge_request.can_resolve_conflicts_in_ui?).to be_falsey
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a falsey value when the conflicts contain a file with ambiguous conflict markers' do
merge_request = create_merge_request('conflict-contains-conflict-markers')
expect(merge_request.can_resolve_conflicts_in_ui?).to be_falsey
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a falsey value when the conflicts contain a file edited in one branch and deleted in another' do
merge_request = create_merge_request('conflict-missing-side')
expect(merge_request.can_resolve_conflicts_in_ui?).to be_falsey
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
end
it 'returns a truthy value when the conflicts are resolvable in the UI' do
merge_request = create_merge_request('conflict-resolvable')
expect(merge_request.can_resolve_conflicts_in_ui?).to be_truthy
expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_truthy
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment