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
d2a09844
Commit
d2a09844
authored
Nov 16, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Condense time for display in stringifyTime.
parent
79fd521b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
app/assets/javascripts/issuable_time_tracker.js.es6
app/assets/javascripts/issuable_time_tracker.js.es6
+4
-2
spec/javascripts/issuable_time_tracker_spec.js.es6
spec/javascripts/issuable_time_tracker_spec.js.es6
+6
-6
No files found.
app/assets/javascripts/issuable_time_tracker.js.es6
View file @
d2a09844
...
...
@@ -101,9 +101,11 @@
this.displayHelp = show;
},
stringifyTime(obj) {
return _.reduce(obj, (memo, val, key) => {
return memo + `${val}${key.charAt(0)} `;
const reducedTime = _.reduce(obj, (memo, unitValue, unitName) => {
const isNonZero = !!unitValue;
return isNonZero ? (memo + `${unitValue}${unitName.charAt(0)} `) : memo;
}, '').trim();
return reducedTime.length ? reducedTime : '0m';
},
},
template: `
...
...
spec/javascripts/issuable_time_tracker_spec.js.es6
View file @
d2a09844
...
...
@@ -57,14 +57,14 @@ function initComponent(time_estimate = 100000, time_spent = 5000 ) {
it('should display the human readable version of time estimated', function() {
const estimateText = this.timeTracker.$el.querySelector('.time-tracking-pane-compare .estimated .compare-value').innerText;
const correctText = '
0w
3d 3h 46m';
const correctText = '3d 3h 46m';
expect(estimateText).toBe(correctText);
});
it('should display the human readable version of time spent', function() {
const spentText = this.timeTracker.$el.querySelector('.time-tracking-pane-compare .compare-value.spent').innerText;
const correctText = '
0w 0d
1h 23m';
const correctText = '1h 23m';
expect(spentText).toBe(correctText);
});
...
...
@@ -107,7 +107,7 @@ function initComponent(time_estimate = 100000, time_spent = 5000 ) {
it('should display the human readable version of time estimated', function() {
const estimateText = this.timeTracker.$el.querySelector('.time-tracking-estimate-only').innerText;
const correctText = 'Estimated:
0w 0d
2h 46m';
const correctText = 'Estimated: 2h 46m';
expect(estimateText).toBe(correctText);
});
...
...
@@ -127,7 +127,7 @@ function initComponent(time_estimate = 100000, time_spent = 5000 ) {
it('should display the human readable version of time spent', function() {
const spentText = this.timeTracker.$el.querySelector('.time-tracking-spend-only').innerText;
const correctText = 'Spent:
0w 0d
1h 23m';
const correctText = 'Spent: 1h 23m';
expect(spentText).toBe(correctText);
});
...
...
@@ -323,7 +323,7 @@ function initComponent(time_estimate = 100000, time_spent = 5000 ) {
const timeString = this.timeTracker.stringifyTime(timeObject);
expect(timeString).toBe('
0w 4d 0h
20m');
expect(timeString).toBe('
4d
20m');
});
it('should stringify values with no non-zero units', function() {
...
...
@@ -336,7 +336,7 @@ function initComponent(time_estimate = 100000, time_spent = 5000 ) {
const timeString = this.timeTracker.stringifyTime(timeObject);
expect(timeString).toBe('0
w 0d 0h 0
m');
expect(timeString).toBe('0m');
});
});
...
...
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