itizawa 5 лет назад
Родитель
Сommit
27bfac1482
2 измененных файлов с 5 добавлено и 7 удалено
  1. 4 0
      src/server/models/page.js
  2. 1 7
      src/test/models/page.test.js

+ 4 - 0
src/server/models/page.js

@@ -706,6 +706,10 @@ module.exports = function(crowi) {
    * find pages that is match with `path` and its descendants whitch user is able to manage
    */
   pageSchema.statics.findManageableListWithDescendants = async function(page, user, option = {}) {
+    if (user == null) {
+      return null;
+    }
+
     const builder = new PageQueryBuilder(this.find());
     builder.addConditionToListWithDescendants(page.path, option);
     builder.addConditionToExcludeRedirect();

+ 1 - 7
src/test/models/page.test.js

@@ -495,13 +495,7 @@ describe('Page', () => {
       const pages = await Page.findManageableListWithDescendants(parentPage, null);
 
       // assert totalCount
-      expect(pages.length).toEqual(2);
-
-      console.log(pages)
-      // assert paths
-      const pagePaths = await pages.map((page) => { return page.path });
-      expect(pagePaths).toContainEqual('/grant/public');
-      expect(pagePaths).toContainEqual('/grant');
+      expect(pages).toBeNull();
     });
   });