diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index bd3011e71..70b095816 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -51,6 +51,7 @@ - fixed #11005: calendar feed workflow - fixed #11008: Test::Class - fixed #11003: Subscribable AssetAspect: no i18n + - fixed #11004: Subscribable AssetAspect: handling the subscription group 7.7.19 - fixed #10838: Forwarded forum post email to new CS adds reply to original thread diff --git a/lib/WebGUI/AssetAspect/Subscribable.pm b/lib/WebGUI/AssetAspect/Subscribable.pm index 3c0b6f0e9..bada309bd 100644 --- a/lib/WebGUI/AssetAspect/Subscribable.pm +++ b/lib/WebGUI/AssetAspect/Subscribable.pm @@ -62,6 +62,23 @@ sub definition { #---------------------------------------------------------------------------- +=head2 duplicate ( [ options ] ) + +Subclass the method to create a new group for subscribers for the new asset. + +=cut + +sub duplicate { + my $self = shift; + my $properties = shift; + my $newSelf = $self->next::method( $properties ); + $newSelf->update({ subscriptionGroupId => '' }); + $newSelf->createSubscriptionGroup; + return $newSelf; +} + +#---------------------------------------------------------------------------- + =head2 addRevision ( properties [, revisionDate, options ] ) Override addRevision to set skipNotification to 0 for each new revision. @@ -405,6 +422,25 @@ sub notifySubscribers { #---------------------------------------------------------------------------- +=head2 purge ( ) + +Subclass the method to remove the subscription group. + +=cut + +sub purge { + my $self = shift; + my $options = shift; + + my $group = $self->getSubscriptionGroup(); + $group->delete; + $self->next::method($options); + + return; +} + +#---------------------------------------------------------------------------- + =head2 setSkipNotification ( ) Set a flag so that this asset does not send out notifications for this diff --git a/t/Asset/Wobject/WikiMaster/subscribable.t b/t/Asset/Wobject/WikiMaster/subscribable.t index 2fbff29d7..443009d5f 100644 --- a/t/Asset/Wobject/WikiMaster/subscribable.t +++ b/t/Asset/Wobject/WikiMaster/subscribable.t @@ -19,6 +19,7 @@ use lib "$FindBin::Bin/../../../lib"; use Test::More; use WebGUI::Test; # Must use this before any other WebGUI modules use WebGUI::Session; +use WebGUI::Group; #---------------------------------------------------------------------------- # Init @@ -36,7 +37,7 @@ WebGUI::Test->tagsToRollback( WebGUI::VersionTag->getWorking( $session ) ); #---------------------------------------------------------------------------- # Tests -plan tests => 17; # Increment this number for each test you create +plan tests => 20; # Increment this number for each test you create #---------------------------------------------------------------------------- # Test subscribable methods @@ -92,6 +93,26 @@ ok( !$new_rev->get('skipNotification'), 'addRevision resets skipNotification to # notify subscribers # subscription content +#---------------------------------------------------------------------------- +# duplication + +my $otherWiki = $wiki->duplicate({ skipAutoCommitWorkflows => 1 }); +ok($otherWiki->get('subscriptionGroupId'), 'duplicate: duplicated wiki got a subscription group'); +isnt( + $wiki->get('subscriptionGroupId'), + $otherWiki->get('subscriptionGroupId'), + 'and it is a different group from the original wiki' +); + +#---------------------------------------------------------------------------- +# purging + +my $otherGroup = $otherWiki->getSubscriptionGroup(); +$otherWiki->purge; + +my $groupShouldBeGone = WebGUI::Group->new($session, $otherGroup->getId); +is(ref $groupShouldBeGone, '', 'purge: cleaned up the subscription group'); + #---------------------------------------------------------------------------- # Cleanup