Do not send emails when a Post or Thread is copied inside WebGUI. Fixes bug #12024.

This commit is contained in:
Colin Kuskie 2011-01-19 18:43:33 -08:00
parent ca54f439e9
commit 8c2958b042
3 changed files with 41 additions and 4 deletions

View file

@ -2,6 +2,7 @@
- rfe #12016 for the top story as well
- fixed #11965: Friend Manager only shows 15 people
- fixed #12023: International URLs of aattachments & files in folder
- fixed #12024: Copied Collaboration System re-sends subscription mail
7.10.7
- rfe #10521: Use monospaced font in template edit textarea

View file

@ -150,6 +150,10 @@ A hash reference of options that can modify how this method works.
Assets that normally autocommit their workflows (like CS Posts, and Wiki Pages) won't if this is true.
=head4 skipNotification
Disable sending a notification that a new revision was added, for those assets that support it.
=head4 state
A state for the duplicated asset (defaults to 'published')
@ -160,8 +164,15 @@ sub duplicate {
my $self = shift;
my $options = shift;
my $parent = $self->getParent;
##Remove state and pass all other options along to addChild
my $asset_state = delete $options->{state};
my $newAsset
= $parent->addChild( $self->get, undef, $self->get("revisionDate"), { skipAutoCommitWorkflows => $options->{skipAutoCommitWorkflows} } );
= $parent->addChild(
$self->get,
undef,
$self->get("revisionDate"),
$options,
);
if (! $newAsset) {
$self->session->log->error(
@ -189,8 +200,8 @@ sub duplicate {
keywords => $keywords,
} );
if (my $state = $options->{state}) {
$newAsset->setState($state);
if ($asset_state) {
$newAsset->setState($asset_state);
}
return $newAsset;

View file

@ -16,7 +16,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 => 12; # increment this value for each test you create
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Post::Thread;
@ -101,5 +101,30 @@ is $url,
$expected_url,
'url UTF8 checks out';
my $before_copy = $session->db->quickScalar('select count(*) from mailQueue');
{
##Disable sending email
my $sendmock = Test::MockObject->new( {} );
$sendmock->set_isa('WebGUI::Mail::Send');
$sendmock->set_true('addText', 'send', 'addHeaderField', 'addHtml', 'queue', 'addFooter');
my $was_sent = 0;
my $was_queued = 0;
$sendmock->set_bound('send', $was_sent);
$sendmock->set_bound('queue', $was_queued);
local *WebGUI::Mail::Send::create;
$sendmock->fake_module('WebGUI::Mail::Send',
create => sub { return $sendmock },
);
my $t1p1_copy = $t1p1->duplicate();
WebGUI::Test->addToCleanup($t1p1_copy);
is $was_sent, 0, 'email not sent when Post is duplicated';
is $was_queued, 0, '... nor queued';
my $after_copy = $session->db->quickScalar('select count(*) from mailQueue');
is $after_copy, $before_copy, '... and no additional mails in the queue';
}
#vim:ft=perl