diff options
author | Simon McVittie <smcv@debian.org> | 2014-02-23 16:03:44 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2014-07-04 23:23:42 +0100 |
commit | 0357ad66eaf739299db1df38bbddc289c561b034 (patch) | |
tree | 4696bb391b3dd2c2019600636ca69d28c121b6ee /t | |
parent | 6d90e56c8dbb1e380f0e621305fd014767e9364b (diff) | |
download | ikiwiki-0357ad66eaf739299db1df38bbddc289c561b034.tar ikiwiki-0357ad66eaf739299db1df38bbddc289c561b034.tar.gz |
inline: postform=no should take precedence over rootpage existing
If someone has explicitly disabled the postform, it seems reasonable
from a least-astonishment point of view for that to take precedence
over rootpage, even though that makes rootpage useless.
Also add a regression test; so far, this is all it tests.
Diffstat (limited to 't')
-rwxr-xr-x | t/inline.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/t/inline.t b/t/inline.t new file mode 100755 index 000000000..b34cd27dc --- /dev/null +++ b/t/inline.t @@ -0,0 +1,59 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Test::More; +use IkiWiki; + +my $blob; + +ok(! system("rm -rf t/tmp")); +ok(! system("mkdir t/tmp")); + +sub write_old_file { + my $name = shift; + my $content = shift; + + writefile($name, "t/tmp/in", $content); + ok(utime(333333333, 333333333, "t/tmp/in/$name")); +} + +write_old_file("protagonists.mdwn", + '[[!inline pages="protagonists/*" rootpage="protagonists/new"]]'); +write_old_file("friends.mdwn", + '[[!inline pages="friends/*" postform=yes]]'); +write_old_file("antagonists.mdwn", + '[[!inline pages="antagonists/*"]]'); +write_old_file("enemies.mdwn", + '[[!inline pages="enemies/*" postform=no rootpage=enemies]]'); +foreach my $page (qw(protagonists/shepard protagonists/link + antagonists/saren antagonists/ganondorf + friends/liara friends/midna + enemies/benezia enemies/zant)) { + write_old_file("$page.mdwn", "this page is *$page*"); +} + +ok(! system("make -s ikiwiki.out")); + +my $command = "perl -I. ./ikiwiki.out -set usedirs=0 -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates t/tmp/in t/tmp/out -verbose"; + +ok(! system($command)); + +ok(! system("$command -refresh")); + +$blob = readfile("t/tmp/out/protagonists.html"); +like($blob, qr{Add a new post}, 'rootpage=yes gives postform'); +like($blob, qr{<input type="hidden" name="from" value="protagonists/new"}, + 'explicit rootpage is /protagonists/new'); + +$blob = readfile("t/tmp/out/friends.html"); +like($blob, qr{Add a new post}, 'postform=yes forces postform'); +like($blob, qr{<input type="hidden" name="from" value="friends"}, + 'implicit rootpage is /friends'); + +$blob = readfile("t/tmp/out/antagonists.html"); +unlike($blob, qr{Add a new post}, 'default is no postform'); + +$blob = readfile("t/tmp/out/enemies.html"); +unlike($blob, qr{Add a new post}, 'postform=no forces no postform'); + +done_testing; |