diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-08 14:51:40 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-08 14:51:40 +0000 |
commit | ef5667204f28000cc66f258b199239b883230e32 (patch) | |
tree | 537e14045d536ad2ecc1e8914ef6373818079cfe | |
parent | abb53bb6b718f56d44aa5480c85d29177f03e5c3 (diff) | |
parent | 0a8289cafd4a996452c0e21322178793be8120be (diff) | |
download | gitlab-ce-ef5667204f28000cc66f258b199239b883230e32.tar.gz |
Merge branch '24507_remove_deleted_branch_link_in_merge_request' into 'master'
Remove unnecessary target branch link from MR page in case of deleted target branch
Fixes #24507
See merge request !7916
3 files changed, 46 insertions, 1 deletions
diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml index 0e2975bd551..896f10104fa 100644 --- a/app/views/projects/merge_requests/_show.html.haml +++ b/app/views/projects/merge_requests/_show.html.haml @@ -31,7 +31,7 @@ %span.label-branch= source_branch_with_namespace(@merge_request) %span into %span.label-branch - = link_to @merge_request.target_branch, namespace_project_commits_path(@project.namespace, @project, @merge_request.target_branch) + = link_to_if @merge_request.target_branch_exists?, @merge_request.target_branch, namespace_project_commits_path(@project.namespace, @project, @merge_request.target_branch) - if @merge_request.open? && @merge_request.diverged_from_target_branch? %span (#{pluralize(@merge_request.diverged_commits_count, 'commit')} behind) diff --git a/changelogs/unreleased/24507_remove_deleted_branch_link_in_merge_request.yml b/changelogs/unreleased/24507_remove_deleted_branch_link_in_merge_request.yml new file mode 100644 index 00000000000..34999480d4a --- /dev/null +++ b/changelogs/unreleased/24507_remove_deleted_branch_link_in_merge_request.yml @@ -0,0 +1,4 @@ +--- +title: 'Remove unnecessary target branch link from MR page in case of deleted target branch' +merge_request: 7916 +author: Rydkin Maxim diff --git a/spec/features/merge_requests/target_branch_spec.rb b/spec/features/merge_requests/target_branch_spec.rb new file mode 100644 index 00000000000..b6134540273 --- /dev/null +++ b/spec/features/merge_requests/target_branch_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'Target branch', feature: true do + let(:user) { create(:user) } + let(:merge_request) { create(:merge_request) } + let(:project) { merge_request.project } + + def path_to_merge_request + namespace_project_merge_request_path( + project.namespace, + project, merge_request + ) + end + + before do + login_as user + project.team << [user, :master] + end + + it 'shows link to target branch' do + visit path_to_merge_request + expect(page).to have_link('feature', href: namespace_project_commits_path(project.namespace, project, merge_request.target_branch)) + end + + context 'when branch was deleted' do + before do + DeleteBranchService.new(project, user).execute('feature') + visit path_to_merge_request + end + + it 'shows a message about missing target branch' do + expect(page).to have_content( + 'Target branch feature does not exist' + ) + end + + it 'does not show link to target branch' do + expect(page).not_to have_link('feature') + end + end +end |