• 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

16.67
/api/controllers/v1/caver/remove-from-group.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const ErrorService = require('../../../services/ErrorService');
1✔
3
const RightService = require('../../../services/RightService');
1✔
4

5
module.exports = async (req, res) => {
1✔
6
  // Check right
7
  const hasRight = RightService.hasGroup(
×
8
    req.token.groups,
9
    RightService.G.ADMINISTRATOR
10
  );
11
  if (!hasRight) {
×
12
    return res.forbidden(
×
13
      'You are not authorized to remove a caver from a group.'
14
    );
15
  }
16

17
  // Check params
18
  if (
×
19
    !(await sails.helpers.checkIfExists.with({
20
      attributeName: 'id',
21
      attributeValue: req.param('caverId'),
22
      sailsModel: TCaver,
23
    }))
24
  ) {
25
    return res.badRequest(
×
26
      `Could not found caver with id ${req.param('caverId')}.`
27
    );
28
  }
29
  const groupId = req.param('groupId');
×
30
  if (
×
31
    !(await sails.helpers.checkIfExists.with({
32
      attributeName: 'id',
33
      attributeValue: groupId,
34
      sailsModel: TGroup,
35
    }))
36
  ) {
37
    return res.badRequest(
×
38
      `Could not found group with id ${req.param('groupId')}.`
39
    );
40
  }
41

42
  // Update caver
43
  try {
×
44
    await TCaver.removeFromCollection(
×
45
      req.param('caverId'),
46
      'groups',
47
      req.param('groupId')
48
    );
49
    const params = {};
×
50
    params.controllerMethod = 'CaverController.removeFromGroup';
×
51
    return ControllerService.treat(req, null, {}, params, res);
×
52
  } catch (e) {
53
    return ErrorService.getDefaultErrorHandler(res)(e);
×
54
  }
55
};
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