| 1 | use strict; |
|---|
| 2 | use Wiki::Toolkit::Setup::SQLite; |
|---|
| 3 | use File::Temp qw( tempfile ); |
|---|
| 4 | use OpenGuides; |
|---|
| 5 | use OpenGuides::Test; |
|---|
| 6 | use Test::More; |
|---|
| 7 | |
|---|
| 8 | eval { require DBD::SQLite; }; |
|---|
| 9 | if ( $@ ) { |
|---|
| 10 | my ($error) = $@ =~ /^(.*?)\n/; |
|---|
| 11 | plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | plan tests => 4; |
|---|
| 15 | |
|---|
| 16 | # Clear out the database from any previous runs. |
|---|
| 17 | unlink "t/node.db"; |
|---|
| 18 | unlink <t/indexes/*>; |
|---|
| 19 | Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); |
|---|
| 20 | |
|---|
| 21 | my $config = OpenGuides::Test->make_basic_config; |
|---|
| 22 | my $guide = OpenGuides->new( config => $config ); |
|---|
| 23 | |
|---|
| 24 | # Print some RSS to a temporary file, and use a 'file://' URL to save faff. |
|---|
| 25 | my ($fh, $filename) = tempfile( UNLINK => 1 ); |
|---|
| 26 | while ( my $line = <DATA> ) { |
|---|
| 27 | print $fh $line; |
|---|
| 28 | } |
|---|
| 29 | close $fh; |
|---|
| 30 | my $url = 'file://' . $filename; |
|---|
| 31 | |
|---|
| 32 | OpenGuides::Test->write_data( |
|---|
| 33 | guide => $guide, |
|---|
| 34 | node => "Crabtree Tavern", |
|---|
| 35 | content => '@RSS ' . $url, |
|---|
| 36 | ); |
|---|
| 37 | OpenGuides::Test->write_data( |
|---|
| 38 | guide => $guide, |
|---|
| 39 | node => "Crabtree Tavern", |
|---|
| 40 | content => '@RSS ' . $url, |
|---|
| 41 | ); |
|---|
| 42 | my $output = eval { |
|---|
| 43 | $guide->display_diffs( |
|---|
| 44 | id => "Crabtree Tavern", |
|---|
| 45 | version => 1, |
|---|
| 46 | other_version => 2, |
|---|
| 47 | return_output => 1, |
|---|
| 48 | ); |
|---|
| 49 | }; |
|---|
| 50 | is( $@, "", |
|---|
| 51 | "->display_diffs doesn't die when called on a node with RSS feeds in" ); |
|---|
| 52 | |
|---|
| 53 | OpenGuides::Test->write_data( |
|---|
| 54 | guide => $guide, |
|---|
| 55 | node => "Calthorpe Arms", |
|---|
| 56 | content => '@INDEX_LIST [[Category Foo]]', |
|---|
| 57 | ); |
|---|
| 58 | OpenGuides::Test->write_data( |
|---|
| 59 | guide => $guide, |
|---|
| 60 | node => "Calthorpe Arms", |
|---|
| 61 | content => '@INDEX_LIST [[Category Foo]]', |
|---|
| 62 | ); |
|---|
| 63 | $output = eval { |
|---|
| 64 | $guide->display_diffs( |
|---|
| 65 | id => "Calthorpe Arms", |
|---|
| 66 | version => 1, |
|---|
| 67 | other_version => 2, |
|---|
| 68 | return_output => 1, |
|---|
| 69 | ); |
|---|
| 70 | }; |
|---|
| 71 | is( $@, "", |
|---|
| 72 | "...or on a node with INDEX_LIST in" ); |
|---|
| 73 | |
|---|
| 74 | OpenGuides::Test->write_data( |
|---|
| 75 | guide => $guide, |
|---|
| 76 | node => "Penderel's Oak", |
|---|
| 77 | content => '@INDEX_LINK [[Category Foo]]', |
|---|
| 78 | ); |
|---|
| 79 | OpenGuides::Test->write_data( |
|---|
| 80 | guide => $guide, |
|---|
| 81 | node => "Penderel's Oak", |
|---|
| 82 | content => '@INDEX_LINK [[Category Foo]]', |
|---|
| 83 | ); |
|---|
| 84 | $output = eval { |
|---|
| 85 | $guide->display_diffs( |
|---|
| 86 | id => "Penderel's Oak", |
|---|
| 87 | version => 1, |
|---|
| 88 | other_version => 2, |
|---|
| 89 | return_output => 1, |
|---|
| 90 | ); |
|---|
| 91 | }; |
|---|
| 92 | is( $@, "", |
|---|
| 93 | "...or on a node with INDEX_LINK in" ); |
|---|
| 94 | like( $output, qr|view all pages in category foo|i, |
|---|
| 95 | "...and index link is correct" ); |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | __DATA__ |
|---|
| 99 | <?xml version="1.0" encoding="UTF-8"?> |
|---|
| 100 | |
|---|
| 101 | <rdf:RDF |
|---|
| 102 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
|---|
| 103 | xmlns="http://purl.org/rss/1.0/" |
|---|
| 104 | xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" |
|---|
| 105 | xmlns:dc="http://purl.org/dc/elements/1.1/" |
|---|
| 106 | xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" |
|---|
| 107 | xmlns:wiki="http://purl.org/rss/1.0/modules/wiki/" |
|---|
| 108 | xmlns:admin="http://webns.net/mvcb/" |
|---|
| 109 | > |
|---|
| 110 | |
|---|
| 111 | <channel rdf:about="http://london.openguides.org/kakemirror/?RecentChanges"> |
|---|
| 112 | <title>The Open Guide to London - Kake's Mirror</title> |
|---|
| 113 | <link>http://london.openguides.org/kakemirror/?RecentChanges</link> |
|---|
| 114 | <description></description> |
|---|
| 115 | <dc:date>2004-12-14T12:59:42</dc:date> |
|---|
| 116 | <wiki:interwiki></wiki:interwiki> |
|---|
| 117 | <items> |
|---|
| 118 | <rdf:Seq> |
|---|
| 119 | <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=9" /> |
|---|
| 120 | <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=8" /> |
|---|
| 121 | <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=14" /> |
|---|
| 122 | <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=13" /> |
|---|
| 123 | <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=12" /> |
|---|
| 124 | </rdf:Seq> |
|---|
| 125 | </items> |
|---|
| 126 | </channel> |
|---|
| 127 | |
|---|
| 128 | <item rdf:about="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=9"> |
|---|
| 129 | <title>Buckingham Arms, SW1H 9EU</title> |
|---|
| 130 | <link>http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=9</link> |
|---|
| 131 | <description>extraneous : [bob]</description> |
|---|
| 132 | <dc:date>2004-12-12T13:25:27</dc:date> |
|---|
| 133 | <dc:contributor>bob</dc:contributor> |
|---|
| 134 | <wiki:history></wiki:history> |
|---|
| 135 | <wiki:importance>minor</wiki:importance> |
|---|
| 136 | <wiki:version>9</wiki:version> |
|---|
| 137 | <wiki:status>updated</wiki:status> |
|---|
| 138 | <wiki:diff></wiki:diff> |
|---|
| 139 | </item> |
|---|
| 140 | |
|---|
| 141 | <item rdf:about="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=8"> |
|---|
| 142 | <title>Buckingham Arms, SW1H 9EU</title> |
|---|
| 143 | <link>http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=8</link> |
|---|
| 144 | <description> [Martin]</description> |
|---|
| 145 | <dc:date>2004-12-11T14:05:38</dc:date> |
|---|
| 146 | <dc:contributor>Martin</dc:contributor> |
|---|
| 147 | <wiki:history></wiki:history> |
|---|
| 148 | <wiki:importance>major</wiki:importance> |
|---|
| 149 | <wiki:version>8</wiki:version> |
|---|
| 150 | <wiki:status>updated</wiki:status> |
|---|
| 151 | <wiki:diff></wiki:diff> |
|---|
| 152 | </item> |
|---|
| 153 | |
|---|
| 154 | <item rdf:about="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=14"> |
|---|
| 155 | <title>Star Tavern, SW1X 8HT</title> |
|---|
| 156 | <link>http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=14</link> |
|---|
| 157 | <description>De-bobbed the bob bits. [Kake]</description> |
|---|
| 158 | <dc:date>2004-12-10T14:29:13</dc:date> |
|---|
| 159 | <dc:contributor>Kake</dc:contributor> |
|---|
| 160 | <wiki:history></wiki:history> |
|---|
| 161 | <wiki:importance>minor</wiki:importance> |
|---|
| 162 | <wiki:version>14</wiki:version> |
|---|
| 163 | <wiki:status>updated</wiki:status> |
|---|
| 164 | <wiki:diff></wiki:diff> |
|---|
| 165 | </item> |
|---|
| 166 | |
|---|
| 167 | <item rdf:about="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=13"> |
|---|
| 168 | <title>Star Tavern, SW1X 8HT</title> |
|---|
| 169 | <link>http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=13</link> |
|---|
| 170 | <description>More comments. [Kake]</description> |
|---|
| 171 | <dc:date>2004-12-10T14:27:41</dc:date> |
|---|
| 172 | <dc:contributor>Kake</dc:contributor> |
|---|
| 173 | <wiki:history></wiki:history> |
|---|
| 174 | <wiki:importance>major</wiki:importance> |
|---|
| 175 | <wiki:version>13</wiki:version> |
|---|
| 176 | <wiki:status>updated</wiki:status> |
|---|
| 177 | <wiki:diff></wiki:diff> |
|---|
| 178 | </item> |
|---|
| 179 | |
|---|
| 180 | <item rdf:about="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=12"> |
|---|
| 181 | <title>Star Tavern, SW1X 8HT</title> |
|---|
| 182 | <link>http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=12</link> |
|---|
| 183 | <description>updated [bob]</description> |
|---|
| 184 | <dc:date>2004-12-10T14:18:51</dc:date> |
|---|
| 185 | <dc:contributor>bob</dc:contributor> |
|---|
| 186 | <wiki:history></wiki:history> |
|---|
| 187 | <wiki:importance>minor</wiki:importance> |
|---|
| 188 | <wiki:version>12</wiki:version> |
|---|
| 189 | <wiki:status>updated</wiki:status> |
|---|
| 190 | <wiki:diff></wiki:diff> |
|---|
| 191 | </item> |
|---|
| 192 | |
|---|
| 193 | </rdf:RDF> |
|---|