diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index e689502a2..e2110daf5 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -195,13 +195,14 @@ sub getChildCount { =head2 getDescendantCount ( ) -Returns the number of descendants this asset has. This excludes assets in the trash or clipboard. +Returns the number of descendants this asset has. This includes only assets that are published, and not +in the clipboard or trash. =cut sub getDescendantCount { my $self = shift; - my ($count) = $self->session->db->quickArray("select count(*) from asset where state in ('published', 'archived') and lineage like ?", [$self->get("lineage")."%"]); + my ($count) = $self->session->db->quickArray("select count(*) from asset, assetData where asset.assetId=assetData.assetId and asset.state = 'published' and assetData.status in ('approved','archived') and asset.lineage like ?", [$self->get("lineage")."%"]); $count--; # have to subtract self return $count; } diff --git a/t/Asset/AssetLineage.t b/t/Asset/AssetLineage.t index 06b36d2e7..81bdc162c 100644 --- a/t/Asset/AssetLineage.t +++ b/t/Asset/AssetLineage.t @@ -17,7 +17,7 @@ use WebGUI::Session; use WebGUI::User; use WebGUI::Asset; -use Test::More tests => 82; # increment this value for each test you create +use Test::More tests => 83; # increment this value for each test you create use Test::Deep; # Test the methods in WebGUI::AssetLineage @@ -135,9 +135,13 @@ is(2, $topFolder->getChildCount, 'getChildCount: restored original setup for nex # #################################################### -is(10, $topFolder->getDescendantCount, 'getDescendantCount on top folder'); -is(scalar @snippets, $folder->getDescendantCount, 'getDescendantCount on folder with several children'); -is(1, $folder2->getDescendantCount, 'getDescendantCount on folder with 1 child'); +is($topFolder->getDescendantCount, 10, 'getDescendantCount on top folder'); +is($folder->getDescendantCount, scalar @snippets, 'getDescendantCount on folder with several children'); +is($folder2->getDescendantCount, 1, 'getDescendantCount on folder with 1 child'); + +$folder->update({status => 'pending'}); +is($topFolder->getDescendantCount, 9, 'getDescendantCount with one child pending'); +$folder->update({status => 'approved'}); #################################################### #