In the CS, do not show a profile link unless the user is not a visitor. Fixes bug #11084
If the post is owned by Visitor, do not show the link because no one is allowed to see Visitor's profile. If the current user is Visitor, do not show the link because Visitor is not allowed to view anyone's profile.
This commit is contained in:
parent
3fb3644389
commit
247166baf2
9 changed files with 194 additions and 50 deletions
|
|
@ -8,13 +8,6 @@
|
|||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# XXX I (chrisn) started this file to test the features I added to the
|
||||
# Collaboration / Post system for 7.5, but didn't have the time available to me
|
||||
# to do a full test suite for the Post Wobject. This means that this test suite
|
||||
# is *largely incomplete* and should be finished. What is here *is* the
|
||||
# following:
|
||||
#
|
||||
#
|
||||
# 1. The basic framework for a test suite for the Post Asset.
|
||||
# Includes setup, cleanup, boilerplate, etc. Basically the really boring,
|
||||
# repetitive parts of the test that you don't want to write yourself.
|
||||
|
|
@ -26,7 +19,7 @@ use strict;
|
|||
use lib "$FindBin::Bin/../lib";
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 9; # increment this value for each test you create
|
||||
use Test::More tests => 16; # increment this value for each test you create
|
||||
use WebGUI::Asset::Wobject::Collaboration;
|
||||
use WebGUI::Asset::Post;
|
||||
use WebGUI::Asset::Post::Thread;
|
||||
|
|
@ -114,7 +107,11 @@ ok($post->canEdit(), "User in groupToEditPost group can edit post after the time
|
|||
$session->user({userId => $groupIdEditUser->userId});
|
||||
ok($post->canEdit(), "User in groupIdEditUserGroup group can edit post after the timeout");
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# getSynopsisAndContent
|
||||
#
|
||||
######################################################################
|
||||
|
||||
my ($synopsis, $content) = $post->getSynopsisAndContent('', q|Brandheiße Neuigkeiten rund um's Klettern für euch aus der Region |);
|
||||
is($synopsis, q|Brandheiße Neuigkeiten rund um's Klettern für euch aus der Region |, 'getSynopsisAndContent: UTF8 characters okay');
|
||||
|
|
@ -132,9 +129,40 @@ is($synopsis, q|less than < greater than >|, '... HTML escaped characters
|
|||
($synopsis, $content) = $post->getSynopsisAndContent('', q|<p>less than < greater than ></p>|);
|
||||
is($synopsis, q|less than < greater than >|, '... HTML entities decoded by HTML::splitTag');
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
ok(0, 'Whole lot more work to do here');
|
||||
}
|
||||
######################################################################
|
||||
#
|
||||
# getTemplateVars
|
||||
#
|
||||
######################################################################
|
||||
|
||||
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
|
||||
my $post1 = $collab->addChild({
|
||||
className => 'WebGUI::Asset::Post::Thread',
|
||||
content => 'hello, world!',
|
||||
ownerUserId => 3,
|
||||
}, @addArgs);
|
||||
my $post2 = $collab->addChild({
|
||||
className => 'WebGUI::Asset::Post::Thread',
|
||||
content => 'hello, world!',
|
||||
ownerUserId => 1,
|
||||
}, @addArgs);
|
||||
$versionTag2->commit();
|
||||
WebGUI::Test->tagsToRollback($versionTag);
|
||||
my $variables;
|
||||
$session->user({userId => 1});
|
||||
$variables = $post1->getTemplateVars();
|
||||
is( $variables->{'ownerUserId'}, 3, 'first post owned by admin');
|
||||
ok( $variables->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
|
||||
$variables = $post2->getTemplateVars();
|
||||
is( $variables->{'ownerUserId'}, 1, 'first post owned by admin');
|
||||
ok( $variables->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
|
||||
|
||||
$session->user({userId => 3});
|
||||
$variables = $post1->getTemplateVars();
|
||||
is( $variables->{'ownerUserId'}, 3, 'first post owned by admin');
|
||||
ok( !$variables->{'hideProfileUrl'}, 'show profile url');
|
||||
$variables = $post2->getTemplateVars();
|
||||
is( $variables->{'ownerUserId'}, 1, 'first post owned by admin');
|
||||
ok( $variables->{'hideProfileUrl'}, 'hide profile url, since poster is visitor');
|
||||
|
||||
# vim: syntax=perl filetype=perl
|
||||
|
|
|
|||
92
t/Asset/Wobject/Collaboration/templateVariables.t
Normal file
92
t/Asset/Wobject/Collaboration/templateVariables.t
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Test the Collaboration system template variables
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
use WebGUI::Session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 20; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my @addChildArgs = ( {skipAutoCommitWorkflows=>1} );
|
||||
my $collab = WebGUI::Asset->getImportNode( $session )->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Collaboration',
|
||||
threadsPerPage => 20,
|
||||
displayLastReply => 1,
|
||||
});
|
||||
|
||||
my @threads = (
|
||||
$collab->addChild( {
|
||||
className => 'WebGUI::Asset::Post::Thread',
|
||||
title => "X - Foo",
|
||||
isSticky => 0,
|
||||
ownerUserId => 1,
|
||||
}, undef, 1, @addChildArgs),
|
||||
$collab->addChild( {
|
||||
className => 'WebGUI::Asset::Post::Thread',
|
||||
title => "X - Bar",
|
||||
isSticky => 0,
|
||||
ownerUserId => 3,
|
||||
}, undef, 2, @addChildArgs),
|
||||
);
|
||||
|
||||
$_->setSkipNotification for @threads; # 100+ messages later...
|
||||
my $versionTag = WebGUI::VersionTag->getWorking( $session );
|
||||
$versionTag->commit;
|
||||
WebGUI::Test->tagsToRollback($versionTag);
|
||||
|
||||
my $templateVars;
|
||||
my $posts;
|
||||
$session->user({userId => 3});
|
||||
$templateVars = $collab->getViewTemplateVars();
|
||||
|
||||
##Threads come in reverse order, most recent first
|
||||
$posts = $templateVars->{post_loop};
|
||||
is( $posts->[1]->{'ownerUserId'}, 1, 'first post owned by visitor');
|
||||
ok( $posts->[1]->{'user.isVisitor'}, 'first post made by visitor');
|
||||
ok( $posts->[1]->{'hideProfileUrl'}, 'hide profile url, since post made by visitor');
|
||||
ok( $posts->[1]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||
ok( $posts->[1]->{'lastReply.hideProfileUrl'}, 'lastReply show profile url, since post not made by visitor, and user is not visitor');
|
||||
is( $posts->[0]->{'ownerUserId'}, 3, 'second post owned by admin');
|
||||
ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
|
||||
ok( !$posts->[0]->{'hideProfileUrl'}, 'show profile url, since post made by admin, and user is not visitor');
|
||||
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||
ok( !$posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply show profile url, since post not made by visitor, and user is not visitor');
|
||||
|
||||
$session->user({userId => 1});
|
||||
$templateVars = $collab->getViewTemplateVars();
|
||||
|
||||
##Threads come in reverse order, most recent first
|
||||
$posts = $templateVars->{post_loop};
|
||||
is( $posts->[1]->{'ownerUserId'}, 1, 'first post owned by visitor');
|
||||
ok( $posts->[1]->{'user.isVisitor'}, 'first post made by visitor');
|
||||
ok( $posts->[1]->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
|
||||
ok( $posts->[1]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||
ok( $posts->[1]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
|
||||
is( $posts->[0]->{'ownerUserId'}, 3, 'second post owned by admin');
|
||||
ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
|
||||
ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
|
||||
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||
ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
|
||||
#vim:ft=perl
|
||||
Loading…
Add table
Add a link
Reference in a new issue