Commit afef4019 authored by rlacko's avatar rlacko 💬
Browse files

Attendance docs

parent 97681a93
Pipeline #4724 passed with stages
in 2 minutes and 1 second
......@@ -107,7 +107,7 @@ components:
items:
type: string
description: cuid of each attendance
comment:
comments:
type: array
items:
type: string
......
......@@ -42,7 +42,9 @@ describe('/group "Mentor" Functionality', () => {
// GET One
test(`GET returns with allowed keys`, async () => {
const newAttendance = await Attendance.create(fakeAttendanceJson)
let response = await authSession.get(`${endpointUrl}/${newAttendance._id}`)
let response = await authSession.get(
`${endpointUrl}/id/${newAttendance._id}`
)
expect(response.statusCode).toBe(200)
validateKeys(response.body.data, defaultKeys)
})
......@@ -71,7 +73,7 @@ describe('/group "Mentor" Functionality', () => {
test(`Delete group returns with allowed keys`, async () => {
const newAttendance = await Attendance.create(fakeAttendanceJson)
let response = await authSession.delete(
`${endpointUrl}/${newAttendance._id}`
`${endpointUrl}/id/${newAttendance._id}`
)
expect(response.statusCode).toBe(200)
validateKeys(response.body.data, defaultKeys)
......@@ -80,7 +82,7 @@ describe('/group "Mentor" Functionality', () => {
test(`Update group returns with allowed keys`, async () => {
const newAttendance = await Attendance.create(fakeAttendanceJson)
let response = await authSession
.put(`${endpointUrl}/${newAttendance._id}`)
.put(`${endpointUrl}/id/${newAttendance._id}`)
.send({
state: 'present',
})
......
......@@ -11,13 +11,28 @@ const fakeAttendanceJson = {
}
describe('/attendance Permission tests', () => {
crudPermTest(
app,
endpointUrl + '/id',
Attendance,
'attendance',
fakeAttendanceJson,
[false, false, true, true, true],
[
// [role, create, readAll, readOne, update, delete]
['none', false, false, false, false, false],
['normal', false, false, false, false, false],
['accepted', false, false, false, false, false],
['mentor', true, true, true, true, true],
]
)
crudPermTest(
app,
endpointUrl,
Attendance,
'attendance',
fakeAttendanceJson,
[true, true, true, true, true],
[true, true, false, false, false],
[
// [role, create, readAll, readOne, update, delete]
['none', false, false, false, false, false],
......
openapi: '3.0.2'
info:
title: 'Attendance Endpoint'
version: '1.0'
paths:
/attendance:
get:
tags:
- 'Attendance'
summary: 'Get a List of attendances'
description: 'Have to be mentor for this.'
operationId: 'getAllAttendance'
responses:
'200':
description: OK
content:
application/json:
schema:
type: 'array'
items:
$ref: '#/components/schemas/Attendance'
post:
tags:
- 'Attendance'
summary: 'Create an attendance'
description: 'Have to be mentor for this.'
operationId: 'createAttendance'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Attendance'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Attendance'
/attendance/id/{id}:
get:
tags:
- 'Attendance'
summary: 'Get an attendance by ID'
description: 'Have to be mentor for this.'
operationId: 'getAttendance'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Attendance'
put:
tags:
- 'Attendance'
summary: 'Update an attendance by ID'
description: 'Only mentors can update an attendance.'
operationId: 'updateOneAttendance'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Attendance'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Attendance'
delete:
tags:
- 'Attendance'
summary: 'Delete an attendance by ID'
description: 'Only mentors can delete an attendance.'
operationId: 'deleteAttendance'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Attendance'
components:
schemas:
Attendance:
type: object
properties:
activity:
type: string
description: cuid of each attendance
user:
type: string
description: schacc of the user
state:
type: string
enum:
- absent
- present
- cantcome
default: absent
comments:
type: array
items:
type: string
description: cuid of each comment
required:
- activity
- user
- state
......@@ -4,15 +4,15 @@ const { isLoggedIn, isMentor } = require('../../middlewares/auth')
const router = Router()
// /api/item
// /api/v1/attendance/
router
.route('/')
.get(isLoggedIn, isMentor, controllers.getMany)
.post(isLoggedIn, isMentor, controllers.createOne)
// /api/item/:id
// /api/v1/attendance/id/:id
router
.route('/:id')
.route('/id/:id')
.get(isLoggedIn, isMentor, controllers.getOne)
.put(isLoggedIn, isMentor, controllers.updateOne)
.delete(isLoggedIn, isMentor, controllers.removeOne)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment