mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-20 09:09:35 +02:00
fix(cases): only refuse the cases folder and its direct children for a custom-folder case
blockedReason() refused every path below a cases directory, with the reason that it is "already listed as a local case". GET /api/cases lists only the direct children of the cases directory, so only those can be registered twice. With CODEMAN_CASES_PATH set to a broad root such as /mnt/user/Scripts, the rule blocked almost the whole tree, including folders that are already linked cases. Refuse the cases directory itself and its direct children only, and name the cases directory in the message.
This commit is contained in:
1 parent
3d59e59e37
commit
2f8e0377ff
3 files changed
+22
-3
No files matched your search
+11
-1
@@ -54,14 +54,24 @@ describe('blockedReason', () => {
|
||||
expect(blockedReason('/usrlocal', c)).toBeNull();
|
||||
});
|
||||
|
||||
it('refuses a cases directory and anything inside it, when given', () => {
|
||||
it('refuses a cases directory and its direct children, when given', () => {
|
||||
const withCases = { ...c, casesDirs: ['/home/u/codeman-cases'] };
|
||||
expect(blockedReason('/home/u/codeman-cases', withCases)).toMatch(/plain Create New/);
|
||||
expect(blockedReason('/home/u/codeman-cases/foo', withCases)).toMatch(/plain Create New/);
|
||||
expect(blockedReason('/home/u/codeman-cases/foo', withCases)).toContain('/home/u/codeman-cases');
|
||||
expect(blockedReason('/home/u/codeman-cases-old/foo', withCases)).toBeNull();
|
||||
expect(blockedReason('/home/u/codeman-cases/foo', c)).toBeNull();
|
||||
});
|
||||
|
||||
it('allows a folder deeper than a direct child of the cases directory (it is not listed as a local case)', () => {
|
||||
// CODEMAN_CASES_PATH can be a broad root such as /mnt/user/Scripts; GET /api/cases lists only its
|
||||
// direct children, so a folder further down can be linked without appearing twice.
|
||||
const broad = { ...c, casesDirs: ['/mnt/user/Scripts'] };
|
||||
expect(blockedReason('/mnt/user/Scripts/GitHub', broad)).toMatch(/plain Create New/);
|
||||
expect(blockedReason('/mnt/user/Scripts/GitHub/opticon454', broad)).toBeNull();
|
||||
expect(blockedReason('/mnt/user/Scripts/GitHub/opticon454/app', broad)).toBeNull();
|
||||
});
|
||||
|
||||
it('judges against the system roots it is given', () => {
|
||||
expect(blockedReason('/private/etc/x', c)).toBeNull();
|
||||
expect(blockedReason('/private/etc/x', c, ['/private/etc'])).toMatch(/system directory/);
|
||||
|
||||
Reference in new issue
Block a user