• 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

19.05
/api/controllers/v1/document-duplicate/create-from-duplicate.js
1
const ErrorService = require('../../../services/ErrorService');
1✔
2
const DocumentService = require('../../../services/DocumentService');
1✔
3
const RightService = require('../../../services/RightService');
1✔
4

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

16
  if (
×
17
    !(await sails.helpers.checkIfExists.with({
18
      attributeName: 'id',
19
      attributeValue: req.param('id'),
20
      sailsModel: TDocumentDuplicate,
21
    }))
22
  ) {
23
    return res.badRequest(
×
24
      `Could not find duplicate with id ${req.param('id')}.`
25
    );
26
  }
27
  const id = req.param('id');
×
28
  const duplicate = await TDocumentDuplicate.findOne(id);
×
29
  const { document, description } = duplicate.content;
×
30
  try {
×
31
    await DocumentService.createDocument(req, document, description);
×
32
    await TDocumentDuplicate.destroyOne(id);
×
33
    return res.ok();
×
34
  } catch (e) {
35
    return ErrorService.getDefaultErrorHandler(res)(e);
×
36
  }
37
};
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