]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Limit rule to 255 2680/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 3 Dec 2016 10:10:39 +0000 (11:10 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 3 Dec 2016 10:10:39 +0000 (11:10 +0100)
To avoid database error

src/Wallabag/CoreBundle/Entity/TaggingRule.php
tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php

index 28914cc1949efb94ec3cb59fe688f6e1cd4a5da8..72651b19e1af2e17542c6199876b825f080d0267 100644 (file)
@@ -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"}
index 447feb4f9741290d47c9531251d45000fa924917..beb0598a969f32dcbe8295a47e98cec18e3adb1a 100644 (file)
@@ -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');