Use case-insensitive matches for tasks

Valid task list completion can be recorded as `[x]` or `[X]`. The former
is more common, as it's what happens when you click the checkbox in the
UI, but the latter is valid too and can come from a manual edit.

The merge request validator should consider both as checked
tasks. Otherwise, it's wrong, and the error messages are very confusing.
parent 40c5c340
......@@ -20,11 +20,11 @@ module ReleaseTools
# * [ ] Task name here
# - [x] Task name here
# * [x] Task name here
ALL_TASKS = /(\*|-)\s*\[(\s+|x)\]/.freeze
ALL_TASKS = /(\*|-)\s*\[(\s+|[xX])\]/.freeze
# A regular expression to use to determine if the merge request was
# assigned to a reviewer.
APPROVED_TASK = /-\s*\[x\]\s*Assign to a reviewer/.freeze
APPROVED_TASK = /-\s*\[[xX]\]\s*Assign to a reviewer/.freeze
# A regular expression used to determine if the target branch of a merge
# request is valid.
......
......@@ -199,7 +199,7 @@ describe ReleaseTools::Security::MergeRequestValidator do
end
it 'does not add an error when at least one task is present' do
merge_request = double(:merge_request, description: '- [ ] Foo')
merge_request = double(:merge_request, description: '- [X] Foo')
client = double(:client)
validator = described_class.new(merge_request, client)
......@@ -232,6 +232,18 @@ describe ReleaseTools::Security::MergeRequestValidator do
expect(validator.errors).to be_empty
end
it 'does not add an error when the merge request is reviewed using a manual edit' do
merge_request =
double(:merge_request, description: '- [X] Assign to a reviewer')
client = double(:client)
validator = described_class.new(merge_request, client)
validator.validate_reviewed
expect(validator.errors).to be_empty
end
end
describe '#validate_target_branch' 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