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
b46d8405
Commit
b46d8405
authored
Sep 03, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ddb35e2c
bc26349b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
5 deletions
+34
-5
app/serializers/entity_date_helper.rb
app/serializers/entity_date_helper.rb
+7
-5
changelogs/unreleased/62591-fix-milestone-due-date-today-wording.yml
...unreleased/62591-fix-milestone-due-date-today-wording.yml
+5
-0
spec/serializers/entity_date_helper_spec.rb
spec/serializers/entity_date_helper_spec.rb
+22
-0
No files found.
app/serializers/entity_date_helper.rb
View file @
b46d8405
...
...
@@ -46,12 +46,14 @@ module EntityDateHelper
# If start date is provided and elapsed, with no due date, it returns "# days elapsed"
def
remaining_days_in_words
(
due_date
,
start_date
=
nil
)
if
due_date
&
.
past?
content_tag
(
:strong
,
'Past due'
)
content_tag
(
:strong
,
_
(
'Past due'
))
elsif
due_date
&
.
today?
content_tag
(
:strong
,
_
(
'Today'
))
elsif
start_date
&
.
future?
content_tag
(
:strong
,
'Upcoming'
)
content_tag
(
:strong
,
_
(
'Upcoming'
)
)
elsif
due_date
is_upcoming
=
(
due_date
-
Date
.
today
).
to_i
>
0
time_ago
=
time_ago_in_words
(
due_date
)
time_ago
=
distance_of_time_in_words
(
due_date
,
Date
.
today
)
# https://gitlab.com/gitlab-org/gitlab-ce/issues/49440
#
...
...
@@ -59,8 +61,8 @@ module EntityDateHelper
# of the string instead of piecewise translations.
content
=
time_ago
.
gsub
(
/\d+/
)
{
|
match
|
"<strong>
#{
match
}
</strong>"
}
.
remove
(
"about "
)
remaining_or_ago
=
is_upcoming
?
_
(
"remaining"
)
:
_
(
"ago"
)
.
remove
(
'about '
)
remaining_or_ago
=
is_upcoming
?
_
(
'remaining'
)
:
_
(
'ago'
)
"
#{
content
}
#{
remaining_or_ago
}
"
.
html_safe
elsif
start_date
&
.
past?
...
...
changelogs/unreleased/62591-fix-milestone-due-date-today-wording.yml
0 → 100644
View file @
b46d8405
---
title
:
Fix wording on milestone due date when milestone is due today
merge_request
:
32096
author
:
type
:
changed
spec/serializers/entity_date_helper_spec.rb
View file @
b46d8405
...
...
@@ -57,6 +57,28 @@ describe EntityDateHelper do
end
end
context
'when milestone due date is today'
do
let
(
:milestone_remaining
)
{
date_helper_class
.
remaining_days_in_words
(
Date
.
today
)
}
it
'returns today'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>Today</strong>"
)
end
end
context
'when milestone due date is tomorrow'
do
let
(
:milestone_remaining
)
{
date_helper_class
.
remaining_days_in_words
(
Date
.
tomorrow
)
}
it
'returns 1 day remaining'
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>1</strong> day remaining"
)
end
it
'returns 1 day remaining when queried mid-day'
do
Timecop
.
freeze
(
Time
.
utc
(
2017
,
3
,
17
,
13
,
10
))
do
expect
(
milestone_remaining
).
to
eq
(
"<strong>1</strong> day remaining"
)
end
end
end
context
'when less than 1 year and more than 30 days remaining'
do
let
(
:milestone_remaining
)
{
date_helper_class
.
remaining_days_in_words
(
2
.
months
.
from_now
.
utc
.
to_date
)
}
...
...
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