mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(packing): anyone on the trip can be put down as the bringer of a shared item, and taken off again (#3098)
A common item only let you pledge yourself. Nobody else could be named, and a bringer could never be removed, so an item that went personal and back kept its owner's avatar for good. The item menu now lists every member to tick on or off, a click on the avatar opens it there, and the add route takes an optional user_id limited to the trip's members. Taking the owner off clears the owner. The remove route now checks visibility for the caller, not for the user named in the path.
This commit is contained in:
@@ -112,3 +112,22 @@ describe('PackingItemsRepository — share.service.ts SH13 read', () => {
|
||||
expect(await packingItemsRepo.listPublicForShare(trip.id)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PackingItemsRepository — clearOwner (#3098)', () => {
|
||||
it('drops the owner of one item, keeps its tier and leaves the other items alone', async () => {
|
||||
const { user: owner } = createUser(testDb);
|
||||
const trip = createTrip(testDb, owner.id);
|
||||
const item = createPackingItem(testDb, trip.id, { name: 'Stove' });
|
||||
const other = createPackingItem(testDb, trip.id, { name: 'Pot' });
|
||||
await updateRows(t, PackingItems, { id: item.id }, { is_private: 0, owner: owner.id, updated_at: null });
|
||||
await updateRows(t, PackingItems, { id: other.id }, { is_private: 0, owner: owner.id });
|
||||
|
||||
await packingItemsRepo.clearOwner(item.id);
|
||||
|
||||
const row = await packingItemsRepo.findById(item.id);
|
||||
expect(row?.owner_id).toBeNull();
|
||||
expect(row?.is_private).toBe(0);
|
||||
expect(row?.updated_at).not.toBeNull();
|
||||
expect((await packingItemsRepo.findById(other.id))?.owner_id).toBe(owner.id);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user