Sorting: Updated sort set command, Changed sort timestamp handling

- Renamed AssignSortSetCommand to AssignSortRuleCommand, updated
  contents and testing.
- Updated sorting operations to not update timestamps if only priority
  is changed.
This commit is contained in:
Dan Brown
2025-02-11 15:29:16 +00:00
parent b9306a9029
commit 7bd89316bc
7 changed files with 193 additions and 145 deletions

View File

@ -165,6 +165,27 @@ class SortRuleTest extends TestCase
]);
}
public function test_auto_book_sort_does_not_touch_timestamps()
{
$book = $this->entities->bookHasChaptersAndPages();
$rule = SortRule::factory()->create(['sequence' => 'name_asc,chapters_first']);
$book->sort_rule_id = $rule->id;
$book->save();
$page = $book->pages()->first();
$chapter = $book->chapters()->first();
$resp = $this->actingAsApiEditor()->put("/api/pages/{$page->id}", [
'name' => '1111 page',
]);
$resp->assertOk();
$oldTime = $chapter->updated_at->unix();
$oldPriority = $chapter->priority;
$chapter->refresh();
$this->assertEquals($oldTime, $chapter->updated_at->unix());
$this->assertNotEquals($oldPriority, $chapter->priority);
}
public function test_name_numeric_ordering()
{
$book = Book::factory()->create();