Commit 200cbed5 authored by Albert Salim's avatar Albert Salim

Fix bug on MR title ending with `wip`/`draft`

MR title ending with `wip` or `draft` should not
be marked as draft MR.

Similarly, these MR titles should not have
`wip`/`draft` words removed.
parent 273691f7
......@@ -385,11 +385,11 @@ module Gitlab
end
def merge_request_wip
/(?i)(\[WIP\]\s*|WIP:\s*|WIP$)/
/(?i)(\[WIP\]\s*|WIP:\s*|\AWIP\z)/
end
def merge_request_draft
/(?i)(\[draft\]|\(draft\)|draft:|draft\s\-\s|draft$)/
/\A(?i)(\[draft\]|\(draft\)|draft:|draft\s\-\s|draft\z)/
end
def issue
......
......@@ -1353,6 +1353,24 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect(subject.work_in_progress?).to eq false
end
it 'does not detect Draft: in the middle of the title' do
subject.title = 'Something with Draft: in the middle'
expect(subject.work_in_progress?).to eq false
end
it 'does not detect WIP at the end of the title' do
subject.title = 'Something ends with WIP'
expect(subject.work_in_progress?).to eq false
end
it 'does not detect Draft at the end of the title' do
subject.title = 'Something ends with Draft'
expect(subject.work_in_progress?).to eq false
end
it "doesn't detect WIP for words starting with WIP" do
subject.title = "Wipwap #{subject.title}"
expect(subject.work_in_progress?).to eq false
......@@ -1363,6 +1381,11 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect(subject.work_in_progress?).to eq false
end
it "doesn't detect draft for words containing with draft" do
subject.title = "Drafting #{subject.title}"
expect(subject.work_in_progress?).to eq false
end
it "doesn't detect WIP by default" do
expect(subject.work_in_progress?).to eq false
end
......@@ -1393,6 +1416,42 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect(subject.work_in_progress?).to eq false
end
end
it 'removes only WIP prefix from the MR title' do
subject.title = 'WIP: Implement feature called WIP'
expect(subject.wipless_title).to eq 'Implement feature called WIP'
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'
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
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
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
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
end
end
describe "#wip_title" do
......
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