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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6924b4d3
Commit
6924b4d3
authored
Mar 16, 2017
by
Michael
Committed by
Rémy Coutable
Mar 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue milestone remaining time tooltip
parent
774e0e3b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
7 deletions
+83
-7
app/helpers/milestones_helper.rb
app/helpers/milestones_helper.rb
+5
-4
changelogs/unreleased/chore-23493-remaining-time-tooltip.yml
changelogs/unreleased/chore-23493-remaining-time-tooltip.yml
+5
-0
spec/helpers/milestones_helper_spec.rb
spec/helpers/milestones_helper_spec.rb
+50
-0
spec/models/concerns/milestoneish_spec.rb
spec/models/concerns/milestoneish_spec.rb
+23
-3
No files found.
app/helpers/milestones_helper.rb
View file @
6924b4d3
...
...
@@ -82,12 +82,13 @@ module MilestonesHelper
def
milestone_remaining_days
(
milestone
)
if
milestone
.
expired?
content_tag
(
:strong
,
'Past due'
)
elsif
milestone
.
due_date
days
=
milestone
.
remaining_days
content
=
content_tag
(
:strong
,
days
)
content
<<
"
#{
'day'
.
pluralize
(
days
)
}
remaining"
elsif
milestone
.
upcoming?
content_tag
(
:strong
,
'Upcoming'
)
elsif
milestone
.
due_date
time_ago
=
time_ago_in_words
(
milestone
.
due_date
)
content
=
time_ago
.
gsub
(
/\d+/
)
{
|
match
|
"<strong>
#{
match
}
</strong>"
}
content
.
slice!
(
"about "
)
content
<<
" remaining"
elsif
milestone
.
start_date
&&
milestone
.
start_date
.
past?
days
=
milestone
.
elapsed_days
content
=
content_tag
(
:strong
,
days
)
...
...
changelogs/unreleased/chore-23493-remaining-time-tooltip.yml
0 → 100644
View file @
6924b4d3
---
title
:
Added remaining_time method to milestoneish, specs and updated the milestone_helper
milestone_remaining_days method to correctly return the correct remaining time.
merge_request
:
author
:
Michael Robinson
spec/helpers/milestones_helper_spec.rb
View file @
6924b4d3
...
...
@@ -47,4 +47,54 @@ describe MilestonesHelper do
end
end
end
describe
'#milestone_remaining_days'
do
context
'when less than 31 days remaining'
do
let
(
:milestone_remaining
)
{
milestone_remaining_days
(
build_stubbed
(
:milestone
,
due_date:
12
.
days
.
from_now
))
}
it
'returns days remaining'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>11</strong> days remaining"
)
end
end
context
'when less than 1 year and more than 30 days remaining'
do
let
(
:milestone_remaining
)
{
milestone_remaining_days
(
build_stubbed
(
:milestone
,
due_date:
2
.
months
.
from_now
))
}
it
'returns months remaining'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>2</strong> months remaining"
)
end
end
context
'when more than 1 year remaining'
do
let
(
:milestone_remaining
)
{
milestone_remaining_days
(
build_stubbed
(
:milestone
,
due_date:
1
.
year
.
from_now
+
2
.
days
))
}
it
'returns years remaining'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>1</strong> year remaining"
)
end
end
context
'when milestone is expired'
do
let
(
:milestone_remaining
)
{
milestone_remaining_days
(
build_stubbed
(
:milestone
,
due_date:
2
.
days
.
ago
))
}
it
'returns "Past due"'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>Past due</strong>"
)
end
end
context
'when milestone has start_date in the future'
do
let
(
:milestone_remaining
)
{
milestone_remaining_days
(
build_stubbed
(
:milestone
,
start_date:
2
.
days
.
from_now
))
}
it
'returns "Upcoming"'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>Upcoming</strong>"
)
end
end
context
'when milestone has start_date in the past'
do
let
(
:milestone_remaining
)
{
milestone_remaining_days
(
build_stubbed
(
:milestone
,
start_date:
2
.
days
.
ago
))
}
it
'returns days elapsed'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>2</strong> days elapsed"
)
end
end
end
end
spec/models/concerns/milestoneish_spec.rb
View file @
6924b4d3
...
...
@@ -116,21 +116,41 @@ describe Milestone, 'Milestoneish' do
end
end
describe
'#remaining_days'
do
it
'shows 0 if no due date'
do
milestone
=
build_stubbed
(
:milestone
)
expect
(
milestone
.
remaining_days
).
to
eq
(
0
)
end
it
'shows 0 if expired'
do
milestone
=
build_stubbed
(
:milestone
,
due_date:
2
.
days
.
ago
)
expect
(
milestone
.
remaining_days
).
to
eq
(
0
)
end
it
'shows correct remaining days'
do
milestone
=
build_stubbed
(
:milestone
,
due_date:
2
.
days
.
from_now
)
expect
(
milestone
.
remaining_days
).
to
eq
(
2
)
end
end
describe
'#elapsed_days'
do
it
'shows 0 if no start_date set'
do
milestone
=
build
(
:milestone
)
milestone
=
build
_stubbed
(
:milestone
)
expect
(
milestone
.
elapsed_days
).
to
eq
(
0
)
end
it
'shows 0 if start_date is a future'
do
milestone
=
build
(
:milestone
,
start_date:
Time
.
now
+
2
.
days
)
milestone
=
build
_stubbed
(
:milestone
,
start_date:
Time
.
now
+
2
.
days
)
expect
(
milestone
.
elapsed_days
).
to
eq
(
0
)
end
it
'shows correct amount of days'
do
milestone
=
build
(
:milestone
,
start_date:
Time
.
now
-
2
.
days
)
milestone
=
build
_stubbed
(
:milestone
,
start_date:
Time
.
now
-
2
.
days
)
expect
(
milestone
.
elapsed_days
).
to
eq
(
2
)
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