diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 901ef6a0a..e3d4eb23c 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -19,6 +19,7 @@ - fixed: packages don't include archived assets - fixed: Getting an i18n key from a file that does not exist. - fixed: Tree Navigation menu shows level numbers + - fixed: loginBox macro no longer can return user to "logout" page, logging them out 7.5.20 - fixed: DataForm acknowledgement screen shows incorrect value for Date/Time fields diff --git a/lib/WebGUI/Asset/File/GalleryFile/Photo.pm b/lib/WebGUI/Asset/File/GalleryFile/Photo.pm index bec196849..5b34c7b4d 100644 --- a/lib/WebGUI/Asset/File/GalleryFile/Photo.pm +++ b/lib/WebGUI/Asset/File/GalleryFile/Photo.pm @@ -109,28 +109,21 @@ C is a hash reference of options and is currently not used. sub applyConstraints { my $self = shift; - my $options = shift; my $gallery = $self->getGallery; # Update the asset's size and make a thumbnail - my $maxImageSize = $gallery->get("imageViewSize") + my $maxImageSize = $self->getGallery->get("imageViewSize") || $self->session->setting->get("maxImageSize"); + my $thumbnailSize = $self->getGallery->get("imageThumbnailSize") + || $self->session->setting->get("thumbnailSize"); my $parameters = $self->get("parameters"); my $storage = $self->getStorageLocation; my $file = $self->get("filename"); - - # Make resolutions before fixing image, so that we can get higher quality - # resolutions - $self->makeResolutions; - - # adjust density before size, so that the dimensions won't change - $storage->resize( $file, undef, undef, $gallery->get( 'imageDensity' ) ); $storage->adjustMaxImageSize($file, $maxImageSize); - $self->generateThumbnail; $self->setSize; + $self->makeResolutions; $self->updateExifDataFromFile; - $self->SUPER::applyConstraints( $options ); } #------------------------------------------------------------------- @@ -368,7 +361,7 @@ sub makeResolutions { } my $newFilename = $res . ".jpg"; $storage->copyFile( $self->get("filename"), $newFilename ); - $storage->resize( $newFilename, $res, undef, $self->getGallery->get( 'imageDensity' ) ); + $storage->resize( $newFilename, $res ); } } diff --git a/lib/WebGUI/Macro/L_loginBox.pm b/lib/WebGUI/Macro/L_loginBox.pm index 23df4d62b..3dde458f4 100644 --- a/lib/WebGUI/Macro/L_loginBox.pm +++ b/lib/WebGUI/Macro/L_loginBox.pm @@ -77,17 +77,23 @@ sub process { $var{'logout.label'} = $i18n->get(49); # A hidden field with the current URL + my $returnUrl = $session->url->page; + if ( !$session->form->get("op") eq "auth" ) { + $returnUrl .= '?' . $session->env->get( "QUERY_STRING" ); + } $var{'form.returnUrl'} = WebGUI::Form::hidden( $session, { name => 'returnUrl', value => $session->url->page($session->env->get("QUERY_STRING")), }); - + + # Fix box size my $boxSize = $param[0]; $boxSize = 12 unless ($boxSize); if (index(lc($session->env->get("HTTP_USER_AGENT")),"msie") < 0) { $boxSize = int($boxSize=$boxSize*2/3); } + my $action; if ($session->setting->get("encryptLogin")) { $action = $session->url->page(undef,1); diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 9ffbe51a6..6f98e6335 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -283,7 +283,6 @@ my $origRequest = $session->{_request}; my $newRequest = Test::MockObject->new(); my $func; $newRequest->set_bound('body', \$func); -$newRequest->set_bound('param', \$func); $session->{_request} = $newRequest; $func = 'add'; is($importNode->addEditLabel, $i18n->get('add').' '.$importNode->getName, 'addEditLabel, use add mode'); @@ -436,7 +435,7 @@ my $importNodeTitle = $importNode->getTitle(); foreach my $test (@fixTitleTests) { my $fixedTitle = $importNode->fixTitle($test->{title}, 'ownerUserId'); - my $expectedTitle = defined $test->{fixed} ? $test->{fixed} : $importNodeTitle; + my $expectedTitle = $test->{fixed} || $importNodeTitle; is($fixedTitle, $expectedTitle, $test->{comment}); } @@ -698,7 +697,9 @@ is($rootAsset->get('isExportable'), 1, 'isExportable exists, defaults to 1'); ################################################################ my $assetProps = $rootAsset->get(); my $funkyTitle = q{Miss Annie's Whoopie Emporium and Sasparilla Shop}; +diag $assetProps->{title}; $assetProps->{title} = $funkyTitle; +diag $assetProps->{title}; isnt( $rootAsset->get('title'), $funkyTitle, 'get returns a safe copy of the Asset properties'); @@ -707,7 +708,7 @@ isnt( $rootAsset->get('title'), $funkyTitle, 'get returns a safe copy of the Ass # getIsa # ################################################################ -my $node = WebGUI::Asset->getRoot($session); +my $node = WebGUI::Asset::Sku::Product->getProductImportNode($session); my $product1 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'}); my $product2 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'}); my $product3 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'}); @@ -893,29 +894,29 @@ sub getFixIdTests { } ##Return an array of hashrefs. Each hashref describes a test -##for the fixTitle method. If "fixed" != undef, it should +##for the fixTitle method. If "fixed" != 0, it should ##contain what the fixTitle method will return. sub getFixTitleTests { my $session = shift; return ({ title => undef, - fixed => undef, + fixed => 0, comment => "undef returns the Asset's title", }, { title => '', - fixed => undef, + fixed => 0, comment => "null string returns the Asset's title", }, { title => 'untitled', - fixed => undef, + fixed => 0, comment => "'untitled' returns the Asset's title", }, { title => 'UnTiTlEd', - fixed => undef, + fixed => 0, comment => "'untitled' in any case returns the Asset's title", }, { @@ -938,11 +939,6 @@ sub getFixTitleTests { fixed => 'This is a good Title', comment => "Good titles are passed", }, - { - title => '', - fixed => '', - comment => "If there is no title left after processing, then it is set to untitled.", - }, ); } diff --git a/t/Asset/AssetExportHtml.t b/t/Asset/AssetExportHtml.t index 408ef227a..ade702964 100644 --- a/t/Asset/AssetExportHtml.t +++ b/t/Asset/AssetExportHtml.t @@ -742,45 +742,40 @@ $exportPath->rmtree; # list of files that should exist. obtained by running previous known working # export function on a full stock asset tree @createdFiles = ( - [ qw/ getting_started getting-started index.html /], - [ qw/ getting_started getting-started-part2 index.html /], - [ qw/ getting_started index.html /], - [ qw/ home ad index.html /], - [ qw/ home ad2 index.html /], - [ qw/ home index.html /], - [ qw/ home key-benefits index.html /], - [ qw/ home welcome index.html /], - [ qw/ site_map index.html /], - [ qw/ site_map site_map index.html /], - [ qw/ tell_a_friend index.html /], - [ qw/ tell_a_friend tell_a_friend index.html /], - [ qw/ the_latest_news index.html /], - [ qw/ the_latest_news the_latest_news index.html /], - [ qw/ yns docs index.html /], - [ qw/ yns experts index.html /], - [ qw/ yns features index.html /], - [ qw/ yns hosting index.html /], - [ qw/ yns promotion index.html /], - [ qw/ yns style index.html /], - [ qw/ yns support index.html /], - [ qw/ yns translated index.html /], - [ qw/ your_next_step index.html /], - [ qw/ documentation index.html /], - [ qw/ documentation commercial-documentation index.html /], - [ qw/ documentation free-documentation index.html /], + [ qw/ getting_started getting-started index.html /], + [ qw/ getting_started getting-started-part2 index.html /], + [ qw/ getting_started index.html /], + [ qw/ home ad index.html /], + [ qw/ home ad2 index.html /], + [ qw/ home index.html /], + [ qw/ home key-benefits index.html /], + [ qw/ home welcome index.html /], + [ qw/ site_map index.html /], + [ qw/ site_map site_map index.html /], + [ qw/ tell_a_friend index.html /], + [ qw/ tell_a_friend tell_a_friend index.html /], + [ qw/ the_latest_news index.html /], + [ qw/ the_latest_news the_latest_news index.html /], + [ qw/ yns docs index.html /], + [ qw/ yns experts index.html /], + [ qw/ yns features index.html /], + [ qw/ yns hosting index.html /], + [ qw/ yns promotion index.html /], + [ qw/ yns style index.html /], + [ qw/ yns support index.html /], + [ qw/ yns translated index.html /], + [ qw/ your_next_step index.html /], ); -my $numberCreatedAll = scalar @createdFiles; - # turn them into Path::Class::File objects my @shouldExist = map { Path::Class::File->new($exportPath, @{$_})->absolute->stringify } @createdFiles; # ensure that the files that should exist do exist my @doExist; $exportPath->recurse( callback => sub { my $o = shift; $o->is_dir ? return : push @doExist, $o->absolute->stringify } ); -cmp_bag(\@shouldExist, \@doExist, "exportAsHtml on home writes correct files"); +cmp_deeply(sort @shouldExist, sort @doExist, "exportAsHtml on home writes correct files"); is($success, 1, "exportAsHtml on home returns true"); -like($message, qr/Exported $numberCreatedAll pages/, "exportAsHtml on home returns correct message"); +like($message, qr/Exported 23 pages/, "exportAsHtml on home returns correct message"); $exportPath->rmtree; @doExist = (); @@ -866,17 +861,13 @@ $gettingStarted->update({ isExportable => 0 }); [ qw/ yns support index.html /], [ qw/ yns translated index.html /], [ qw/ your_next_step index.html /], - [ qw/ documentation index.html /], - [ qw/ documentation commercial-documentation index.html /], - [ qw/ documentation free-documentation index.html /], ); -my $numberCreated = scalar @createdFiles; @shouldExist = map { Path::Class::File->new($exportPath, @{$_})->absolute->stringify } @createdFiles; $exportPath->recurse( callback => sub { my $o = shift; $o->is_dir ? return : push @doExist, $o->absolute->stringify } ); -cmp_bag(\@shouldExist, \@doExist, "exportAsHtml on home with non-exportable getting-started writes correct files"); +cmp_deeply(sort @shouldExist, sort @doExist, "exportAsHtml on home with non-exportable getting-started writes correct files"); is($success, 1, "exportAsHtml on home with non-exportable getting-started returns true"); -like($message, qr/Exported $numberCreated pages/, "exportAsHtml on home with non-exportable getting-started returns correct message"); +like($message, qr/Exported 19 pages/, "exportAsHtml on home with non-exportable getting-started returns correct message"); # restore the original setting $gettingStarted->update({ isExportable => 1 }); @@ -915,24 +906,24 @@ $config->delete('exportPath'); # undefined exportPath eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) }; -is($@, '', "exportAsHtml catches undefined exportPath exception"); -is($success, 0, "exportAsHtml returns 0 for undefined exportPath"); +is($@, '', "exportAsHtml catches undefined exportPath exception"); +is($success, 0, "exportAsHtml returns 0 for undefined exportPath"); is($message, 'exportPath must be defined and not ""', "exportAsHtml returns correct message for undefined exportPath"); # inaccessible exportPath $config->set('exportPath', Path::Class::Dir->new('')->stringify); eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) }; -is($@, '', "exportAsHtml catches inaccessible exportPath "); -is($success, 0, "exportAsHtml returns 0 for inaccessible exportPath"); +is($@, '', "exportAsHtml catches inaccessible exportPath "); +is($success, 0, "exportAsHtml returns 0 for inaccessible exportPath"); is($message, "can't access " . Path::Class::Dir->new('')->stringify, "exportAsHtml returns correct message for inaccessible exportPath"); # exportPath is a file, not a directory $config->set('exportPath', $exportPathFile); eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) }; -is($@, '', "exportAsHtml catches exportPath is file exception"); -is($success, 0, "exportAsHtml returns 0 if exportPath is a file"); +is($@, '', "exportAsHtml catches exportPath is file exception"); +is($success, 0, "exportAsHtml returns 0 if exportPath is a file"); is($message, "$exportPathFile isn't a directory", "exportAsHtml returns correct message if exportPath is a file"); # can't create export path @@ -940,8 +931,8 @@ chmod 0000, $tempDirectory; $config->set('exportPath', $inaccessibleDirectory->stringify); eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) }; -is($@, '', "exportAsHtml catches uncreatable exportPath exception"); -is($success, 0, "exportAsHtml returns 0 for uncreatable exportPath"); +is($@, '', "exportAsHtml catches uncreatable exportPath exception"); +is($success, 0, "exportAsHtml returns 0 for uncreatable exportPath"); is($message, "can't create exportPath $inaccessibleDirectory", "exportAsHtml returns correct message for uncreatable exportPath"); # user can't view asset @@ -975,21 +966,18 @@ $exportPath->rmtree; ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99, extrasUploadAction => 'symlink', quiet => 1 } ); $extrasSymlink = Path::Class::File->new($exportPath, $extrasUrl); $uploadsSymlink = Path::Class::File->new($exportPath, $uploadsUrl); - -is($success, 1, "exportAsHtml when linking extras and uploads returns true"); -like($message, qr/Exported $numberCreatedAll pages/, "exportAsHtml when linking extras and uploads returns correct message"); - -ok(-e $extrasSymlink->absolute->stringify, "exportAsHtml writes extras symlink"); +is($success, 1, "exportAsHtml when linking extras and uploads returns true"); +like($message, qr/Exported 23 pages/, "exportAsHtml when linking extras and uploads returns correct message"); +ok(-e $extrasSymlink->absolute->stringify, "exportAsHtml writes extras symlink"); is($extrasPath, readlink $extrasSymlink->absolute->stringify, "exportAsHtml extras symlink points to right place"); - -ok(-e $uploadsSymlink->absolute->stringify, "exportAsHtml writes uploads symlink"); +ok(-e $uploadsSymlink->absolute->stringify, "exportAsHtml writes uploads symlink"); is($uploadsPath, readlink $uploadsSymlink->absolute->stringify, "exportAsHtml uploads symlink points to right place"); # next, make sure the root URL symlinking works. ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99, rootUrlAction => 'symlink', quiet => 1 } ); my $rootUrlSymlink = Path::Class::File->new($exportPath, 'index.html'); is($success, 1, 'exportAsHtml when linking root URL returns true'); -like($message, qr/Exported $numberCreatedAll pages/, "exportAsHtml when linking root URL returns correct message"); +like($message, qr/Exported 23 pages/, "exportAsHtml when linking root URL returns correct message"); ok(-e $rootUrlSymlink->absolute->stringify, "exportAsHtml writes root URL symlink"); is($home->exportGetUrlAsPath->absolute->stringify, readlink $rootUrlSymlink->absolute->stringify, "exportAsHtml root URL symlink points to right place"); diff --git a/t/Asset/AssetPackage.t b/t/Asset/AssetPackage.t index 0141d1648..1e6bdf0c7 100644 --- a/t/Asset/AssetPackage.t +++ b/t/Asset/AssetPackage.t @@ -97,7 +97,6 @@ sub hack_session_request { return $id }, ); - $request->mock('param', sub { shift->body(@_) }); $session->{_request} = $request; } diff --git a/t/Asset/File/GalleryFile/Photo/view.t b/t/Asset/File/GalleryFile/Photo/view.t index 6426bcfae..d03d51db3 100644 --- a/t/Asset/File/GalleryFile/Photo/view.t +++ b/t/Asset/File/GalleryFile/Photo/view.t @@ -79,7 +79,7 @@ my $testTemplateVars = { url_listFilesForOwner => $gallery->getUrl('func=listFilesForUser;userId=3'), url_promote => $photo->getUrl('func=promote'), - url_album => $album->getUrl('pn=1'), + url_album => $album->getUrl, url_thumbnails => $album->getUrl('func=thumbnails'), url_slideshow => $album->getUrl('func=slideshow'), fileUrl => $photo->getFileUrl, diff --git a/t/Asset/Sku/Product.t b/t/Asset/Sku/Product.t index 91de3033e..fce39fbbc 100644 --- a/t/Asset/Sku/Product.t +++ b/t/Asset/Sku/Product.t @@ -34,11 +34,13 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 8; # Increment this number for each test you create +plan tests => 7; # Increment this number for each test you create #---------------------------------------------------------------------------- # put your tests here -my $node = WebGUI::Asset->getRoot($session); +my $node = WebGUI::Asset::Sku::Product->getProductImportNode($session); +isa_ok($node, 'WebGUI::Asset::Wobject::Folder', 'getProductImportNode returns a Folder'); +is($node->getId, 'PBproductimportnode001', 'Product Import Node has the correct GUID'); my $product = $node->addChild({ className => "WebGUI::Asset::Sku::Product", @@ -51,10 +53,9 @@ my $image = WebGUI::Storage::Image->create($session); $image->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg')); my $imagedProduct = $node->addChild({ - className => "WebGUI::Asset::Sku::Product", - title => "Bible", - image1 => $image->getId, - isShippingRequired => 1, + className => "WebGUI::Asset::Sku::Product", + title => "Bible", + image1 => $image->getId, }); ok($imagedProduct->getThumbnailUrl(), 'getThumbnailUrl is not empty'); @@ -66,24 +67,6 @@ $otherImage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('gooey.jp ok($imagedProduct->getThumbnailUrl($otherImage), 'getThumbnailUrl with an explicit storageId returns something'); is($imagedProduct->getThumbnailUrl($otherImage), $otherImage->getThumbnailUrl('gooey.jpg'), 'getThumbnailUrl with an explicit storageId returns the right path to the URL'); -is($imagedProduct->get('isShippingRequired'), 1, 'isShippingRequired set to 1 in db'); -is($imagedProduct->isShippingRequired, 1, 'isShippingRequired accessor works'); - -my $englishVarId = $imagedProduct->setCollateral('variantsJSON', 'variantId', 'new', - { - shortdesc => 'English', - varSku => 'english-bible', - price => 10, - weight => 5, - quantity => 1000, - } -); - -use Data::Dumper; -$imagedProduct->applyOptions($imagedProduct->getCollateral('variantsJSON', 'variantId', $englishVarId)); - -is($imagedProduct->getConfiguredTitle, 'Bible - English', 'getConfiguredTitle is overridden and concatenates the Product Title and the variant shortdesc'); - #---------------------------------------------------------------------------- # Cleanup END { diff --git a/t/Asset/Sku/ProductCollateral.t b/t/Asset/Sku/ProductCollateral.t index d9bc039e7..46f9508e1 100644 --- a/t/Asset/Sku/ProductCollateral.t +++ b/t/Asset/Sku/ProductCollateral.t @@ -55,7 +55,7 @@ ok($session->id->valid($vid), 'a valid id was generated for the new collateral e my $json; $json = $product->get('variantsJSON'); -my $jsonData = decode_json($json); +my $jsonData = from_json($json); cmp_deeply( $jsonData, [ {a => 'aye', b => 'bee', vid => $vid } ], diff --git a/t/Asset/Wobject/GalleryAlbum/view.t b/t/Asset/Wobject/GalleryAlbum/view.t index 69d4ae2a0..b67c49497 100644 --- a/t/Asset/Wobject/GalleryAlbum/view.t +++ b/t/Asset/Wobject/GalleryAlbum/view.t @@ -69,27 +69,18 @@ plan tests => 7; #---------------------------------------------------------------------------- # Test getFileIds and getFilePaginator -cmp_bag( $album->getFileIds, [ map { $_->getId } @photos ], 'getFileIds returns ids of all photos' ); +cmp_bag( $album->getFileIds, [ map { $_->getId } @photos ] ); my $p = $album->getFilePaginator; isa_ok( $p, "WebGUI::Paginator" ); -cmp_deeply( $p->getPageData, subbagof( map { $_->getId } @photos ), 'getPageData contains a subset of the ids o the photos'); +cmp_deeply( $p->getPageData, subbagof( map { $_->getId } @photos ) ); #---------------------------------------------------------------------------- # Test getTemplateVars # Is a superset of Asset->get # NOTE: url is Asset->getUrl -# NOTE: undef description remapped to empty string '' -cmp_deeply( - $album->getTemplateVars, - superhashof( { - %{$album->get}, - url => $album->getUrl, - description => '', - } ), - q|getTemplateVariables returns the Album's asset properties| -); +cmp_deeply( $album->getTemplateVars, superhashof( { %{$album->get}, url => $album->getUrl, } ) ); # Contains specific keys/values my $expected = { @@ -123,7 +114,7 @@ my $expected = { => WebGUI::User->new($session, 3)->username, }; -cmp_deeply( $album->getTemplateVars, superhashof( $expected ), '... and also returns a set of other template variables' ); +cmp_deeply( $album->getTemplateVars, superhashof( $expected ) ); #---------------------------------------------------------------------------- # Test appendTemplateVarsFileLoop diff --git a/t/Asset/Wobject/SyndicatedContent.t b/t/Asset/Wobject/SyndicatedContent.t index 0052cf42d..dc6a788bd 100644 --- a/t/Asset/Wobject/SyndicatedContent.t +++ b/t/Asset/Wobject/SyndicatedContent.t @@ -25,7 +25,7 @@ use WebGUI::Asset::Wobject::SyndicatedContent; my $session = WebGUI::Test->session; my %var; -my (@rss_feeds); +my ($items, @rss_feeds); ############################## ## SETUP ## @@ -99,10 +99,8 @@ my $rss_info = WebGUI::Asset::Wobject::SyndicatedContent::_get_rss_data($session ok(ref($rss_info) eq 'HASH', "Hashref returned from _get_rss_data"); push(@rss_feeds, $rss_info); - -my $items = []; -WebGUI::Asset::Wobject::SyndicatedContent::_create_interleaved_items($items, \@rss_feeds , $max_headlines, $hasTermsRegex); -ok($items , "Got results back from XML" ); +my $xml_list = WebGUI::Asset::Wobject::SyndicatedContent::_create_interleaved_items($items, \@rss_feeds , $max_headlines, $hasTermsRegex); +ok($xml_list , "Got results back from XML " ); my($item_loop,$rss_feeds) = $syndicated_content->_get_items(\@validated_urls, $max_headlines); ok(ref($item_loop) eq 'ARRAY',"Arrayref of items returned from _get_items" );