diff --git a/scripts/generate/aliases_0_90.js b/scripts/generate/aliases_0_90.js index 4ab98a39f..a65b081c9 100644 --- a/scripts/generate/aliases_0_90.js +++ b/scripts/generate/aliases_0_90.js @@ -56,8 +56,5 @@ module.exports = { '/{index}/_stats/indexing', '/{index}/_stats/search/{search_groups}', '/{index}/_stats/fielddata/{fields}' - ], - 'search': [ - '/_search' ] }; \ No newline at end of file diff --git a/src/lib/apis/0_90.js b/src/lib/apis/0_90.js index bfe34b5b4..991410710 100644 --- a/src/lib/apis/0_90.js +++ b/src/lib/apis/0_90.js @@ -3086,6 +3086,9 @@ api.search = ca({ type: 'list' } } + }, + { + fmt: '/_search' } ], method: 'POST' diff --git a/src/lib/client_action.js b/src/lib/client_action.js index f3e85b3f6..b6db6bbd7 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -5,7 +5,6 @@ module.exports = ClientAction; var _ = require('./utils'); -var when = require('when'); function ClientAction(spec) { if (!_.isPlainObject(spec.params)) { @@ -31,7 +30,9 @@ function ClientAction(spec) { if (typeof cb === 'function') { _.nextTick(cb, e); } else { - return when.reject(e); + var def = this.transport.defer(); + def.reject(e); + return def.promise; } } } diff --git a/test/unit/browser_builds/angular.js b/test/unit/browser_builds/angular.js index 6e07cc5d0..7a512fffb 100644 --- a/test/unit/browser_builds/angular.js +++ b/test/unit/browser_builds/angular.js @@ -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(); + }); + }; + }); + }); }); \ No newline at end of file diff --git a/test/unit/specs/client_action.js b/test/unit/specs/client_action.js index a9129ab2a..1980c1a49 100644 --- a/test/unit/specs/client_action.js +++ b/test/unit/specs/client_action.js @@ -20,6 +20,9 @@ function mockClient() { } else { return when.resolve(params); } + }, + defer: function () { + return when.defer(); } } };