Skip to content
Merged
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
4,144 changes: 1 addition & 4,143 deletions docs/api/api_data.js

Large diffs are not rendered by default.

4,144 changes: 1 addition & 4,143 deletions docs/api/api_data.json

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions docs/api/api_project.js

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

17 changes: 1 addition & 16 deletions docs/api/api_project.json
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
{
"name": "hackerAPI",
"version": "0.0.8",
"description": "Documentation for the API used for mchacks",
"defaultVersion": "0.0.8",
"title": "hackerAPI documentation",
"url": "https://api.mchacks.ca/api",
"sampleUrl": "https://api.mchacks.ca/api",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-10-31T17:54:03.433Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
}
{ "name": "hackerAPI", "version": "0.0.8", "description": "Documentation for the API used for mchacks", "defaultVersion": "0.0.8", "title": "hackerAPI documentation", "url": "https://api.mchacks.ca/api", "sampleUrl": "https://api.mchacks.ca/api", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2020-11-01T22:01:33.009Z", "url": "http://apidocjs.com", "version": "0.17.7" }}
Expand Down
2 changes: 1 addition & 1 deletion middlewares/settings.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function updateSettings(req, res, next) {

/**
* @function confirmValidPatch
* @param {{body:{settingsDetails:{openTime:Date, closeTime:Date, confirmTime:Date}}}} req
* @param {{body:{settingsDetails:{openTime:Date, closeTime:Date, confirmTime:Date, isRemote: Boolean}}}} req
* @param {*} res
* @param {*} next
* @return {void}
Expand Down
3 changes: 2 additions & 1 deletion middlewares/validators/settings.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
createSettingsValidator: [
VALIDATOR.dateValidator("body", "openTime", true),
VALIDATOR.dateValidator("body", "closeTime", true),
VALIDATOR.dateValidator("body", "confirmTime", true)
VALIDATOR.dateValidator("body", "confirmTime", true),
VALIDATOR.booleanValidator("body", "isRemote", true)
]
};
4 changes: 4 additions & 0 deletions models/settings.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const settings = new mongoose.Schema({
confirmTime: {
type: Date,
default: Date.now() + 31104000000 + 2628000000 // 1 year and 1 month from now.
},
isRemote: {
type: Boolean,
default: false
}
});

Expand Down
7 changes: 5 additions & 2 deletions routes/api/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ module.exports = {
* "settings": {
* openTime: "Wed Feb 06 2019 00:00:00 GMT-0500 (GMT-05:00)",
* closeTime: "Sat Feb 01 2020 00:00:00 GMT-0500 (GMT-05:00)",
* confirmTime: "Sat Feb 20 2020 00:00:00 GMT-0500 (GMT-05:00)"
* confirmTime: "Sat Feb 20 2020 00:00:00 GMT-0500 (GMT-05:00)",
* isRemote: false
* }
* }
* }
Expand All @@ -55,6 +56,7 @@ module.exports = {
* @apiParam (body) {Date} [openTime] The opening time for the hackathon.
* @apiParam (body) {Date} [closeTime] The closing time for the hackathon.
* @apiParam (body) {Date} [confirmTime] The deadline for confirmation for the hackathon.
* @apiParam (body) {Boolean} [isRemote] Whether this hackathon is remote or not.
*
* @apiSuccess {string} message Success message
* @apiSuccess {object} data Settings Object
Expand All @@ -65,7 +67,8 @@ module.exports = {
* "settings": {
* openTime: "Wed Feb 06 2019 00:00:00 GMT-0500 (GMT-05:00)",
* closeTime: "Sat Feb 01 2020 00:00:00 GMT-0500 (GMT-05:00)",
* confirmTime: "Sat Feb 20 2020 00:00:00 GMT-0500 (GMT-05:00)"
* confirmTime: "Sat Feb 20 2020 00:00:00 GMT-0500 (GMT-05:00)",
* isRemote: true
* }
* }
* }
Expand Down
24 changes: 24 additions & 0 deletions tests/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,28 @@ describe("PATCH settings", function() {
);
});
});
it("should succeed to make the hackathon remote", function(done) {
util.auth.login(agent, Admin, (error) => {
if (error) {
agent.close();
return done(error);
}
return (
agent
.patch(`/api/settings/`)
.type("application/json")
.send(util.settings.settingRemoteHackathon)
// does not have password because of to stripped json
.end(function(err, res) {
res.should.have.status(200);
res.should.be.json;
res.body.should.have.property("message");
res.body.message.should.equal(
Constants.Success.SETTINGS_PATCH
);
done();
})
);
});
});
});
10 changes: 9 additions & 1 deletion tests/util/settings.test.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const settingConfirmClosed = {
confirmTime: new Date(Date.now() - 100)
};

const settingRemoteHackathon = {
openTime: new Date(Date.now() - 100),
closeTime: new Date(Date.now() + 10000000000),
confirmTime: new Date(Date.now() + 100000000000000),
isRemote: true
};

async function storeAll() {
const toStore = new Settings(settingApplicationOpen);
Settings.collection.insertOne(toStore);
Expand Down Expand Up @@ -61,5 +68,6 @@ module.exports = {
settingApplicationNotYetOpen: settingApplicationNotYetOpen,
settingApplicationOpen: settingApplicationOpen,
settingApplicationClosed: settingApplicationClosed,
settingConfirmClosed: settingConfirmClosed
settingConfirmClosed: settingConfirmClosed,
settingRemoteHackathon: settingRemoteHackathon
};