diff --git a/api/app/Controllers/Http/PlacesController.ts b/api/app/Controllers/Http/PlacesController.ts index 019232f..e2ebd74 100644 --- a/api/app/Controllers/Http/PlacesController.ts +++ b/api/app/Controllers/Http/PlacesController.ts @@ -45,6 +45,7 @@ export default class PlacesController { return response.status(403).send({ message: 'You do not have permission to access this resource' }) } + posted.user_id = auth.user?.id const place = await Place.create(posted) await illustration.related('places').save(place) return response.send({message: 'Created successfully', id: place.id}) @@ -60,7 +61,7 @@ export default class PlacesController { */ public async update({ params, auth, request, response }: HttpContextContract) { - const post = request.post() + const post = request.body() let place = await Place.findOrFail(params.id) diff --git a/api/tests/functional/place.spec.ts b/api/tests/functional/place.spec.ts index 205ca7e..7ed6462 100644 --- a/api/tests/functional/place.spec.ts +++ b/api/tests/functional/place.spec.ts @@ -49,11 +49,19 @@ test.group('Place', (group) => { const loggedInUser = await client.post('/login').json({ email: goodUser.email, password: 'oasssadfasdf' }) const illustration = await Illustration.findByOrFail('title', 'Places Test') - const place = await PlaceFactory.make() -// console.log(place.toJSON()) - const response = await client.post(`/places/${illustration.id}`).bearerToken(loggedInUser.body().token).json(place.toJSON()) + // not forcing the user ID here + // also not using factory, which creates a user + const place = { + place: 'Gusikowski and Sons', + location: 'South Tressie, South Dakota', + used: '2023-03-11' + } + + const response = await client.post(`/places/${illustration.id}`).bearerToken(loggedInUser.body().token).json(place) response.assertStatus(200) - assert.equal(response.body().message,'Created successfully') + // console.log(response.body()) + assert.equal(response.body().message, 'Created successfully') + assert.equal(response.body().place.user_id,goodUser.id) assert.isNumber(response.body().id) }) diff --git a/frontend/src/components/IllustrationForm.tsx b/frontend/src/components/IllustrationForm.tsx index c693508..6a1f826 100644 --- a/frontend/src/components/IllustrationForm.tsx +++ b/frontend/src/components/IllustrationForm.tsx @@ -88,7 +88,8 @@ export default function IllustrationForm({ illustration }: { - : <> -