allow update for uploaded routes and implement creator id for routes
This commit is contained in:
@@ -214,6 +214,37 @@ assert result['ok'] is True
|
||||
assert.doesNotMatch(downloadedGpx.toString(), /<trkpt /);
|
||||
assert.deepEqual(parseGpx(downloadedGpx.toString()).points, parseGpx(gpx.toString()).points);
|
||||
|
||||
assert.equal(route.creator_id, null);
|
||||
const creatorId = 'a'.repeat(64);
|
||||
const { body: assigned } = await requestJson(`${baseUrl}/api/routes/${route.id}`, {
|
||||
method: 'PUT', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ creator_id: creatorId })
|
||||
});
|
||||
assert.equal(assigned.creator_id, creatorId);
|
||||
await requestJson(`${baseUrl}/api/routes/${route.id}`, {
|
||||
method: 'PUT', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ creator_id: 'b'.repeat(64) })
|
||||
}, 409);
|
||||
await requestJson(`${baseUrl}/api/routes/${route.id}`, {
|
||||
method: 'PUT', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ creator_id: 'bad' })
|
||||
}, 400);
|
||||
const { body: preserved } = await requestJson(`${baseUrl}/api/routes/${route.id}`, {
|
||||
method: 'PUT', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ description: 'Ersteller bleibt erhalten' })
|
||||
});
|
||||
assert.equal(preserved.creator_id, creatorId);
|
||||
const createWithIdentity = new FormData();
|
||||
createWithIdentity.append('name', 'Ersteller-Test');
|
||||
createWithIdentity.append('creator_id', creatorId);
|
||||
createWithIdentity.append('gpx', new Blob([gpx], { type: 'application/gpx+xml' }), 'route.gpx');
|
||||
const { body: ownedRoute } = await requestJson(`${baseUrl}/api/routes`, { method: 'POST', body: createWithIdentity }, 201);
|
||||
assert.equal(ownedRoute.creator_id, creatorId);
|
||||
const invalidIdentity = new FormData();
|
||||
invalidIdentity.append('creator_id', 'invalid');
|
||||
invalidIdentity.append('gpx', new Blob([gpx], { type: 'application/gpx+xml' }), 'route.gpx');
|
||||
await requestJson(`${baseUrl}/api/routes`, { method: 'POST', body: invalidIdentity }, 400);
|
||||
|
||||
const { body: pendingPoi } = await requestJson(`${baseUrl}/api/routes/${route.id}/pois`, {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ title: 'Ohne Empfang', lat: null, lon: null })
|
||||
|
||||
Reference in New Issue
Block a user