aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-12-04 16:47:19 +0100
committerStas Vilchik <vilchiks@gmail.com>2015-12-04 16:47:19 +0100
commitc816f9d8bb9efc1fc3dba9c86be53c942ecb8a93 (patch)
tree1bc72702ebc117e34dfc24890ee12e975f47e2c3 /server
parent45728121b79935c9f30132c8bdd87d09e9c5c3a0 (diff)
downloadsonarqube-c816f9d8bb9efc1fc3dba9c86be53c942ecb8a93.tar.gz
sonarqube-c816f9d8bb9efc1fc3dba9c86be53c942ecb8a93.zip
fix formatting of WORK_DUR measures
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/helpers/measures.js4
-rw-r--r--server/sonar-web/tests/helpers/measures-test.js2
2 files changed, 4 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/helpers/measures.js b/server/sonar-web/src/main/js/helpers/measures.js
index 639a7678266..81bf4454323 100644
--- a/server/sonar-web/src/main/js/helpers/measures.js
+++ b/server/sonar-web/src/main/js/helpers/measures.js
@@ -243,9 +243,9 @@ function durationFormatter (value) {
var hoursInDay = window.SS.hoursInDay,
isNegative = value < 0,
absValue = Math.abs(value);
- var days = Math.round(absValue / hoursInDay / 60);
+ var days = Math.floor(absValue / hoursInDay / 60);
var remainingValue = absValue - days * hoursInDay * 60;
- var hours = Math.round(remainingValue / 60);
+ var hours = Math.floor(remainingValue / 60);
remainingValue -= hours * 60;
return formatDuration(isNegative, days, hours, remainingValue);
}
diff --git a/server/sonar-web/tests/helpers/measures-test.js b/server/sonar-web/tests/helpers/measures-test.js
index 503d6e3214a..cc8e7a4a25c 100644
--- a/server/sonar-web/tests/helpers/measures-test.js
+++ b/server/sonar-web/tests/helpers/measures-test.js
@@ -89,6 +89,7 @@ describe('Measures', function () {
expect(formatMeasure(0, 'WORK_DUR')).to.equal('0');
expect(formatMeasure(5 * ONE_DAY, 'WORK_DUR')).to.equal('5d');
expect(formatMeasure(2 * ONE_HOUR, 'WORK_DUR')).to.equal('2h');
+ expect(formatMeasure(40 * ONE_MINUTE, 'WORK_DUR')).to.equal('40min');
expect(formatMeasure(ONE_MINUTE, 'WORK_DUR')).to.equal('1min');
expect(formatMeasure(5 * ONE_DAY + 2 * ONE_HOUR, 'WORK_DUR')).to.equal('5d 2h');
expect(formatMeasure(2 * ONE_HOUR + ONE_MINUTE, 'WORK_DUR')).to.equal('2h 1min');
@@ -103,6 +104,7 @@ describe('Measures', function () {
expect(formatMeasure(0, 'SHORT_WORK_DUR')).to.equal('0');
expect(formatMeasure(5 * ONE_DAY, 'SHORT_WORK_DUR')).to.equal('5d');
expect(formatMeasure(2 * ONE_HOUR, 'SHORT_WORK_DUR')).to.equal('2h');
+ expect(formatMeasure(40 * ONE_MINUTE, 'SHORT_WORK_DUR')).to.equal('40min');
expect(formatMeasure(ONE_MINUTE, 'SHORT_WORK_DUR')).to.equal('1min');
expect(formatMeasure(5 * ONE_DAY + 2 * ONE_HOUR, 'SHORT_WORK_DUR')).to.equal('5d');
expect(formatMeasure(2 * ONE_HOUR + ONE_MINUTE, 'SHORT_WORK_DUR')).to.equal('2h');