-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(core): mongoose models rewritten with Joi
- Loading branch information
1 parent
8586ef3
commit 12e1d9e
Showing
22 changed files
with
180 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
import { Router } from 'express'; | ||
|
||
import { requireAuth, verifyPermission } from 'auth'; | ||
|
||
import * as controller from './controller'; | ||
import LocalizedArticle from './model'; | ||
|
||
const router = Router(); | ||
|
||
router.post('/:articleId', requireAuth, verifyPermission('canCreateArticle'), controller.create); | ||
router.put('/:slug', requireAuth, verifyPermission('canCreateArticle'), controller.update); | ||
|
||
export { LocalizedArticle }; | ||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
import { expect, dropData, loginTestAdmin, defaultObjectMetadata, spy } from 'utils/testing'; | ||
|
||
import 'db/connect'; | ||
|
||
import LocalizedArticle from './model'; | ||
|
||
describe('LocalizedArticle model', () => { | ||
let metadata; | ||
|
||
before(async function() { | ||
this.timeout(5000); | ||
await dropData(); | ||
|
||
await loginTestAdmin(); | ||
metadata = await defaultObjectMetadata(); | ||
}); | ||
|
||
it('should fail to save article | no locale', async () => { | ||
const errorHandler = spy(({ message }) => { | ||
expect(message).to.not.empty(); | ||
expect(message.locale).to.includes('required'); | ||
}); | ||
|
||
await LocalizedArticle({ | ||
articleId: mongoose.Types.ObjectId().toString(), | ||
title: 'Title', | ||
subtitle: 'Subtitle', | ||
slug: 'slug1', | ||
metadata, | ||
}) | ||
.save() | ||
.catch(errorHandler); | ||
|
||
expect(errorHandler).to.have.been.called(); | ||
}); | ||
}); |
Oops, something went wrong.