refs #5666 perf: replace Role by VnRole

This commit is contained in:
Javier Segarra 2023-12-05 07:16:12 +01:00
parent 2fe631f078
commit 57add7abf0
5 changed files with 6 additions and 6 deletions

View File

@ -68,7 +68,7 @@ module.exports = Self => {
userToUpdate.hasGrant = hasGrant; userToUpdate.hasGrant = hasGrant;
if (roleFk) { if (roleFk) {
const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions); const role = await models.VnRole.findById(roleFk, {fields: ['name']}, myOptions);
const hasRole = await Self.hasRole(userId, role.name, myOptions); const hasRole = await Self.hasRole(userId, role.name, myOptions);
if (!hasRole) if (!hasRole)

View File

@ -70,7 +70,7 @@ describe('VnUser privileges()', () => {
const tx = await models.VnUser.beginTransaction({}); const tx = await models.VnUser.beginTransaction({});
const options = {transaction: tx}; const options = {transaction: tx};
const agency = await models.Role.findOne({ const agency = await models.VnRole.findOne({
where: { where: {
name: 'agency' name: 'agency'
} }

View File

@ -239,7 +239,7 @@ module.exports = Self => {
// Prepare data // Prepare data
let roles = await $.Role.find({ let roles = await $.VnRole.find({
fields: ['id', 'name', 'description'] fields: ['id', 'name', 'description']
}); });
let roleRoles = await $.RoleRole.find({ let roleRoles = await $.RoleRole.find({

View File

@ -102,7 +102,7 @@ describe('sale canEdit()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const role = await models.Role.findOne({ const role = await models.VnRole.findOne({
where: { where: {
name: roleEnabled.principalId name: roleEnabled.principalId
} }
@ -159,7 +159,7 @@ describe('sale canEdit()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const role = await models.Role.findOne({ const role = await models.VnRole.findOne({
where: { where: {
name: roleEnabled.principalId name: roleEnabled.principalId
} }

View File

@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server');
describe('Worker activeWithInheritedRole', () => { describe('Worker activeWithInheritedRole', () => {
let allRolesCount; let allRolesCount;
beforeAll(async() => { beforeAll(async() => {
allRolesCount = await app.models.Role.count(); allRolesCount = await app.models.VnRole.count();
}); });
it('should return the workers with an inherited role of salesPerson', async() => { it('should return the workers with an inherited role of salesPerson', async() => {