diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f874c8aee..cd7c15dca 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3747,6 +3747,6 @@ INSERT INTO `vn`.`supplierDms`(`supplierFk`, `dmsFk`, `editorFk`) VALUES (1, 10, 9); -INSERT INTO vn.workerTeam -(id, team, workerFk) -VALUES(8, 1, 19); +INSERT INTO vn.workerTeam(id, team, workerFk) + VALUES + (8, 1, 19); diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 56d4fdfed..f60b6572e 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -4,15 +4,10 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethod('filter', { + Self.remoteMethodCtx('filter', { description: 'Find all instances of the model matched by filter from the data source.', accessType: 'READ', accepts: [ - { - arg: 'ctx', - type: 'object', - http: {source: 'context'} - }, { arg: 'filter', type: 'object', diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index 08e680e97..acaa3c527 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); const models = require('vn-loopback/server/server').models; -describe('claim filter()', () => { +fdescribe('claim filter()', () => { let ctx; beforeEach(() => { ctx = { @@ -18,7 +18,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 1}}, null, options); + ctx.args = {search: 1}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(1); @@ -36,7 +37,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 'Tony Stark'}}, null, options); + ctx.args = {search: 'Tony Stark'}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(4); @@ -54,7 +56,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, workerFk: 18}}, null, options); + ctx.args = {workerFk: 18}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(4); expect(result[0].id).toEqual(1); @@ -75,7 +78,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, itemFk: 2}}, null, options); + ctx.args = {itemFk: 2}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(1); @@ -95,7 +99,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, claimResponsibleFk: 7}}, null, options); + ctx.args = {claimResponsibleFk: 7}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(2); @@ -115,8 +120,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const filter = {}; - const result = await models.Claim.filter({...ctx, args: {filter: {}, itemFk: null, myTeam: true}}, filter, options); + ctx.args = {itemFk: null, myTeam: true}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(2);