Use the transport's defer method within the client_action to ensure we use the configured promises everywhere. Allow search requests to be made without any arguments.
This commit is contained in:
@ -56,8 +56,5 @@ module.exports = {
|
|||||||
'/{index}/_stats/indexing',
|
'/{index}/_stats/indexing',
|
||||||
'/{index}/_stats/search/{search_groups}',
|
'/{index}/_stats/search/{search_groups}',
|
||||||
'/{index}/_stats/fielddata/{fields}'
|
'/{index}/_stats/fielddata/{fields}'
|
||||||
],
|
|
||||||
'search': [
|
|
||||||
'/_search'
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@ -3086,6 +3086,9 @@ api.search = ca({
|
|||||||
type: 'list'
|
type: 'list'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fmt: '/_search'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
module.exports = ClientAction;
|
module.exports = ClientAction;
|
||||||
|
|
||||||
var _ = require('./utils');
|
var _ = require('./utils');
|
||||||
var when = require('when');
|
|
||||||
|
|
||||||
function ClientAction(spec) {
|
function ClientAction(spec) {
|
||||||
if (!_.isPlainObject(spec.params)) {
|
if (!_.isPlainObject(spec.params)) {
|
||||||
@ -31,7 +30,9 @@ function ClientAction(spec) {
|
|||||||
if (typeof cb === 'function') {
|
if (typeof cb === 'function') {
|
||||||
_.nextTick(cb, e);
|
_.nextTick(cb, e);
|
||||||
} else {
|
} else {
|
||||||
return when.reject(e);
|
var def = this.transport.defer();
|
||||||
|
def.reject(e);
|
||||||
|
return def.promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
test/unit/browser_builds/angular.js
vendored
13
test/unit/browser_builds/angular.js
vendored
@ -56,4 +56,17 @@ describe('Angular esFactory', function () {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('returns an error created by calling a method incorrectly', function (done) {
|
||||||
|
directive(function (esFactory) {
|
||||||
|
return function () {
|
||||||
|
var client = esFactory({ hosts: null });
|
||||||
|
client.get().then(function () {
|
||||||
|
expect.fail('promise should have been rejected');
|
||||||
|
}, function (err) {
|
||||||
|
expect(err.message).to.match(/unable/);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@ -20,6 +20,9 @@ function mockClient() {
|
|||||||
} else {
|
} else {
|
||||||
return when.resolve(params);
|
return when.resolve(params);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
defer: function () {
|
||||||
|
return when.defer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user