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
c5205046
Commit
c5205046
authored
Nov 17, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix timeago rendering for environment timeago
parent
18a646c3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
2 deletions
+54
-2
app/assets/javascripts/merge_request_widget.js.es6
app/assets/javascripts/merge_request_widget.js.es6
+1
-1
spec/javascripts/merge_request_widget_spec.js
spec/javascripts/merge_request_widget_spec.js
+53
-1
No files found.
app/assets/javascripts/merge_request_widget.js.es6
View file @
c5205046
...
...
@@ -218,7 +218,7 @@
}
if (environment.deployed_at && environment.deployed_at_formatted) {
environment.deployed_at = gl.utils.getTimeago(
environment.deployed_at
) + '.';
environment.deployed_at = gl.utils.getTimeago(
).format(environment.deployed_at, 'gl_en'
) + '.';
} else {
$('.js-environment-timeago', $template).remove();
environment.name += '.';
...
...
spec/javascripts/merge_request_widget_spec.js
View file @
c5205046
/* eslint-disable space-before-function-paren, quotes, comma-dangle, dot-notation, indent, quote-props, no-var, padded-blocks, max-len */
/*= require merge_request_widget */
/*= require lib/utils/timeago.js */
/*= require lib/utils/timeago */
/*= require lib/utils/datetime_utility */
(
function
()
{
describe
(
'
MergeRequestWidget
'
,
function
()
{
...
...
@@ -54,6 +55,57 @@
});
});
describe
(
'
renderEnvironments
'
,
function
()
{
describe
(
'
should render correct timeago
'
,
function
()
{
beforeEach
(
function
()
{
this
.
environments
=
[{
id
:
'
test-environment-id
'
,
url
:
'
testurl
'
,
deployed_at
:
new
Date
().
toISOString
(),
deployed_at_formatted
:
true
}];
});
function
getTimeagoText
(
template
)
{
var
el
=
document
.
createElement
(
'
html
'
);
el
.
innerHTML
=
template
;
return
el
.
querySelector
(
'
.js-environment-timeago
'
).
innerText
.
trim
();
}
it
(
'
should render less than a minute ago text
'
,
function
()
{
spyOn
(
this
.
class
.
$widgetBody
,
'
before
'
).
and
.
callFake
(
function
(
template
)
{
expect
(
getTimeagoText
(
template
)).
toBe
(
'
less than a minute ago.
'
);
});
this
.
class
.
renderEnvironments
(
this
.
environments
);
});
it
(
'
should render about an hour ago text
'
,
function
()
{
var
oneHourAgo
=
new
Date
();
oneHourAgo
.
setHours
(
oneHourAgo
.
getHours
()
-
1
);
this
.
environments
[
0
].
deployed_at
=
oneHourAgo
.
toISOString
();
spyOn
(
this
.
class
.
$widgetBody
,
'
before
'
).
and
.
callFake
(
function
(
template
)
{
expect
(
getTimeagoText
(
template
)).
toBe
(
'
about an hour ago.
'
);
});
this
.
class
.
renderEnvironments
(
this
.
environments
);
});
it
(
'
should render about 2 hours ago text
'
,
function
()
{
var
twoHoursAgo
=
new
Date
();
twoHoursAgo
.
setHours
(
twoHoursAgo
.
getHours
()
-
2
);
this
.
environments
[
0
].
deployed_at
=
twoHoursAgo
.
toISOString
();
spyOn
(
this
.
class
.
$widgetBody
,
'
before
'
).
and
.
callFake
(
function
(
template
)
{
expect
(
getTimeagoText
(
template
)).
toBe
(
'
about 2 hours ago.
'
);
});
this
.
class
.
renderEnvironments
(
this
.
environments
);
});
});
});
return
describe
(
'
getCIStatus
'
,
function
()
{
beforeEach
(
function
()
{
this
.
ciStatusData
=
{
...
...
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