diff --git a/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql b/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql deleted file mode 100644 index 1fc4e2905..000000000 --- a/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; diff --git a/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql index 6f4cdcc39..1fc4e2905 100644 --- a/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql +++ b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql @@ -1 +1 @@ -ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 'flowersPlants' NULL; +ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 0395e982b..6206eaf1c 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -41,6 +41,7 @@ module.exports = Self => { }; } catch (e) { if (tx) await tx.rollback(); + return params; } }; }; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index b252c4d60..8bf271348 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -1,11 +1,20 @@ const app = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); describe('Supplier newSupplier()', () => { const newSupp = { name: 'TestSupplier-1' }; + const administrativeId = 5; it('should create a new supplier containing only the name', async() => { + const activeCtx = { + accessToken: {userId: administrativeId}, + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + let result = await app.models.Supplier.newSupplier(JSON.stringify(newSupp)); result = result.supplier;