|
Revision 1054, 1.0 kB
(checked in by dom, 19 months ago)
|
|
Add support in output routine for specifying HTTP status code (see #102)
|
| Line | |
|---|
| 1 | use strict; |
|---|
| 2 | use Cwd; |
|---|
| 3 | use OpenGuides; |
|---|
| 4 | use OpenGuides::Template; |
|---|
| 5 | use OpenGuides::Test; |
|---|
| 6 | use Test::More tests => 3; |
|---|
| 7 | |
|---|
| 8 | my $config = OpenGuides::Test->make_basic_config; |
|---|
| 9 | $config->template_path( cwd . "/t/templates" ); |
|---|
| 10 | |
|---|
| 11 | my $guide = OpenGuides->new( config => $config ); |
|---|
| 12 | my $wiki = $guide->wiki; |
|---|
| 13 | |
|---|
| 14 | eval { |
|---|
| 15 | OpenGuides::Template->output( wiki => $wiki, |
|---|
| 16 | config => $config, |
|---|
| 17 | template => "15_test.tt" ); |
|---|
| 18 | }; |
|---|
| 19 | is( $@, "", "is happy doing output" ); |
|---|
| 20 | |
|---|
| 21 | my $output = OpenGuides::Template->output( |
|---|
| 22 | wiki => $wiki, |
|---|
| 23 | config => $config, |
|---|
| 24 | template => "15_test.tt" |
|---|
| 25 | ); |
|---|
| 26 | |
|---|
| 27 | unlike( $output, qr/^Status:/, |
|---|
| 28 | "HTTP status not printed when not explicitly specified "); |
|---|
| 29 | |
|---|
| 30 | # Now supply a http status |
|---|
| 31 | |
|---|
| 32 | $output = OpenGuides::Template->output( |
|---|
| 33 | wiki => $wiki, |
|---|
| 34 | config => $config, |
|---|
| 35 | template => "15_test.tt", |
|---|
| 36 | http_status => '404' |
|---|
| 37 | ); |
|---|
| 38 | like( $output, qr/^Status: 404/, |
|---|
| 39 | "Correct HTTP status printed when specified" ); |
|---|