mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix: merge acl action params appends bug
This commit is contained in:
parent
4d10946a2e
commit
516de92ee2
@ -397,6 +397,34 @@ describe('multiple roles merge', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
test('should union appends(params={ appends: [a,b]}) when appends = [a,b], appends =[]', () => {
|
||||||
|
acl.setAvailableAction('update');
|
||||||
|
acl.define({
|
||||||
|
role: 'role1',
|
||||||
|
actions: {
|
||||||
|
'posts:update': {
|
||||||
|
appends: ['a', 'b'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
acl.define({
|
||||||
|
role: 'role2',
|
||||||
|
actions: {
|
||||||
|
'posts:update': {
|
||||||
|
appends: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const canResult = acl.can({ resource: 'posts', action: 'update', roles: ['role1', 'role2'] });
|
||||||
|
expect(canResult).toStrictEqual({
|
||||||
|
role: 'role1',
|
||||||
|
resource: 'posts',
|
||||||
|
action: 'update',
|
||||||
|
params: {
|
||||||
|
appends: expect.arrayContaining(['a', 'b']),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('filter & fields merge', () => {
|
describe('filter & fields merge', () => {
|
||||||
|
@ -184,7 +184,7 @@ export function mergeAclActionParams(sourceParams, targetParams) {
|
|||||||
},
|
},
|
||||||
fields: andMerge,
|
fields: andMerge,
|
||||||
whitelist: andMerge,
|
whitelist: andMerge,
|
||||||
appends: andMerge,
|
appends: 'union',
|
||||||
});
|
});
|
||||||
removeEmptyParams(mergedParams);
|
removeEmptyParams(mergedParams);
|
||||||
return mergedParams;
|
return mergedParams;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user