fix: Fixed permission issues with Gallery comments
Gallery now checks to see if it's committed before allowing Albums to be added Slideshow and thumbnails work better Much, much more
This commit is contained in:
parent
ae6c1ac6df
commit
3ea9420479
14 changed files with 332 additions and 76 deletions
|
|
@ -179,7 +179,7 @@ ok(
|
|||
my $assetId = $photo->getId;
|
||||
$photo->purge;
|
||||
ok(
|
||||
!$session->db->quickScalar("SELECT commentId FROM Photo_comment WHERE assetId=?",[$assetId]),
|
||||
!$session->db->quickScalar("SELECT commentId FROM GalleryFile_comment WHERE assetId=?",[$assetId]),
|
||||
"Comments are purged along with asset",
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use lib "$FindBin::Bin/../../../../lib";
|
|||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
|
|
@ -68,6 +69,7 @@ my $testTemplateVars = {
|
|||
canComment => bool( 1 ),
|
||||
canEdit => bool( 0 ),
|
||||
ownerUsername => WebGUI::User->new( $session, 3 )->username,
|
||||
synopsis_textonly => WebGUI::HTML::filter( $photo->get('synopsis'), "all" ),
|
||||
url => $photo->getUrl,
|
||||
url_addArchive => $album->getUrl('func=addArchive'),
|
||||
url_delete => $photo->getUrl('func=delete'),
|
||||
|
|
@ -78,6 +80,9 @@ my $testTemplateVars = {
|
|||
url_listFilesForOwner
|
||||
=> $gallery->getUrl('func=listFilesForUser;userId=3'),
|
||||
url_promote => $photo->getUrl('func=promote'),
|
||||
url_album => $album->getUrl,
|
||||
url_thumbnails => $album->getUrl('func=thumbnails'),
|
||||
url_slideshow => $album->getUrl('func=slideshow'),
|
||||
fileUrl => $photo->getFileUrl,
|
||||
thumbnailUrl => $photo->getThumbnailUrl,
|
||||
numberOfComments => scalar @{ $photo->getCommentIds },
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ my %threadFields = (
|
|||
|
||||
# Post fields mapped to photo fields that should be migrated
|
||||
my %postFields = (
|
||||
content => "synopsis",
|
||||
createdBy => 'createdBy',
|
||||
creationDate => 'creationDate',
|
||||
ownerUserId => "ownerUserId",
|
||||
|
|
@ -113,8 +112,8 @@ my %postFields = (
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
# addAlbumFromThread adds 6 tests for $thread[0] and @{$posts[0]}
|
||||
my $threadPostTests = 6 * ( 1 + scalar @{ $posts[0] } );
|
||||
# addAlbumFromThread adds 7 tests for $thread[0] and @{$posts[0]}
|
||||
my $threadPostTests = 7 * ( 1 + scalar @{ $posts[0] } );
|
||||
|
||||
# addAlbumFromThread adds 1 test for each field in %threadFields
|
||||
my $threadFieldTests = 1 * scalar keys %threadFields;
|
||||
|
|
@ -180,20 +179,22 @@ is(
|
|||
"addAlbumFromThread adds one file for each attachment to the thread or posts of the thread",
|
||||
);
|
||||
|
||||
# 6 tests for each post/file + postFields tests
|
||||
# 7 tests for each post/file + postFields tests
|
||||
my $albumUrl = $album->get('url');
|
||||
for my $fileId ( @{$album->getFileIds} ) {
|
||||
my $file = WebGUI::Asset->newByDynamicClass( $session, $fileId );
|
||||
|
||||
# Find which Thread or Post this file corresponds to
|
||||
my $post;
|
||||
my ( $post, $isThread );
|
||||
if ( length $file->get('userDefined1') == 1 ) {
|
||||
# Is a thread, get it
|
||||
$post = $threads[ $file->get('userDefined1') ];
|
||||
$isThread = 1;
|
||||
}
|
||||
else {
|
||||
my @index = split //, $file->get('userDefined1');
|
||||
$post = $posts[ $index[0] ][ $index[1] ];
|
||||
$isThread = 0;
|
||||
}
|
||||
|
||||
for my $oldField ( sort keys %postFields ) {
|
||||
|
|
@ -201,6 +202,19 @@ for my $fileId ( @{$album->getFileIds} ) {
|
|||
"addAlbumFromThread migrates Post $oldField to File $postFields{$oldField}",
|
||||
);
|
||||
}
|
||||
|
||||
# File synopsis should be Post content If and only if Post content is not the same
|
||||
# as the Thread content
|
||||
if ( $isThread ) {
|
||||
is ( $file->get('synopsis'), undef,
|
||||
"Files do not get the Thread's content"
|
||||
);
|
||||
}
|
||||
else {
|
||||
is ( $file->get('synopsis'), $post->get('content'),
|
||||
"Files get content when they're from posts other than the Thread",
|
||||
);
|
||||
}
|
||||
|
||||
like(
|
||||
$file->get('url'), qr/^$albumUrl/,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue