allow to prefill timesheet description by get param (#2580)
This commit is contained in:
@@ -183,6 +183,11 @@ abstract class TimesheetAbstractController extends AbstractController
|
|||||||
$entry->setActivity($activity);
|
$entry->setActivity($activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->query->get('description')) {
|
||||||
|
$description = $request->query->get('description');
|
||||||
|
$entry->setDescription($description);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->query->get('tags')) {
|
if ($request->query->get('tags')) {
|
||||||
foreach ($this->getTags($tagRepository, $request->query->get('tags')) as $tag) {
|
foreach ($this->getTags($tagRepository, $request->query->get('tags')) as $tag) {
|
||||||
$entry->addTag($tag);
|
$entry->addTag($tag);
|
||||||
|
|||||||
@@ -497,6 +497,60 @@ class TimesheetControllerTest extends ControllerBaseTest
|
|||||||
$this->assertEquals(['one', 'two', 'three'], $timesheet->getTagsAsArray());
|
$this->assertEquals(['one', 'two', 'three'], $timesheet->getTagsAsArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreateActionWithDescription()
|
||||||
|
{
|
||||||
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||||
|
|
||||||
|
$this->request($client, '/timesheet/create?description=Lorem%20Ipsum');
|
||||||
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||||
|
|
||||||
|
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();
|
||||||
|
$client->submit($form, [
|
||||||
|
'timesheet_edit_form' => [
|
||||||
|
'hourlyRate' => 100,
|
||||||
|
'project' => 1,
|
||||||
|
'activity' => 1,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertIsRedirect($client, $this->createUrl('/timesheet/'));
|
||||||
|
$client->followRedirect();
|
||||||
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||||
|
$this->assertHasFlashSuccess($client);
|
||||||
|
|
||||||
|
$em = $this->getEntityManager();
|
||||||
|
/** @var Timesheet $timesheet */
|
||||||
|
$timesheet = $em->getRepository(Timesheet::class)->findAll()[0];
|
||||||
|
$this->assertEquals('Lorem Ipsum', $timesheet->getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreateActionWithDescriptionHtmlInjection()
|
||||||
|
{
|
||||||
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||||
|
|
||||||
|
$this->request($client, '/timesheet/create?description=Some text"><bold>HelloWorld<%2Fbold>');
|
||||||
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||||
|
|
||||||
|
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();
|
||||||
|
$client->submit($form, [
|
||||||
|
'timesheet_edit_form' => [
|
||||||
|
'hourlyRate' => 100,
|
||||||
|
'project' => 1,
|
||||||
|
'activity' => 1,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertIsRedirect($client, $this->createUrl('/timesheet/'));
|
||||||
|
$client->followRedirect();
|
||||||
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||||
|
$this->assertHasFlashSuccess($client);
|
||||||
|
|
||||||
|
$em = $this->getEntityManager();
|
||||||
|
/** @var Timesheet $timesheet */
|
||||||
|
$timesheet = $em->getRepository(Timesheet::class)->findAll()[0];
|
||||||
|
$this->assertEquals('Some text"><bold>HelloWorld</bold>', $timesheet->getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
public function testEditAction()
|
public function testEditAction()
|
||||||
{
|
{
|
||||||
$client = $this->getClientForAuthenticatedUser();
|
$client = $this->getClientForAuthenticatedUser();
|
||||||
|
|||||||
Reference in New Issue
Block a user