Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions models/committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default sequelize.define('committees', {
return {
include: [{
model: Officer.scope({ method: ['active', date] }),
attributes: [],
includeIgnoreAttributes: false,
}],
};
},
Expand Down
53 changes: 38 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions routes/committees.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ router
Committee
.scope(scopes)
.findAndCountAll()
.then(result => res.send({
total: result.count,
perPage: req.query.perPage,
currentPage: req.query.page,
data: result.rows.map((committee) => {
.then(result => {
const uniqueCommittees = {};
result.rows.forEach((committee) => {
const c = committee.get({ plain: true });
Reflect.deleteProperty(c, 'officer');
return c;
}),
}))
uniqueCommittees[c.name] = c;
});
return res.send({
total: Object.keys(uniqueCommittees).length,
perPage: req.query.perPage,
currentPage: req.query.page,
data: Object.values(uniqueCommittees),
})
})
.catch(err => next(err));
});

Expand Down
2 changes: 1 addition & 1 deletion routes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ router
}
})
.post(needs('events', 'create'), (req, res, next) => {
Event.create(req.body, { fields: ['name', 'startDate', 'endDate', 'description', 'location', 'image', 'committeeName'] })
Event.create(req.body, { fields: ['name', 'startDate', 'endDate', 'description', 'location', 'link', 'image', 'committeeName'] })
.then(event => res.status(201).send(event))
.catch((err) => {
err.status = 422;
Expand Down
25 changes: 10 additions & 15 deletions test/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,54 @@ import { token } from '../helpers';

describe('INTEGRATION TESTS: AUTH', function () {
describe('GET /', function () {
it('Denies Unauthenticated Users', function (done) {
it('Denies Unauthenticated Users', function () {
const expected = {
error: 'not logged in',
};

request(app)
return request(app)
.get('/api/v2/auth')
.expect(401)
.then((response) => {
expect(response.body).to.deep.equal(expected);
done();
});
});

it('Gets the Current Logged In User', function (done) {
it('Gets the Current Logged In User', function () {
const expected = {
firstName: 'Test',
lastName: 'User',
dce: 'abc1234',
};

request(app)
return request(app)
.get('/api/v2/auth')
.set('Authorization', `Bearer ${token}`)
.expect(200)
.then((response) => {
expect(response.body).to.deep.equal(expected);
done();
});
});
});

describe('GET /googleClientID', function () {
it('Gets the Google Client ID', function (done) {
it('Gets the Google Client ID', function () {
const expected = {
token: nconf.get('auth').google.id,
};

request(app)
return request(app)
.get('/api/v2/auth/googleClientID')
.expect(200)
.then((response) => {
expect(response.body).to.deep.equal(expected);
done();
});
});
});

describe('POST /:provider', function () {
it('Sends a Refresh Token', function (done) {
request(app)
it('Sends a Refresh Token', function () {
return request(app)
.post('/api/v2/auth/refresh')
.set('Authorization', `Bearer ${token}`)
.expect(200)
Expand All @@ -69,22 +66,20 @@ describe('INTEGRATION TESTS: AUTH', function () {
// not be the same as the original token.
expect(response.body.token).to.not.be.undefined; // eslint-disable-line no-unused-expressions
expect(response.body).to.not.deep.equal({ token });
done();
});
});

it('Does Not Support Unknown Providers', function (done) {
it('Does Not Support Unknown Providers', function () {
const expected = {
error: 'invalid provider',
};

request(app)
return request(app)
.post('/api/v2/auth/unknown')
.set('Authorization', `Bearer ${token}`)
.expect(401)
.then((response) => {
expect(response.body).to.deep.equal(expected);
done();
});
});

Expand Down
Loading