| | 1 | use strict; |
| | 2 | use OpenGuides; |
| | 3 | use OpenGuides::Test; |
| | 4 | use Test::More; |
| | 5 | use Wiki::Toolkit::Setup::SQLite; |
| | 6 | |
| | 7 | eval { require DBD::SQLite; }; |
| | 8 | if ( $@ ) { |
| | 9 | plan skip_all => "DBD::SQLite not installed - no database to test with"; |
| | 10 | exit 0; |
| | 11 | } |
| | 12 | |
| | 13 | |
| | 14 | plan tests => 2; |
| | 15 | |
| | 16 | # test that an editable page gets the universal edit <link> and that a non-editable one doesnt. |
| | 17 | |
| | 18 | my ( $config, $guide, $wiki, $cookie, $output ); |
| | 19 | |
| | 20 | # Clear out the database from any previous runs. |
| | 21 | unlink "t/node.db"; |
| | 22 | unlink <t/indexes/*>; |
| | 23 | Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); |
| | 24 | |
| | 25 | # Make a guide. |
| | 26 | $config = OpenGuides::Test->make_basic_config; |
| | 27 | $guide = OpenGuides->new( config => $config ); |
| | 28 | my $wiki = $guide->wiki; |
| | 29 | |
| | 30 | # Write a node. |
| | 31 | OpenGuides::Test->write_data( |
| | 32 | guide => $guide, |
| | 33 | node => "Red Lion", |
| | 34 | ); |
| | 35 | |
| | 36 | $output = $guide->display_node( |
| | 37 | id => "Red Lion", |
| | 38 | return_output => 1, |
| | 39 | ); |
| | 40 | like( $output, qr|<link rel="alternate" type="application/wiki" title="Edit this page!"|ms, |
| | 41 | "universal edit link present"); |
| | 42 | |
| | 43 | |
| | 44 | unlike ( get_output($wiki, $config), qr|<link rel="alternate" type="application/wiki" title="Edit this page!"|ms, |
| | 45 | "universal edit link not present"); |
| | 46 | |
| | 47 | |
| | 48 | sub get_output { |
| | 49 | my ($wiki, $config) = @_; |
| | 50 | |
| | 51 | return OpenGuides::Template->output( |
| | 52 | wiki => $wiki, |
| | 53 | config => $config, |
| | 54 | template => "preferences.tt", |
| | 55 | noheaders => 1, |
| | 56 | vars => { |
| | 57 | not_editable => 1, |
| | 58 | show_form => 1 |
| | 59 | }, |
| | 60 | ); |
| | 61 | } |