Merge remote-tracking branch 'jbudz/lint-ignore' into testDiscover

This commit is contained in:
LeeDr 2015-11-13 10:46:33 -06:00
commit db95e52886
6 changed files with 28 additions and 6 deletions

View file

@ -1,3 +1,4 @@
src/fixtures
test/fixtures/scenarios
optimize
test/fixtures/scenarios

View file

@ -45,7 +45,8 @@ module.exports = function (grunt) {
'<%= root %>/tasks/**/*.js',
'<%= root %>/test/**/*.js',
'<%= src %>/**/*.js',
'!<%= src %>/fixtures/**/*.js'
'!<%= src %>/fixtures/**/*.js',
'!<%= root %>/test/fixtures/scenarios/**/*.js'
],
deepModules: {
'caniuse-db': '1.0.30000265',

View file

@ -3,6 +3,7 @@ describe('ui/index_patterns/_calculate_indices', () => {
const sinon = require('auto-release-sinon');
const expect = require('expect.js');
const ngMock = require('ngMock');
const moment = require('moment');
let Promise;
let $rootScope;
@ -38,7 +39,7 @@ describe('ui/index_patterns/_calculate_indices', () => {
function run({ start = undefined, stop = undefined } = {}) {
calculateIndices('wat-*-no', '@something', start, stop);
$rootScope.$apply();
config = _.first(es.fieldStats.firstCall.args);
config = _.first(es.fieldStats.lastCall.args);
constraints = config.body.index_constraints;
}
@ -68,6 +69,14 @@ describe('ui/index_patterns/_calculate_indices', () => {
it('max_value is gte', () => {
expect(constraints['@something'].max_value).to.have.property('gte');
});
it('max_value is set to original if not a moment object', () => {
expect(constraints['@something'].max_value.gte).to.equal('1234567890');
});
it('max_value is set to moment.valueOf if given a moment object', () => {
const start = moment();
run({ start });
expect(constraints['@something'].max_value.gte).to.equal(start.valueOf());
});
});
context('when given stop', () => {
@ -78,6 +87,14 @@ describe('ui/index_patterns/_calculate_indices', () => {
it('min_value is lte', () => {
expect(constraints['@something'].min_value).to.have.property('lte');
});
it('min_value is set to original if not a moment object', () => {
expect(constraints['@something'].min_value.lte).to.equal('1234567890');
});
it('max_value is set to moment.valueOf if given a moment object', () => {
const stop = moment();
run({ stop });
expect(constraints['@something'].min_value.lte).to.equal(stop.valueOf());
});
});
});

View file

@ -2,6 +2,11 @@ define(function (require) {
const _ = require('lodash');
const moment = require('moment');
// gets parsed value if given arg is a moment object
function timeValue(val) {
return moment.isMoment(val) ? val.valueOf() : val;
}
return function CalculateIndicesFactory(Promise, es) {
// Uses the field stats api to determine the names of indices that need to
@ -17,10 +22,10 @@ define(function (require) {
function getFieldStats(pattern, timeFieldName, start, stop) {
const constraints = {};
if (start) {
constraints.max_value = { gte: moment(start).valueOf() };
constraints.max_value = { gte: timeValue(start) };
}
if (stop) {
constraints.min_value = { lte: moment(stop).valueOf() };
constraints.min_value = { lte: timeValue(stop) };
}
return es.fieldStats({

View file

@ -1,4 +1,3 @@
/*eslint-disable*/
module.exports = [{
'index': {
'_index': 'logstash-2015.09.17',

View file

@ -1,4 +1,3 @@
/*eslint-disable*/
module.exports = [{
'index': {
'_index': 'logstash-2015.09.18',