Aligned user preference endpoints in style and behaviour

Changes their endpoints and remove the user id from the URLs.
Simplifies list changes to share a single endpoint, which aligns it to
the behaviour of the existing sort preference endpoint.
Also added test to ensure user preferences are deleted on user delete.
This commit is contained in:
Dan Brown
2022-11-09 19:30:08 +00:00
parent 24a7e8500d
commit a3fcc98d6e
16 changed files with 89 additions and 88 deletions

View File

@ -225,18 +225,18 @@ class BookTest extends TestCase
setting()->putUser($editor, 'books_view_type', 'list');
$resp = $this->actingAs($editor)->get('/books');
$this->withHtml($resp)->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'Grid View');
$this->withHtml($resp)->assertElementExists('input[name="view_type"][value="grid"]');
$this->withHtml($resp)->assertElementContains('form[action$="/preferences/change-view/books"]', 'Grid View');
$this->withHtml($resp)->assertElementExists('button[name="view"][value="grid"]');
$resp = $this->patch("/settings/users/{$editor->id}/switch-books-view", ['view_type' => 'grid']);
$resp = $this->patch("/preferences/change-view/books", ['view' => 'grid']);
$resp->assertRedirect();
$this->assertEquals('grid', setting()->getUser($editor, 'books_view_type'));
$resp = $this->actingAs($editor)->get('/books');
$this->withHtml($resp)->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'List View');
$this->withHtml($resp)->assertElementExists('input[name="view_type"][value="list"]');
$this->withHtml($resp)->assertElementContains('form[action$="/preferences/change-view/books"]', 'List View');
$this->withHtml($resp)->assertElementExists('button[name="view"][value="list"]');
$resp = $this->patch("/settings/users/{$editor->id}/switch-books-view", ['view_type' => 'list']);
$resp = $this->patch("/preferences/change-view/books", ['view_type' => 'list']);
$resp->assertRedirect();
$this->assertEquals('list', setting()->getUser($editor, 'books_view_type'));
}