Changeset 1026
- Timestamp:
- 04/28/07 09:40:21 (19 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
Changes (modified) (1 diff)
-
lib/OpenGuides/Feed.pm (modified) (2 diffs)
-
t/22_feed_recent_changes.t (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r1023 r1026 5 5 6 6 0.60 7 Fixed bug in OpenGuides::Feed - HTML equivalent link now works even 8 if your script_name isn't blank. 7 9 Rewrote the HTML of the edit page to use <div>s rather than tables. 8 10 Note that you will probably want to provide at least basic styling -
trunk/lib/OpenGuides/Feed.pm
r903 r1026 11 11 use URI::Escape; 12 12 use Carp 'croak'; 13 14 use base qw( Class::Accessor ); 15 # Add more here if we need them - this one added for testing purposes. 16 my @variables = qw( html_equiv_link ); 17 OpenGuides::Feed->mk_accessors( @variables ); 13 18 14 19 sub new { … … 53 58 $self->{site_description} = $config->site_desc || ""; 54 59 $self->{og_version} = $args{og_version}; 55 $self->{html_equiv_link} = $self->{config}->script_url . '?action=rc'; 60 $self->{html_equiv_link} = $self->{config}->script_url 61 . $self->{config}->script_name . '?action=rc'; 56 62 57 63 $self; -
trunk/t/22_feed_recent_changes.t
r956 r1026 4 4 use OpenGuides; 5 5 use OpenGuides::Feed; 6 use OpenGuides::Test; 6 7 use OpenGuides::Utils; 7 8 use Test::More; … … 21 22 # Which feed types do we test? 22 23 my @feed_types = qw( rss atom ); 23 plan tests => 1 0* scalar @feed_types;24 plan tests => 12 * scalar @feed_types; 24 25 25 26 my %content_types = (rss=>'application/rdf+xml', atom=>'application/atom+xml'); … … 31 32 32 33 Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); 33 my $config = OpenGuides::Config->new( 34 vars => { 35 dbtype => "sqlite", 36 dbname => "t/node.db", 37 indexing_directory => "t/indexes", 38 script_name => "wiki.cgi", 39 script_url => "http://example.com/", 40 site_name => "Test Site", 41 template_path => "./templates", 42 home_name => "Home", 43 use_plucene => 1, 44 http_charset => "UTF-7", 45 } 46 ); 34 my $config = OpenGuides::Test->make_basic_config; 35 $config->script_name( "wiki.cgi" ); 36 $config->script_url( "http://example.com/" ); 37 $config->http_charset( "UTF-7" ); 47 38 48 39 # Basic sanity check first. … … 52 43 config => $config ); 53 44 is( $feed->default_content_type($feed_type), $content_types{$feed_type}, "Return the right content type" ); 45 46 like( $feed->html_equiv_link, qr|http://example.com/wiki.cgi\?|, 47 "html_equiv_link looks right" ); 54 48 55 49 my $feed_output = eval { $feed->make_feed(feed_type => $feed_type, feed_listing => 'recent_changes'); }; … … 65 59 # Now write some data, first a minor edit then a non-minor one. 66 60 my $guide = OpenGuides->new( config => $config ); 67 68 # Set up CGI parameters ready for a node write.69 # Most of these are in here to avoid uninitialised value warnings.70 my $q = CGI->new;71 $q->param( -name => "content", -value => "foo" );72 $q->param( -name => "categories", -value => "" );73 $q->param( -name => "locales", -value => "" );74 $q->param( -name => "phone", -value => "" );75 $q->param( -name => "fax", -value => "" );76 $q->param( -name => "website", -value => "" );77 $q->param( -name => "hours_text", -value => "" );78 $q->param( -name => "address", -value => "" );79 $q->param( -name => "postcode", -value => "" );80 $q->param( -name => "map_link", -value => "" );81 $q->param( -name => "os_x", -value => "" );82 $q->param( -name => "os_y", -value => "" );83 $q->param( -name => "username", -value => "bob" );84 $q->param( -name => "comment", -value => "foo" );85 $q->param( -name => "edit_type", -value => "Minor tidying" );86 $ENV{REMOTE_ADDR} = "127.0.0.1";87 61 88 my $output = $guide->commit_node( 89 return_output => 1, 90 id => "Wombats", 91 cgi_obj => $q, 92 ); 93 94 $q->param( -name => "edit_type", -value => "Normal edit" ); 95 $output = $guide->commit_node( 96 return_output => 1, 97 id => "Badgers", 98 cgi_obj => $q, 99 ); 100 101 $q->param( -name => "username", -value => "Kake" ); 102 $output = $guide->commit_node( 103 return_output => 1, 104 id => "Wombles", 105 cgi_obj => $q, 106 ); 62 OpenGuides::Test->write_data( 63 node => "Wombats", 64 guide => $guide, 65 username => "bob", 66 edit_type => "Minor tidying", 67 return_output => 1, 68 ); 69 OpenGuides::Test->write_data( 70 node => "Badgers", 71 guide => $guide, 72 username => "bob", 73 edit_type => "Normal edit", 74 return_output => 1, 75 ); 76 OpenGuides::Test->write_data( 77 node => "Wombles", 78 guide => $guide, 79 username => "Kake", 80 edit_type => "Normal edit", 81 return_output => 1, 82 ); 107 83 108 84 # Check that the writes went in. … … 112 88 113 89 # Check that the minor edits can be filtered out. 114 $output = $guide->display_feed(115 feed_type => $feed_type,116 feed_listing => "recent_changes",117 items => 5,118 username => "bob",119 ignore_minor_edits => 1,120 return_output => 1,121 );90 my $output = $guide->display_feed( 91 feed_type => $feed_type, 92 feed_listing => "recent_changes", 93 items => 5, 94 username => "bob", 95 ignore_minor_edits => 1, 96 return_output => 1, 97 ); 122 98 unlike( $output, qr/Wombats/, "minor edits filtered out when required" ); 123 99 like( $output, qr/Badgers/, "but normal edits still in" ); … … 125 101 # Check that the username parameter is taken notice of. 126 102 unlike( $output, qr/Wombles/, "username parameter taken note of" ); 103 104 # Now make sure that the HTTP euiv link still works with a blank scriptname 105 $config->script_name( "" ); 106 $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 107 108 $feed = OpenGuides::Feed->new( wiki => $wiki, 109 config => $config ); 110 like( $feed->html_equiv_link, qr|http://example.com/\?|, 111 "html_equiv_link looks right with blank script_name" ); 127 112 }
