• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GrottoCenter / grottocenter-api / 5631056675

pending completion
5631056675

push

github

vmarseguerra
refactor(right): replaces rights with a static groups system

751 of 1944 branches covered (38.63%)

Branch coverage included in aggregate %.

59 of 59 new or added lines in 35 files covered. (100.0%)

2702 of 5007 relevant lines covered (53.96%)

14.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.27
/api/controllers/v1/document-duplicate/find-all.js
1
const ErrorService = require('../../../services/ErrorService');
1✔
2
const ControllerService = require('../../../services/ControllerService');
1✔
3
const RightService = require('../../../services/RightService');
1✔
4
const { toListFromController } = require('../../../services/mapping/utils');
1✔
5
const { toDocumentDuplicate } = require('../../../services/mapping/converters');
1✔
6

7
module.exports = async (req, res) => {
1✔
8
  const hasRight = RightService.hasGroup(
×
9
    req.token.groups,
10
    RightService.G.MODERATOR
11
  );
12
  if (!hasRight) {
×
13
    return res.forbidden(
×
14
      'You are not authorized to find all documents duplicate.'
15
    );
16
  }
17

18
  const sort = `${req.param('sortBy', 'dateInscription')} ${req.param(
×
19
    'orderBy',
20
    'ASC'
21
  )}`;
22
  const limit = req.param('limit', 50);
×
23
  const skip = req.param('skip', 0);
×
24
  try {
×
25
    const duplicates = await TDocumentDuplicate.find()
×
26
      .skip(skip)
27
      .limit(limit)
28
      .sort(sort)
29
      .populate('author');
30
    const totalNb = await TDocumentDuplicate.count();
×
31

32
    const params = {
×
33
      controllerMethod: 'DocumentDuplicateController.findAll',
34
      limit,
35
      searchedItem: 'Document duplicates',
36
      skip,
37
      total: totalNb,
38
      url: req.originalUrl,
39
    };
40

41
    return ControllerService.treatAndConvert(
×
42
      req,
43
      null,
44
      duplicates,
45
      params,
46
      res,
47
      (data) => toListFromController('duplicates', data, toDocumentDuplicate)
×
48
    );
49
  } catch (err) {
50
    ErrorService.getDefaultErrorHandler(res)(err);
×
51
    return false;
×
52
  }
53
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc