Merge pull request #2410 from automatisch/bug-fix-owned-flows-folder
fix: Filtered flows by only owned with null folder id
This commit is contained in:
@@ -553,9 +553,11 @@ class User extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (folderId === 'null') {
|
if (folderId === 'null') {
|
||||||
builder
|
builder.where((builder) => {
|
||||||
.whereNull('flows.folder_id')
|
builder
|
||||||
.orWhereNotIn('flows.folder_id', ownedFolderIds);
|
.whereNull('flows.folder_id')
|
||||||
|
.orWhereNotIn('flows.folder_id', ownedFolderIds);
|
||||||
|
});
|
||||||
} else if (folderId) {
|
} else if (folderId) {
|
||||||
builder.where('flows.folder_id', folderId);
|
builder.where('flows.folder_id', folderId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1186,6 +1186,7 @@ describe('User model', () => {
|
|||||||
currentUserRole,
|
currentUserRole,
|
||||||
anotherUser,
|
anotherUser,
|
||||||
folder,
|
folder,
|
||||||
|
anotherUserFolder,
|
||||||
flowOne,
|
flowOne,
|
||||||
flowTwo,
|
flowTwo,
|
||||||
flowThree;
|
flowThree;
|
||||||
@@ -1197,7 +1198,7 @@ describe('User model', () => {
|
|||||||
anotherUser = await createUser();
|
anotherUser = await createUser();
|
||||||
|
|
||||||
folder = await createFolder({ userId: currentUser.id });
|
folder = await createFolder({ userId: currentUser.id });
|
||||||
await createFolder({ userId: anotherUser.id });
|
anotherUserFolder = await createFolder({ userId: anotherUser.id });
|
||||||
|
|
||||||
flowOne = await createFlow({
|
flowOne = await createFlow({
|
||||||
userId: currentUser.id,
|
userId: currentUser.id,
|
||||||
@@ -1215,6 +1216,7 @@ describe('User model', () => {
|
|||||||
flowThree = await createFlow({
|
flowThree = await createFlow({
|
||||||
userId: anotherUser.id,
|
userId: anotherUser.id,
|
||||||
name: 'Flow Three',
|
name: 'Flow Three',
|
||||||
|
folderId: anotherUserFolder.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
await createPermission({
|
await createPermission({
|
||||||
@@ -1268,6 +1270,16 @@ describe('User model', () => {
|
|||||||
expect(flows[1].id).toBe(flowTwo.id);
|
expect(flows[1].id).toBe(flowTwo.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return flows filtered by onlyOwnedFlows with null folderId', async () => {
|
||||||
|
const flows = await currentUser.getFlows(
|
||||||
|
{ onlyOwnedFlows: true, folderId: 'null' },
|
||||||
|
[folder.id]
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(flows).toHaveLength(1);
|
||||||
|
expect(flows[0].id).toBe(flowTwo.id);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return flows with specific folder ID', async () => {
|
it('should return flows with specific folder ID', async () => {
|
||||||
const flows = await currentUser.getFlows({ folderId: folder.id }, [
|
const flows = await currentUser.getFlows({ folderId: folder.id }, [
|
||||||
folder.id,
|
folder.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user