Commit 2b33b24a authored by Clement Ho's avatar Clement Ho

Shorten task status phrase

parent c288916d
...@@ -7,6 +7,7 @@ v 8.12.0 (unreleased) ...@@ -7,6 +7,7 @@ v 8.12.0 (unreleased)
- Reduce contributions calendar data payload (ClemMakesApps) - Reduce contributions calendar data payload (ClemMakesApps)
- Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel) - Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel)
- Set path for all JavaScript cookies to honor GitLab's subdirectory setting !5627 (Mike Greiling) - Set path for all JavaScript cookies to honor GitLab's subdirectory setting !5627 (Mike Greiling)
- Shorten task status phrase (ClemMakesApps)
- Add hover color to emoji icon (ClemMakesApps) - Add hover color to emoji icon (ClemMakesApps)
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention) - Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Add `wiki_page_events` to project hook APIs (Ben Boeckel) - Add `wiki_page_events` to project hook APIs (Ben Boeckel)
......
...@@ -52,11 +52,11 @@ module Taskable ...@@ -52,11 +52,11 @@ module Taskable
end end
# Return a string that describes the current state of this Taskable's task # Return a string that describes the current state of this Taskable's task
# list items, e.g. "20 tasks (12 completed, 8 remaining)" # list items, e.g. "12 of 20 tasks completed"
def task_status def task_status
return '' if description.blank? return '' if description.blank?
sum = tasks.summary sum = tasks.summary
"#{sum.item_count} tasks (#{sum.complete_count} completed, #{sum.incomplete_count} remaining)" "#{sum.complete_count} of #{sum.item_count} #{'task'.pluralize(sum.item_count)} completed"
end end
end end
This diff is collapsed.
...@@ -3,30 +3,57 @@ ...@@ -3,30 +3,57 @@
# Requires a context containing: # Requires a context containing:
# subject { Issue or MergeRequest } # subject { Issue or MergeRequest }
shared_examples 'a Taskable' do shared_examples 'a Taskable' do
before do describe 'with multiple tasks' do
subject.description = <<-EOT.strip_heredoc before do
* [ ] Task 1 subject.description = <<-EOT.strip_heredoc
* [x] Task 2 * [ ] Task 1
* [x] Task 3 * [x] Task 2
* [ ] Task 4 * [x] Task 3
* [ ] Task 5 * [ ] Task 4
EOT * [ ] Task 5
EOT
end
it 'returns the correct task status' do
expect(subject.task_status).to match('2 of')
expect(subject.task_status).to match('5 tasks completed')
end
describe '#tasks?' do
it 'returns true when object has tasks' do
expect(subject.tasks?).to eq true
end
it 'returns false when object has no tasks' do
subject.description = 'Now I have no tasks'
expect(subject.tasks?).to eq false
end
end
end end
it 'returns the correct task status' do describe 'with an incomplete task' do
expect(subject.task_status).to match('5 tasks') before do
expect(subject.task_status).to match('2 completed') subject.description = <<-EOT.strip_heredoc
expect(subject.task_status).to match('3 remaining') * [ ] Task 1
EOT
end
it 'returns the correct task status' do
expect(subject.task_status).to match('0 of')
expect(subject.task_status).to match('1 task completed')
end
end end
describe '#tasks?' do describe 'with a complete task' do
it 'returns true when object has tasks' do before do
expect(subject.tasks?).to eq true subject.description = <<-EOT.strip_heredoc
* [x] Task 1
EOT
end end
it 'returns false when object has no tasks' do it 'returns the correct task status' do
subject.description = 'Now I have no tasks' expect(subject.task_status).to match('1 of')
expect(subject.tasks?).to eq false expect(subject.task_status).to match('1 task completed')
end end
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