summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2017-04-23 12:46:48 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2017-04-23 18:43:26 +0200
commit016b40f99d679f0787f7c8a5f61f4a411b6c3632 (patch)
tree587e6326208d2b241a4f719e6db55b765b92df4b /test
parent4abde895a5b579fb798e062806c8fef2289f0d8f (diff)
downloadaur-016b40f99d679f0787f7c8a5f61f4a411b6c3632.tar.gz
aur-016b40f99d679f0787f7c8a5f61f4a411b6c3632.tar.xz
Render comments when storing them in the database
Instead of converting package comments from plain text to HTML code when they are displayed, do the conversion when the comment is posted and store the rendered result in the database. The conversion itself is done by a Python script which uses Bleach for sanitizing the text. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'test')
-rw-r--r--test/setup.sh1
-rwxr-xr-xtest/t2600-rendercomment.sh22
2 files changed, 23 insertions, 0 deletions
diff --git a/test/setup.sh b/test/setup.sh
index b71e73e8..f29695a6 100644
--- a/test/setup.sh
+++ b/test/setup.sh
@@ -16,6 +16,7 @@ TUVOTEREMINDER="$TOPLEVEL/aurweb/scripts/tuvotereminder.py"
PKGMAINT="$TOPLEVEL/aurweb/scripts/pkgmaint.py"
AURBLUP="$TOPLEVEL/aurweb/scripts/aurblup.py"
NOTIFY="$TOPLEVEL/aurweb/scripts/notify.py"
+RENDERCOMMENT="$TOPLEVEL/aurweb/scripts/rendercomment.py"
# Create the configuration file and a dummy notification script.
cat >config <<-EOF
diff --git a/test/t2600-rendercomment.sh b/test/t2600-rendercomment.sh
new file mode 100755
index 00000000..8d79336d
--- /dev/null
+++ b/test/t2600-rendercomment.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+test_description='rendercomment tests'
+
+. ./setup.sh
+
+test_expect_success 'Test comment rendering.' '
+ cat <<-EOD | sqlite3 aur.db &&
+ INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (1, 1, "Hello world!
+ This is a comment.", "");
+ EOD
+ "$RENDERCOMMENT" 1 &&
+ cat <<-EOD >expected &&
+ Hello world!<br>This is a comment.
+ EOD
+ cat <<-EOD | sqlite3 aur.db >actual &&
+ SELECT RenderedComment FROM PackageComments WHERE ID = 1;
+ EOD
+ test_cmp actual expected
+'
+
+test_done