Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
2b33b24a
Commit
2b33b24a
authored
Aug 27, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shorten task status phrase
parent
c288916d
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
241 additions
and
93 deletions
+241
-93
CHANGELOG
CHANGELOG
+1
-0
app/models/concerns/taskable.rb
app/models/concerns/taskable.rb
+2
-2
spec/features/task_lists_spec.rb
spec/features/task_lists_spec.rb
+193
-73
spec/support/taskable_shared_examples.rb
spec/support/taskable_shared_examples.rb
+45
-18
No files found.
CHANGELOG
View file @
2b33b24a
...
...
@@ -7,6 +7,7 @@ v 8.12.0 (unreleased)
- Reduce contributions calendar data payload (ClemMakesApps)
- 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)
- Shorten task status phrase (ClemMakesApps)
- Add hover color to emoji icon (ClemMakesApps)
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Add `wiki_page_events` to project hook APIs (Ben Boeckel)
...
...
app/models/concerns/taskable.rb
View file @
2b33b24a
...
...
@@ -52,11 +52,11 @@ module Taskable
end
# 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
return
''
if
description
.
blank?
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
spec/features/task_lists_spec.rb
View file @
2b33b24a
This diff is collapsed.
Click to expand it.
spec/support/taskable_shared_examples.rb
View file @
2b33b24a
...
...
@@ -3,30 +3,57 @@
# Requires a context containing:
# subject { Issue or MergeRequest }
shared_examples
'a Taskable'
do
before
do
subject
.
description
=
<<-
EOT
.
strip_heredoc
* [ ] Task 1
* [x] Task 2
* [x] Task 3
* [ ] Task 4
* [ ] Task 5
EOT
describe
'with multiple tasks'
do
before
do
subject
.
description
=
<<-
EOT
.
strip_heredoc
* [ ] Task 1
* [x] Task 2
* [x] Task 3
* [ ] Task 4
* [ ] 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
it
'returns the correct task status'
do
expect
(
subject
.
task_status
).
to
match
(
'5 tasks'
)
expect
(
subject
.
task_status
).
to
match
(
'2 completed'
)
expect
(
subject
.
task_status
).
to
match
(
'3 remaining'
)
describe
'with an incomplete task'
do
before
do
subject
.
description
=
<<-
EOT
.
strip_heredoc
* [ ] 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
describe
'#tasks?'
do
it
'returns true when object has tasks'
do
expect
(
subject
.
tasks?
).
to
eq
true
describe
'with a complete task'
do
before
do
subject
.
description
=
<<-
EOT
.
strip_heredoc
* [x] Task 1
EOT
end
it
'returns
false when object has no task
s'
do
subject
.
description
=
'Now I have no tasks'
expect
(
subject
.
task
s?
).
to
eq
false
it
'returns
the correct task statu
s'
do
expect
(
subject
.
task_status
).
to
match
(
'1 of'
)
expect
(
subject
.
task
_status
).
to
match
(
'1 task completed'
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment