0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/test/regression/models/model_single_use_token_spec.js

31 lines
910 B
JavaScript
Raw Normal View History

const models = require('../../../core/server/models');
const should = require('should');
describe('Regression: models/single-use-token', function () {
before(function () {
models.init();
});
describe('findOne', function () {
it('Does not allow the same token to be read twice', async function () {
const insertedToken = await models.SingleUseToken.add({
data: 'some_data'
}, {});
const tokenFirstRead = await models.SingleUseToken.findOne({
token: insertedToken.get('token')
});
should.exist(tokenFirstRead);
should.equal(tokenFirstRead.id, insertedToken.id);
const tokenSecondRead = await models.SingleUseToken.findOne({
token: insertedToken.get('token')
});
should.not.exist(tokenSecondRead);
});
});
});