my ($self, $user) = @_;
my @tlist;
- if($user && $user ne 'public') {
+ if(ref $user) {
## We have a user object already, so just fetch its traditions and use tose
- foreach my $t (@{ $self->lookup($user)->traditions }) {
+ foreach my $t (@{ $user->traditions }) {
push( @tlist, { 'id' => $self->object_to_id( $t ),
'name' => $t->name } );
}
return @tlist;
+ } elsif($user ne 'public') {
+ die "Passed neither a user object nor 'public' to user_traditionlist";
}
## Search for all traditions which allow public viewing
my( $self, $c ) = @_;
my $m = $c->model('Directory');
# TODO not used yet, will load user texts later
- my $user = $c->user_exists ? $c->user->id : 'public';
+ my $user = $c->user_exists ? $c->user->get_object : 'public';
# my $user = $c->request->param( 'user' ) || 'ALL';
my @textlist = $m->traditionlist($user);
$c->stash->{texts} = \@textlist;
password => 'testingtraditions' });
$user->add_tradition($t);
$user_store->update($user);
-# $userstore->update($t);
is( scalar @{$user->traditions}, 1, 'Added one tradition');
- my @tlist = $user_store->traditionlist($user->kiokudb_object_id);
- is($tlist[0]->name, $t->name, 'Traditionlist returns stored user->tradition');
+ my @tlist = $user_store->traditionlist($user);
+ is($tlist[0]->{name}, $t->name, 'Traditionlist returns same named user->tradition');
+ is($tlist[0]->{id}, $uuid, 'Traditionlist returns actual tradition with same uuid we put in earlier');
}