Commit 2683280e authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix-merge-immediately-button' into 'master'

Fix updating and disabling merge button when Merge Immediately is clicked

Fixes #4128

See merge request !2124
parents 52814562 2d0f9dd0
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
.accept-action .accept-action
- if @ci_commit && @ci_commit.active? - if @ci_commit && @ci_commit.active?
%span.btn-group %span.btn-group
= link_to "#", class: "btn btn-create merge_when_build_succeeds" do = button_tag class: "btn btn-create js-merge-button merge_when_build_succeeds" do
Merge When Build Succeeds Merge When Build Succeeds
%a.btn.btn-success.dropdown-toggle{ 'data-toggle' => 'dropdown' } = button_tag class: "btn btn-success dropdown-toggle", 'data-toggle' => 'dropdown' do
%span.caret %span.caret
%span.sr-only %span.sr-only
Select Merge Moment Select Merge Moment
%ul.dropdown-menu.dropdown-menu-right{ role: 'menu' } %ul.js-merge-dropdown.dropdown-menu.dropdown-menu-right{ role: 'menu' }
%li %li
= link_to "#", class: "merge_when_build_succeeds" do = link_to "#", class: "merge_when_build_succeeds" do
= icon('check fw') = icon('check fw')
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
= icon('warning fw') = icon('warning fw')
Merge Immediately Merge Immediately
- else - else
= f.button class: "btn btn-create btn-grouped accept_merge_request #{status_class}" do = f.button class: "btn btn-create btn-grouped js-merge-button accept_merge_request #{status_class}" do
Accept Merge Request Accept Merge Request
- if @merge_request.can_remove_source_branch?(current_user) - if @merge_request.can_remove_source_branch?(current_user)
.accept-control.checkbox .accept-control.checkbox
...@@ -42,21 +42,19 @@ ...@@ -42,21 +42,19 @@
= hidden_field_tag :merge_when_build_succeeds, "", autocomplete: "off" = hidden_field_tag :merge_when_build_succeeds, "", autocomplete: "off"
:javascript :javascript
$('.accept_merge_request').on('click', function() {
$(this).html("<i class='fa fa-spinner fa-spin'></i> Merge in progress");
});
$('.accept-mr-form').on('ajax:send', function() { $('.accept-mr-form').on('ajax:send', function() {
$(".accept-mr-form :input").disable(); $(".accept-mr-form :input").disable();
}); });
$('a.accept_merge_request').on('click', function(e) { $('.accept_merge_request').on('click', function() {
e.preventDefault(); $('.js-merge-button').html("<i class='fa fa-spinner fa-spin'></i> Merge in progress");
$(this).closest("form").submit();
}); });
$('a.merge_when_build_succeeds').on('click', function(e) { $('.merge_when_build_succeeds').on('click', function() {
e.preventDefault();
$("#merge_when_build_succeeds").val("1"); $("#merge_when_build_succeeds").val("1");
});
$('.js-merge-dropdown a').on('click', function(e) {
e.preventDefault();
$(this).closest("form").submit(); $(this).closest("form").submit();
}); });
...@@ -21,12 +21,12 @@ feature 'Merge When Build Succeeds', feature: true, js: true do ...@@ -21,12 +21,12 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
end end
it 'displays the Merge When Build Succeeds button' do it 'displays the Merge When Build Succeeds button' do
expect(page).to have_link "Merge When Build Succeeds" expect(page).to have_button "Merge When Build Succeeds"
end end
context "Merge When Build succeeds enabled" do context "Merge When Build succeeds enabled" do
before do before do
click_link "Merge When Build Succeeds" click_button "Merge When Build Succeeds"
end end
it 'activates Merge When Build Succeeds feature' do it 'activates Merge When Build Succeeds feature' do
...@@ -58,7 +58,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do ...@@ -58,7 +58,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
it 'cancels the automatic merge' do it 'cancels the automatic merge' do
click_link "Cancel Automatic Merge" click_link "Cancel Automatic Merge"
expect(page).to have_link "Merge When Build Succeeds" expect(page).to have_button "Merge When Build Succeeds"
visit_merge_request(merge_request) # Needed to refresh the page visit_merge_request(merge_request) # Needed to refresh the page
expect(page).to have_content "Canceled the automatic merge" expect(page).to have_content "Canceled the automatic merge"
......
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