BigW Consortium Gitlab

Commit e7e22ece by Dmitriy Zaporozhets

Merge branch 'issue_3583' into 'master'

Ensure "Remove Source Branch" button is not shown when branch is being deleted. Given the merging of the Merge Request happens in the background, sometimes when the client JS code reloads the page the source branch is not still gone. This fix appends a new query string parameter that is checked in the view before rendering the `Remove Source Branch` button. Closes #3583 See merge request !1897
parents 40143a8e aa1ba009
......@@ -10,6 +10,7 @@ v 8.3.0 (unreleased)
- Don't show project fork event as "imported"
- Add API endpoint to fetch merge request commits list
- 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
- Fix 404 in redirection after removing a project (Stan Hu)
......
......@@ -10,17 +10,20 @@ class @MergeRequestWidget
constructor: (@opts) ->
modal = $('#modal_merge_info').modal(show: false)
mergeInProgress: ->
mergeInProgress: (deleteSourceBranch = false)->
$.ajax
type: 'GET'
url: $('.merge-request').data('url')
success: (data) =>
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
$('.mr-widget-body').html("<h4>" + data.merge_error + "</h4>")
else
setTimeout(merge_request_widget.mergeInProgress, 2000)
callback = -> merge_request_widget.mergeInProgress(deleteSourceBranch)
setTimeout(callback, 2000)
dataType: 'json'
getMergeStatus: ->
......
......@@ -6,7 +6,7 @@
#
# 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:
#
......
- if @status
:plain
merge_request_widget.mergeInProgress();
merge_request_widget.mergeInProgress(#{params[:should_remove_source_branch] == '1'});
- else
:plain
$('.mr-widget-body').html("#{escape_javascript(render('projects/merge_requests/widget/open/reload'))}");
......@@ -7,7 +7,7 @@
by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)}
#{time_ago_with_tooltip(@merge_request.merge_event.created_at)}
%div
- if !@merge_request.source_branch_exists?
- if !@merge_request.source_branch_exists? || (params[:delete_source] == 'true')
= succeed '.' do
The changes were merged into
= 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