Show
Ignore:
Timestamp:
03/06/07 11:00:35 (5 years ago)
Author:
kake
Message:

Fix bug - ->categories was picking up out-of-date categories.

Location:
wiki-toolkit-plugin-categoriser/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit-plugin-categoriser/trunk/Changes

    r261 r380  
     10.05 
     2        Fix bug - ->categories was picking up out-of-date categories. 
     3 
    140.04    13 May 2006 
    25        Renamed Wiki::Toolkit::Plugin::Categoriser 
  • wiki-toolkit-plugin-categoriser/trunk/lib/Wiki/Toolkit/Plugin/Categoriser.pm

    r267 r380  
    44 
    55use vars qw( $VERSION @ISA ); 
    6 $VERSION = '0.04'; 
     6$VERSION = '0.05'; 
    77@ISA = qw( Wiki::Toolkit::Plugin ); 
    88 
     
    125125    my ($self, %args) = @_; 
    126126    my $dbh = $self->datastore->dbh; 
    127     my $sth = $dbh->prepare( "SELECT metadata_value FROM node INNER JOIN metadata ON (node_id = id) WHERE name = ? AND metadata_type = 'category'" ); 
     127    my $sth = $dbh->prepare( "SELECT metadata_value 
     128                              FROM node 
     129                              INNER JOIN metadata 
     130                                ON ( node.id = metadata.node_id 
     131                                     AND node.version = metadata.version ) 
     132                              WHERE name = ? AND metadata_type = 'category'" ); 
    128133    $sth->execute( $args{node} ); 
    129134    my @categories; 
  • wiki-toolkit-plugin-categoriser/trunk/t/categoriser.t

    r261 r380  
    44 
    55my $iterator = Wiki::Toolkit::TestLib->new_wiki_maker; 
    6 plan tests => ( 1 + $iterator->number * 6 ); 
     6plan tests => ( 1 + $iterator->number * 7 ); 
    77 
    88use_ok( "Wiki::Toolkit::Plugin::Categoriser" ); 
     
    4242    is_deeply( [ sort @categories ], [ "Pub Food", "Pubs" ], 
    4343               "...->categories returns all categories" ); 
     44 
     45    # Make sure we only look at current category data. 
     46    my %node_data = $wiki->retrieve_node( "Calthorpe Arms" ); 
     47    $wiki->write_node( "Calthorpe Arms", 
     48                       "Oh noes, they stopped doing food!", 
     49                       $node_data{checksum}, 
     50                       { category => [ "Pubs" ] } ) 
     51      or die "Can't write node"; 
     52    @categories = $categoriser->categories( node => "Calthorpe Arms" ); 
     53    is_deeply( \@categories, [ "Pubs" ], 
     54               "->categories ignores out-of-date data" ); 
    4455}