Commit 46278ec7 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Button fix

parent 2462a96e
......@@ -139,7 +139,7 @@ class SystemNoteService
# Called when 'merge when build succeeds' is canceled
def self.cancel_merge_when_build_succeeds(noteable, project, author)
body = "Cancelled the automatic merge"
body = "Canceled the automatic merge"
create_note(noteable: noteable, project: project, author: author, note: body)
end
......
......@@ -5,10 +5,22 @@
.accept-merge-holder.clearfix.js-toggle-container
.accept-action
- if @merge_request.ci_commit && @merge_request.ci_commit.active?
= f.button class: "btn btn-create btn-grouped merge_when_build_succeeds", name: "merge_when_build_succeeds" do
Merge When Build Succeeds
= f.button class: "btn btn-create btn-grouped accept_merge_request #{status_class}" do
Accept Merge Request Now
%span.btn-group
= link_to "#", class: "btn btn-create merge_when_build_succeeds" do
Merge When Build Succeeds
%a.btn.btn-success.dropdown-toggle{ 'data-toggle' => 'dropdown' }
%span.caret
%span.sr-only
Select Merge Moment
%ul.dropdown-menu.dropdown-menu-right{ role: 'menu' }
%li
= link_to "#", class: "merge_when_build_succeeds" do
= icon('check fw')
Merge When Build Succeeds
%li
= link_to "#", class: "accept_merge_request" do
= icon('warning fw')
Accept Merge Request Now
- else
= f.button class: "btn btn-create btn-grouped accept_merge_request #{status_class}" do
Accept Merge Request
......@@ -26,6 +38,8 @@
text: @merge_request.merge_commit_message,
rows: 14, hint: true
= hidden_field_tag :merge_when_build_succeeds, ""
:javascript
$('.accept_merge_request').on('click', function() {
$(this).html("<i class='fa fa-spinner fa-spin'></i> Merge in progress");
......@@ -34,3 +48,14 @@
$('.accept-mr-form').on('ajax:send', function() {
$(".accept-mr-form :input").disable();
});
$('a.accept_merge_request').on('click', function(e) {
e.preventDefault();
$(this).closest("form").submit();
});
$('a.merge_when_build_succeeds').on('click', function(e) {
e.preventDefault();
$("#merge_when_build_succeeds").val("1");
$(this).closest("form").submit();
});
......@@ -68,7 +68,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
expect(page).to have_button "Merge When Build Succeeds"
visit_merge_request(merge_request) # Needed to refresh the page
expect(page).to have_content "Cancelled the automatic merge"
expect(page).to have_content "Canceled the automatic merge"
end
it "allows the user to remove the source branch" do
......
......@@ -192,7 +192,7 @@ describe MergeRequest do
end
end
describe '#can_remove_source_branch' do
describe '#can_remove_source_branch?' do
let(:user) { create(:user) }
let(:user2) { create(:user) }
......
......@@ -78,7 +78,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
it 'Posts a system note' do
note = mr_merge_if_green_enabled.notes.last
expect(note.note).to include 'Cancelled the automatic merge'
expect(note.note).to include 'Canceled the automatic merge'
end
end
end
......@@ -229,7 +229,7 @@ describe SystemNoteService do
it_behaves_like 'a system note'
it "posts the Merge When Build Succeeds system note" do
expect(subject.note).to eq "Cancelled the automatic merge"
expect(subject.note).to eq "Canceled the automatic merge"
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