Allow admins to edit challenge tasks - fixes #8149 (#10658)

* Allow admins to edit challenges

* add test for admin creating a task in a challenge they don't own
This commit is contained in:
Forrest Hatfield
2019-07-12 06:56:09 -07:00
committed by Matteo Pagliazzi
parent babceaff42
commit 684a615a07
2 changed files with 21 additions and 6 deletions

View File

@@ -54,6 +54,21 @@ describe('POST /tasks/challenge/:challengeId', () => {
expect(tasksOrder.habits).to.include(task.id);
});
it('allows non-leader admin to add tasks to a challenge when not a member', async () => {
const admin = await generateUser({'contributor.admin': true});
let task = await admin.post(`/tasks/challenge/${challenge._id}`, {
text: 'test habit from admin',
type: 'habit',
up: false,
down: true,
notes: 1976,
});
let {tasksOrder} = await user.get(`/challenges/${challenge._id}`);
expect(tasksOrder.habits).to.include(task.id);
});
it('returns error when user tries to create task with a alias', async () => {
await expect(user.post(`/tasks/challenge/${challenge._id}`, {
text: 'test habit',