From 5cec936128c782c81f634056b648a953c412167e Mon Sep 17 00:00:00 2001 From: Mark Bell Date: Fri, 24 Oct 2014 14:51:45 -0400 Subject: [PATCH] When get_data fails the legend should be cleared --- src/app/panels/graph/module.js | 1 + src/test/specs/graph-ctrl-specs.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 54a2a028fe6..87098a2d4d7 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -203,6 +203,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries) { $scope.panelMeta.loading = false; $scope.panelMeta.error = err.message || "Timeseries data request error"; $scope.inspector.error = err; + $scope.legend = []; $scope.render([]); }); }; diff --git a/src/test/specs/graph-ctrl-specs.js b/src/test/specs/graph-ctrl-specs.js index e1ddcbc571e..b2cf60d5d5d 100644 --- a/src/test/specs/graph-ctrl-specs.js +++ b/src/test/specs/graph-ctrl-specs.js @@ -36,6 +36,20 @@ define([ var data = ctx.scope.render.getCall(0).args[0]; expect(data.length).to.be(2); }); + + describe('get_data failure following success', function() { + beforeEach(function() { + ctx.datasource.query = sinon.stub().returns(ctx.$q.reject('Datasource Error')); + ctx.scope.get_data(); + ctx.scope.$digest(); + }); + + it('should clear the legend data', function() { + expect(ctx.scope.legend).to.eql([]); + }); + + }); + }); });