Commit aa1ba009 authored by Rubén Dávila's avatar Rubén Dávila

Ensure "Remove Source Branch" button is not shown when branch is being deleted. #3583

parent 238ca3e4
...@@ -9,6 +9,7 @@ v 8.3.0 (unreleased) ...@@ -9,6 +9,7 @@ v 8.3.0 (unreleased)
- Don't show project fork event as "imported" - Don't show project fork event as "imported"
- Add API endpoint to fetch merge request commits list - Add API endpoint to fetch merge request commits list
- Expose events API with comment information and author info - Expose events API with comment information and author info
- Fix: Ensure "Remove Source Branch" button is not shown when branch is being deleted. #3583
v 8.2.2 v 8.2.2
- Fix 404 in redirection after removing a project (Stan Hu) - Fix 404 in redirection after removing a project (Stan Hu)
......
...@@ -10,17 +10,20 @@ class @MergeRequestWidget ...@@ -10,17 +10,20 @@ class @MergeRequestWidget
constructor: (@opts) -> constructor: (@opts) ->
modal = $('#modal_merge_info').modal(show: false) modal = $('#modal_merge_info').modal(show: false)
mergeInProgress: -> mergeInProgress: (deleteSourceBranch = false)->
$.ajax $.ajax
type: 'GET' type: 'GET'
url: $('.merge-request').data('url') url: $('.merge-request').data('url')
success: (data) => success: (data) =>
if data.state == "merged" if data.state == "merged"
location.reload() urlSuffix = if deleteSourceBranch then '?delete_source=true' else ''
window.location.href = window.location.href + urlSuffix
else if data.merge_error else if data.merge_error
$('.mr-widget-body').html("<h4>" + data.merge_error + "</h4>") $('.mr-widget-body').html("<h4>" + data.merge_error + "</h4>")
else else
setTimeout(merge_request_widget.mergeInProgress, 2000) callback = -> merge_request_widget.mergeInProgress(deleteSourceBranch)
setTimeout(callback, 2000)
dataType: 'json' dataType: 'json'
getMergeStatus: -> getMergeStatus: ->
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# #
# For example instead of this: # For example instead of this:
# #
# namespace_project_merge_request_path(merge_request.project.namespace, merge_request.projects, merge_request) # namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request)
# #
# We can simply use shortcut: # We can simply use shortcut:
# #
......
- if @status - if @status
:plain :plain
merge_request_widget.mergeInProgress(); merge_request_widget.mergeInProgress(#{params[:should_remove_source_branch] == '1'});
- else - else
:plain :plain
$('.mr-widget-body').html("#{escape_javascript(render('projects/merge_requests/widget/open/reload'))}"); $('.mr-widget-body').html("#{escape_javascript(render('projects/merge_requests/widget/open/reload'))}");
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)} by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)}
#{time_ago_with_tooltip(@merge_request.merge_event.created_at)} #{time_ago_with_tooltip(@merge_request.merge_event.created_at)}
%div %div
- if !@merge_request.source_branch_exists? - if !@merge_request.source_branch_exists? || (params[:delete_source] == 'true')
= succeed '.' do = succeed '.' do
The changes were merged into The changes were merged into
= link_to namespace_project_commits_path(@project.namespace, @project, @merge_request.target_branch), class: "label-branch" do = link_to namespace_project_commits_path(@project.namespace, @project, @merge_request.target_branch), class: "label-branch" do
......
Feature: Project Merge Requests Acceptance
Background:
Given There is an open Merge Request
And I am signed in as a developer of the project
@javascript
Scenario: Accepting the Merge Request and removing the source branch
Given I am on the Merge Request detail page
When I click on "Remove source branch" option
And I click on Accept Merge Request
Then I should not see the Remove Source Branch button
@javascript
Scenario: Accepting the Merge Request without removing the source branch
Given I am on the Merge Request detail page
When I click on Accept Merge Request
Then I should see the Remove Source Branch button
class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps
include LoginHelpers
include GitlabRoutingHelper
step 'I am on the Merge Request detail page' do
visit merge_request_path(@merge_request)
end
step 'I click on "Remove source branch" option' do
check('Remove source branch')
end
step 'I click on Accept Merge Request' do
click_button('Accept Merge Request')
end
step 'I should see the Remove Source Branch button' do
expect(page).to have_link('Remove Source Branch')
end
step 'I should not see the Remove Source Branch button' do
expect(page).not_to have_link('Remove Source Branch')
end
step 'There is an open Merge Request' do
@user = create(:user)
@project = create(:project, :public)
@project_member = create(:project_member, user: @user, project: @project, access_level: ProjectMember::DEVELOPER)
@merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project)
end
step 'I am signed in as a developer of the project' do
login_as(@user)
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