feat: Separate out update-user into set-cron and make-admin debug routes
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import nconf from 'nconf';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-v3-integration.helper';
|
||||
|
||||
describe('POST /debug/make-admin', () => {
|
||||
let user;
|
||||
|
||||
before(async () => {
|
||||
user = await generateUser();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nconf.set('IS_PROD', false);
|
||||
});
|
||||
|
||||
it('makes user an admine', async () => {
|
||||
await user.post('/debug/make-admin');
|
||||
|
||||
await user.sync();
|
||||
|
||||
expect(user.contributor.admin).to.eql(true);
|
||||
});
|
||||
|
||||
it('returns error when not in production mode', async () => {
|
||||
nconf.set('IS_PROD', true);
|
||||
|
||||
await expect(user.post('/debug/make-admin'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
});
|
||||
});
|
||||
+5
-19
@@ -3,47 +3,33 @@ import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-v3-integration.helper';
|
||||
|
||||
describe('POST /debug/update-user', () => {
|
||||
describe('POST /debug/set-cron', () => {
|
||||
let user;
|
||||
|
||||
before(async () => {
|
||||
user = await generateUser();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterEach(() => {
|
||||
nconf.set('IS_PROD', false);
|
||||
});
|
||||
|
||||
xit('sets protected values', async () => {
|
||||
it('sets last cron', async () => {
|
||||
let newCron = new Date(2015, 11, 20);
|
||||
|
||||
await user.post('/debug/update-user', {
|
||||
balance: 100,
|
||||
await user.post('/debug/set-cron', {
|
||||
lastCron: newCron,
|
||||
});
|
||||
|
||||
await user.sync();
|
||||
|
||||
expect(user.lastCron).to.eql(newCron);
|
||||
expect(user.balance).to.eql(100);
|
||||
});
|
||||
|
||||
xit('sets nested values', async () => {
|
||||
await user.post('/debug/update-user', {
|
||||
'contributor.level': 9,
|
||||
'purchased.txnCount': 100,
|
||||
});
|
||||
|
||||
await user.sync();
|
||||
|
||||
expect(user.contributor.level).to.eql(9);
|
||||
expect(user.purchased.txnCount).to.eql(100);
|
||||
});
|
||||
|
||||
it('returns error when not in production mode', async () => {
|
||||
nconf.set('IS_PROD', true);
|
||||
|
||||
await expect(user.post('/debug/update-user'))
|
||||
await expect(user.post('/debug/set-cron'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
Reference in New Issue
Block a user