BigW Consortium Gitlab

Unverified Commit ea7bf7ed by jurre

Show a custom WIP help message for MR's with WIP commits

parent e59623e7
......@@ -11,7 +11,7 @@
= link_to 'Change branches', mr_change_branches_path(@merge_request)
%hr
= form_for [@project.namespace.becomes(Namespace), @project, @merge_request], html: { class: 'merge-request-form form-horizontal common-note-form js-requires-input js-quick-submit' } do |f|
= render 'shared/issuable/form', f: f, issuable: @merge_request
= render 'shared/issuable/form', f: f, issuable: @merge_request, commits: @commits
= f.hidden_field :source_project_id
= f.hidden_field :source_branch
= f.hidden_field :target_project_id
......
- form = local_assigns.fetch(:f)
- commits = local_assigns[:commits]
- project = @target_project || @project
= form_errors(issuable)
......@@ -14,7 +15,7 @@
= form.label :title, class: 'control-label'
= render 'shared/issuable/form/template_selector', issuable: issuable
= render 'shared/issuable/form/title', issuable: issuable, form: form
= render 'shared/issuable/form/title', issuable: issuable, form: form, has_wip_commits: commits && commits.detect(&:work_in_progress?)
= render 'shared/issuable/form/description', issuable: issuable, form: form
......
- issuable = local_assigns.fetch(:issuable)
- has_wip_commits = local_assigns.fetch(:has_wip_commits)
- form = local_assigns.fetch(:form)
- no_issuable_templates = issuable_templates(issuable).empty?
- div_class = no_issuable_templates ? 'col-sm-10' : 'col-sm-7 col-lg-8'
......@@ -18,6 +19,9 @@
%strong Work In Progress
merge request to be merged when it's ready.
.js-no-wip-explanation
- if has_wip_commits
It looks like you have some WIP commits in this branch.
%br
%a.js-toggle-wip{ href: '', tabindex: -1 }
Start the title with
%code WIP:
......
require 'spec_helper'
feature 'Work In Progress help message', feature: true do
let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let!(:user) { create(:user) }
before do
project.team << [user, :master]
login_as(user)
end
context 'with WIP commits' do
it 'shows a specific WIP hint' do
visit new_namespace_project_merge_request_path(
project.namespace,
project,
merge_request: {
source_project_id: project.id,
target_project_id: project.id,
source_branch: 'wip',
target_branch: 'master'
}
)
within_wip_explanation do
expect(page).to have_text(
'It looks like you have some WIP commits in this branch'
)
end
end
end
context 'without WIP commits' do
it 'shows the regular WIP message' do
visit new_namespace_project_merge_request_path(
project.namespace,
project,
merge_request: {
source_project_id: project.id,
target_project_id: project.id,
source_branch: 'fix',
target_branch: 'master'
}
)
within_wip_explanation do
expect(page).not_to have_text(
'It looks like you have some WIP commits in this branch'
)
expect(page).to have_text(
"Start the title with WIP: to prevent a Work In Progress merge \
request from being merged before it's ready"
)
end
end
end
def within_wip_explanation(&block)
page.within '.js-no-wip-explanation' do
yield
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