From: Jeremy Benoist Date: Sat, 3 Dec 2016 10:10:39 +0000 (+0100) Subject: Limit rule to 255 X-Git-Tag: 2.2.0~3^2~32^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=5aa0294cca8115ce9a9401f9587d07d7ee37b769;p=github%2Fwallabag%2Fwallabag.git Limit rule to 255 To avoid database error --- diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 28914cc1..72651b19 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -28,6 +28,7 @@ class TaggingRule * @var string * * @Assert\NotBlank() + * @Assert\Length(max=255) * @RulerZAssert\ValidRule( * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches"} diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 447feb4f..beb0598a 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -515,6 +515,29 @@ class ConfigControllerTest extends WallabagCoreTestCase } } + public function testTaggingRuleTooLong() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/config'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('button[id=tagging_rule_save]')->form(); + + $crawler = $client->submit($form, [ + 'tagging_rule[rule]' => str_repeat('title', 60), + 'tagging_rule[tags]' => 'cool tag', + ]); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + + $this->assertContains('255 characters', $body[0]); + } + public function testDeletingTaggingRuleFromAnOtherUser() { $this->logInAs('bob');