From 99556057d1639ddda5892e7391587efd390f0d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 26 May 2015 16:48:23 +0200 Subject: [PATCH] Fixed bug with auto refresh option being reset when changing relative time when now delay is configured, Fixes #2042 --- public/app/features/dashboard/timeSrv.js | 2 +- public/test/specs/timeSrv-specs.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/timeSrv.js b/public/app/features/dashboard/timeSrv.js index ef493e07e16..7df83f7fcab 100644 --- a/public/app/features/dashboard/timeSrv.js +++ b/public/app/features/dashboard/timeSrv.js @@ -93,7 +93,7 @@ define([ _.extend(this.time, time); // disable refresh if we have an absolute time - if (time.to !== 'now') { + if (time.to && time.to.indexOf('now') === -1) { this.old_refresh = this.dashboard.refresh || this.old_refresh; this.set_interval(false); } diff --git a/public/test/specs/timeSrv-specs.js b/public/test/specs/timeSrv-specs.js index 231f50afeb8..b62701c2286 100644 --- a/public/test/specs/timeSrv-specs.js +++ b/public/test/specs/timeSrv-specs.js @@ -90,6 +90,12 @@ define([ ctx.service.setTime({from: '2011-01-01', to: 'now' }); expect(_dashboard.refresh).to.be('10s'); }); + + it('should keep refresh after relative time range is changed and now delay exists', function() { + _dashboard.refresh = '10s'; + ctx.service.setTime({from: 'now-1h', to: 'now-10s' }); + expect(_dashboard.refresh).to.be('10s'); + }); }); });