Skip to content
Snippets Groups Projects
Commit 104f9e19 authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch '362277-update-delegation-of-wip_title-to-draft_title' into 'master'

Migrate uses of #wip_title to #draft_title

See merge request gitlab-org/gitlab!88219
parents 5799e083 124cb402
No related branches found
No related tags found
No related merge requests found
Showing with 38 additions and 38 deletions
Loading
Loading
@@ -121,16 +121,16 @@ def update(merge_request)
override :handle_quick_actions
def handle_quick_actions(merge_request)
super
handle_wip_event(merge_request)
handle_draft_event(merge_request)
end
 
def handle_wip_event(merge_request)
if wip_event = params.delete(:wip_event)
def handle_draft_event(merge_request)
if draft_event = params.delete(:wip_event)
# We update the title that is provided in the params or we use the mr title
title = params[:title] || merge_request.title
params[:title] = case wip_event
when 'wip' then MergeRequest.wip_title(title)
when 'unwip' then MergeRequest.wipless_title(title)
params[:title] = case draft_event
when 'wip' then MergeRequest.draft_title(title)
when 'unwip' then MergeRequest.draftless_title(title)
end
end
end
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ def execute
:source_branch_ref,
:source_project,
:compare_commits,
:wip_title,
:draft_title,
:description,
:first_multiline_commit,
:errors,
Loading
Loading
@@ -206,7 +206,7 @@ def target_branch_exists?
def set_draft_title_if_needed
return unless compare_commits.empty? || Gitlab::Utils.to_boolean(params[:draft])
 
merge_request.title = wip_title
merge_request.title = draft_title
end
 
# When your branch name starts with an iid followed by a dash this pattern will be
Loading
Loading
Loading
Loading
@@ -201,7 +201,7 @@
 
context 'when merge request 1 is not mergeable' do
before do
merge_request_1.update!(title: merge_request_1.wip_title)
merge_request_1.update!(title: merge_request_1.draft_title)
merge_request_1.merge_train.pipeline.succeed!
 
merge_request_1.reload
Loading
Loading
Loading
Loading
@@ -160,7 +160,7 @@
 
context 'when merge request is not mergeable' do
before do
merge_request.update!(title: merge_request.wip_title)
merge_request.update!(title: merge_request.draft_title)
end
 
it { is_expected.to eq(false) }
Loading
Loading
Loading
Loading
@@ -89,9 +89,9 @@
end
end
 
context 'when merge request is WIP' do
context 'when merge request is a draft' do
before do
merge_request.update!(title: merge_request.wip_title)
merge_request.update!(title: merge_request.draft_title)
end
 
context 'when remove_mergeable_state_check is true' do
Loading
Loading
Loading
Loading
@@ -103,9 +103,9 @@
end
end
 
context 'when merge request is not under a mergeable state' do
context 'when merge request is not in a mergeable state' do
before do
merge_request.update!(title: merge_request.wip_title)
merge_request.update!(title: merge_request.draft_title)
end
 
it_behaves_like 'drops the merge request from the merge train' do
Loading
Loading
Loading
Loading
@@ -1730,7 +1730,7 @@ def go(format: 'html')
 
describe 'POST remove_wip' do
before do
merge_request.title = merge_request.wip_title
merge_request.title = merge_request.draft_title
merge_request.save!
 
post :remove_wip,
Loading
Loading
@@ -1743,8 +1743,8 @@ def go(format: 'html')
xhr: true
end
 
it 'removes the wip status' do
expect(merge_request.reload.title).to eq(merge_request.wipless_title)
it 'removes the draft status' do
expect(merge_request.reload.title).to eq(merge_request.draftless_title)
end
 
it 'renders MergeRequest as JSON' do
Loading
Loading
Loading
Loading
@@ -174,7 +174,7 @@
 
context 'with draft argument' do
before do
merge_request_4.update!(title: MergeRequest.wip_title(merge_request_4.title))
merge_request_4.update!(title: MergeRequest.draft_title(merge_request_4.title))
end
 
context 'with draft: true argument' do
Loading
Loading
Loading
Loading
@@ -1472,20 +1472,20 @@ def set_compare(merge_request)
end
end
 
describe "#wipless_title" do
describe "#draftless_title" do
subject { build_stubbed(:merge_request) }
 
['draft:', 'Draft: ', '[Draft]', '[DRAFT] '].each do |draft_prefix|
it "removes a '#{draft_prefix}' prefix" do
wipless_title = subject.title
draftless_title = subject.title
subject.title = "#{draft_prefix}#{subject.title}"
 
expect(subject.wipless_title).to eq wipless_title
expect(subject.draftless_title).to eq draftless_title
end
 
it "is satisfies the #work_in_progress? method" do
subject.title = "#{draft_prefix}#{subject.title}"
subject.title = subject.wipless_title
subject.title = subject.draftless_title
 
expect(subject.work_in_progress?).to eq false
end
Loading
Loading
@@ -1497,58 +1497,58 @@ def set_compare(merge_request)
it "doesn't remove a '#{wip_prefix}' prefix" do
subject.title = "#{wip_prefix}#{subject.title}"
 
expect(subject.wipless_title).to eq subject.title
expect(subject.draftless_title).to eq subject.title
end
end
 
it 'removes only draft prefix from the MR title' do
subject.title = 'Draft: Implement feature called draft'
 
expect(subject.wipless_title).to eq 'Implement feature called draft'
expect(subject.draftless_title).to eq 'Implement feature called draft'
end
 
it 'does not remove WIP in the middle of the title' do
subject.title = 'Something with WIP in the middle'
 
expect(subject.wipless_title).to eq subject.title
expect(subject.draftless_title).to eq subject.title
end
 
it 'does not remove Draft in the middle of the title' do
subject.title = 'Something with Draft in the middle'
 
expect(subject.wipless_title).to eq subject.title
expect(subject.draftless_title).to eq subject.title
end
 
it 'does not remove WIP at the end of the title' do
subject.title = 'Something ends with WIP'
 
expect(subject.wipless_title).to eq subject.title
expect(subject.draftless_title).to eq subject.title
end
 
it 'does not remove Draft at the end of the title' do
subject.title = 'Something ends with Draft'
 
expect(subject.wipless_title).to eq subject.title
expect(subject.draftless_title).to eq subject.title
end
end
 
describe "#wip_title" do
describe "#draft_title" do
it "adds the Draft: prefix to the title" do
wip_title = "Draft: #{subject.title}"
draft_title = "Draft: #{subject.title}"
 
expect(subject.wip_title).to eq wip_title
expect(subject.draft_title).to eq draft_title
end
 
it "does not add the Draft: prefix multiple times" do
wip_title = "Draft: #{subject.title}"
subject.title = subject.wip_title
subject.title = subject.wip_title
draft_title = "Draft: #{subject.title}"
subject.title = subject.draft_title
subject.title = subject.draft_title
 
expect(subject.wip_title).to eq wip_title
expect(subject.draft_title).to eq draft_title
end
 
it "is satisfies the #work_in_progress? method" do
subject.title = subject.wip_title
subject.title = subject.draft_title
 
expect(subject.work_in_progress?).to eq true
end
Loading
Loading
Loading
Loading
@@ -333,14 +333,14 @@
 
shared_examples 'undraft command' do
it 'returns wip_event: "unwip" if content contains /draft' do
issuable.update!(title: issuable.wip_title)
issuable.update!(title: issuable.draft_title)
_, updates, _ = service.execute(content, issuable)
 
expect(updates).to eq(wip_event: 'unwip')
end
 
it 'returns the unwip message' do
issuable.update!(title: issuable.wip_title)
issuable.update!(title: issuable.draft_title)
_, _, message = service.execute(content, issuable)
 
expect(message).to eq("Unmarked this #{issuable.to_ability_name.humanize(capitalize: false)} as a draft.")
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment