BigW Consortium Gitlab

Commit 46278ec7 by Zeger-Jan van de Weg

Button fix

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