Merge pull request 'Fix settings form being sent as PUT' (#4) from fix/settings-form-method into main
CI / Deploy / test (push) Successful in 43s
CI / Deploy / deploy (push) Successful in 6s

Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
gnilebein committed 2026-11-07 14:18:30 +01:00
commit 04cbc5bcd3
2 files changed
+12 -1

No files matched your search

+1 -1
View File
@@ -127,7 +127,7 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
<section class="card">
<h2><?= __('Einstellungen') ?></h2>
<?= $this->Form->create($poll, ['url' => $url('admin:settings')]) ?>
<?= $this->Form->create($poll, ['url' => $url('admin:settings'), 'type' => 'post']) ?>
<?= $this->Form->control('title', ['label' => __('Titel'), 'maxlength' => 200]) ?>
<?= $this->Form->control('is_active', [
'type' => 'checkbox',
@@ -49,6 +49,17 @@ class AdminControllerTest extends TestCase
$this->assertHeaderContains('X-Robots-Tag', 'noindex');
}
public function testSettingsFormPostsAndSaves(): void
{
[$poll, $token] = $this->createPoll('Alt');
$this->get("/admin/$token");
$this->assertResponseNotContains('name="_method" value="PUT"', 'settings form must not override method');
$this->post("/admin/$token/settings", ['title' => 'Neu', 'is_active' => '1', 'show_results_to_participants' => '0']);
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
$this->assertSame('Neu', $this->pollsTable()->get($poll->id)->title);
}
public function testTokenOfOtherPollCannotAccessSlides(): void
{
[$pollA] = $this->createPoll('A');