Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# v1.6.71 — Keep live and test-mode API caches apart; driver-assigned events on driver channels

## Added

- **Category `parent_uuid` on internal responses.** The internal Category resource now includes `parent_uuid`, so a console can build a category tree from a flat list (Storefront's nested product categories). (#316)

## Fixed

- **A controller's filter is used for every query it serves.** `Find::httpFilterForModel()` cached its answer per model class for the life of the process, ignoring the filter a controller sets on its model (`$filter`) and whether the request was internal. Under Octane, the first controller to list a model decided the filter for every other: Fleet-Ops' order filter was applied to Storefront's order lists, so a network's orders page listed every order in the company. The cache is now keyed by the model's own filter, and a filter found by convention is picked per request audience. `Find::httpRequestForModel()` is keyed by the model's own request class too. (#315)
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Resources/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function toArray($request)
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
'owner_uuid' => $this->when(Http::isInternalRequest(), $this->owner_uuid),
'owner_type' => $this->when(Http::isInternalRequest(), $this->owner_type),
// Lets a console build a category tree from a flat list without loading each parent.
'parent_uuid' => $this->when(Http::isInternalRequest(), $this->parent_uuid),
'icon' => $this->icon,
'icon_url' => $this->icon_url,
'name' => $this->name,
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/Http/ResourceResponseContractsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function schedule_template_resource_model(array $attributes = []): ScheduleTempl
]));

expect($payload['id'])->toBe('cat_1')
->and($payload)->not->toHaveKeys(['uuid', 'company_uuid', 'owner_uuid', 'owner_type', 'public_id'])
->and($payload)->not->toHaveKeys(['uuid', 'company_uuid', 'owner_uuid', 'owner_type', 'public_id', 'parent_uuid'])
->and($payload['name'])->toBe('Operations')
->and($payload['icon_url'])->toBe('https://flb-assets.s3.ap-southeast-1.amazonaws.com/images/fallback-placeholder-1.png')
->and($payload['tags'])->toBe(['ops', 'dispatch'])
Expand All @@ -283,7 +283,7 @@ function schedule_template_resource_model(array $attributes = []): ScheduleTempl
'public_id' => 'cat_child',
'name' => 'Child Category',
]);
$category = category_resource_model([]);
$category = category_resource_model(['parent_uuid' => 'category-parent']);
$category->setRelation('parentCategory', $parent);
$category->setRelation('subCategories', collect([$child]));

Expand All @@ -301,6 +301,8 @@ function schedule_template_resource_model(array $attributes = []): ScheduleTempl
->and($payload['company_uuid'])->toBe('company-1')
->and($payload['owner_uuid'])->toBe('owner-1')
->and($payload['owner_type'])->toBe('company')
// A console builds its tree from parent_uuid without loading each parent.
->and($payload['parent_uuid'])->toBe('category-parent')
->and($payload)->not->toHaveKeys(['parent', 'subcategories']);

$withParent = (new CategoryResource($category))->resolve(resource_contract_request('/int/v1/categories/category-1', [
Expand Down
Loading