[prev] [thread] [next] [lurker] [Date index for 2003/08/13]
Author: richardc Date: 2003-08-13 14:07:42 +0100 (Wed, 13 Aug 2003) New Revision: 1334 Modified: trunk/siesta/lib/Siesta/List.pm trunk/siesta/t/09plugin_order.t Log: fixup the case of ordering personal plugins Modified: trunk/siesta/lib/Siesta/List.pm =================================================================== --- trunk/siesta/lib/Siesta/List.pm 2003-08-13 12:53:04 UTC (rev 1333) +++ trunk/siesta/lib/Siesta/List.pm 2003-08-13 13:07:42 UTC (rev 1334) @@ -203,7 +203,10 @@ my $self = shift; my $queue = shift; my $i; - my %new_rank = map { $_ => ++$i } @_; + my %new_rank = map { (my $name = $_) =~ s/^\+//; + $name => { personal => $_ ne $name, + rank => ++$i } + } @_; die "'$queue' doesn't look like an queue id" unless $queue =~ /^[a-z]+$/; @@ -215,19 +218,19 @@ # then just add new ones my %old = map { $_->name => 1 } $self->plugins($queue); for my $plugin (keys %new_rank) { - my $personal = ($plugin =~ s/^\+//); next if $old{ $plugin }; Siesta::Plugin->create({ name => $plugin, list => $self, queue => $queue, rank => 0, - personal => $personal, + personal => 0, }); } # and reorder all of them for ($self->plugins($queue)) { - $_->rank( $new_rank{ $_->name } ); + $_->rank( $new_rank{ $_->name }{rank} ); + $_->personal( $new_rank{ $_->name }{personal} ); $_->update; } return 1; Modified: trunk/siesta/t/09plugin_order.t =================================================================== --- trunk/siesta/t/09plugin_order.t 2003-08-13 12:53:04 UTC (rev 1333) +++ trunk/siesta/t/09plugin_order.t 2003-08-13 13:07:42 UTC (rev 1334) @@ -1,6 +1,6 @@ #!perl -w use strict; -use Test::More tests => 10; +use Test::More tests => 11; use lib qw(t/lib); use Siesta::Test; use Siesta::List; @@ -50,3 +50,13 @@ my %ids2 = map { $_->name => $_->id } $list->plugins; is_deeply( \%ids2, \%ids, "reordering not recreating" ); + + +# check that ids remain stable when switching things between list and personal +$list->set_plugins( post => qw( Archive ReplyTo Send ) ); +%ids = map { $_->name => $_->id } $list->plugins; + +$list->set_plugins( post => qw( +ReplyTo Archive Send ) ); +%ids2 = map { $_->name => $_->id } $list->plugins; + +is_deeply( \%ids2, \%ids, "reordering not recreating, personal" );
Generated at 13:57 on 01 Jul 2004 by mariachi 0.52