diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Hand the about filter the tree url its links need
With nothing below the about page, a readme's relative links have to be written against the tree, and only cgit knows how this site spells the url of a tree page and which ref the readme was read from. Both reach the filter already escaped for a url, built by the same writer as cgit's own links.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0201-filters.sh26
1 file changed, 24 insertions, 2 deletions
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh
index 11fa5f8..c6b23af 100755
--- a/tests/t0201-filters.sh
+++ b/tests/t0201-filters.sh
@@ -30,7 +30,7 @@ do
"
test_expect_success "check whether the $prefix about filter works" '
- grep "<div id='"'"'about'"'"'>a+b HELLO$" tmp
+ grep "<div id='"'"'about'"'"'>a+b /filter-$prefix/tree/ HELLO$" tmp
'
test_expect_success "generate filter-$prefix/commit/" "
@@ -61,10 +61,32 @@ do
test_expect_success "the $prefix about filter output stays inside its div" "
cgit_url 'filter-$prefix/about/' >tmp &&
- grep \"<div id='about'>a+b HELLO\" tmp
+ grep \"<div id='about'>a+b /filter-$prefix/tree/ HELLO\" tmp
"
done
+# A readme read at another branch links into the tree at that branch, which
+# the filter is told as the query to follow a path with.
+test_expect_success 'the about filter gets the tree url at the readme branch' '
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "readme=:a+b" &&
+ echo "about-filter=exec:$FILTER_DIRECTORY/dump.sh" &&
+ echo "root-readme=$PWD/root.txt" &&
+ echo "repo.url=filtered" &&
+ echo "repo.path=$PWD/repos/filter/.git"
+ } >aboutargsrc &&
+ CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="url=filtered/about/&h=1%2b2" cgit >tmp &&
+ grep "<div id=.about.>a+b /filtered/tree/ ?h=1%2B2 HELLO" tmp
+'
+
+test_expect_success 'the site readme leaves the tree url empty' '
+ echo site >root.txt &&
+ CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="p=about" cgit >tmp &&
+ grep "root.txt SITE" tmp
+'
+
test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
test "$CGIT_HAS_LUA" -eq 1 || say 'cgit built without lua, error page check skipped'