refs #6641 add button my team #2254
|
@ -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)
|
||||
jcasado marked this conversation as resolved
Outdated
|
||||
VALUES
|
||||
(8, 1, 19);
|
||||
|
|
|
@ -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', {
|
||||
jcasado marked this conversation as resolved
Outdated
alexm
commented
Pq se quita remoteMethodCtx y se pone?
Pq se quita remoteMethod**Ctx** y se pone?
```
{
arg: 'ctx',
type: 'object',
http: {source: 'context'}
},
```
|
||||
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',
|
||||
|
|
|
@ -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};
|
||||
jcasado marked this conversation as resolved
Outdated
alexm
commented
Veo mas como y legible poner en la linea de antes Igual en los otros casos Veo mas como y legible poner en la linea de antes `ctx.args = {search: 1}`
Y luego usar directamente `.. models.Claim.filter(ctx, null, options);`
Igual en los otros casos
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Por seguir la convencion de SQL, añadir tabulaciones