diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 11566be53..5f97e5d2e 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -20,6 +20,7 @@ - fixed #12001: Shelf product import mangles price - fixed #11945: Slow SQL access for duplicate e-mail address lookups - fixed #11960: Billing address mandatory fields not specified + - fixed #11975: Cannot paste threads: "Cannot call method isa()" 7.10.6 - fixed #11974: Toolbar icons unclickable in Webkit using HTML5 diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index f81565959..9289979f0 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -317,6 +317,7 @@ sub pasteInFork { my ( $process, $args ) = @_; my $session = $process->session; my $self = WebGUI::Asset->new( $session, $args->{assetId} ); + $session->asset( $self ); my @roots = grep { $_ && $_->canEdit } map { WebGUI::Asset->newPending( $session, $_ ) } @{ $args->{list} }; diff --git a/t/Asset/AssetClipboard.t b/t/Asset/AssetClipboard.t index 526425e50..acf95a1e0 100644 --- a/t/Asset/AssetClipboard.t +++ b/t/Asset/AssetClipboard.t @@ -21,9 +21,11 @@ use WebGUI::Utility; use WebGUI::Asset; use WebGUI::VersionTag; use Test::MockObject; +use Test::MockObject::Extends; +use WebGUI::Fork; use Test::More; # increment this value for each test you create -plan tests => 29; +plan tests => 30; my $session = WebGUI::Test->session; $session->user({userId => 3}); @@ -200,3 +202,34 @@ $shortcut->publish; $page->cut; is $shortcut->paste($page->getId), 0, 'cannot paste below shortcuts'; + +#################################################### +# +# pasteInFork +# +#################################################### + +$session->user({ userId => "3" }); +my $process = Test::MockObject::Extends->new( 'WebGUI::Fork' ); +$process->mock( "update" => sub { } ); # do nothing on update. we don't care +$process->mock( "session" => sub { return $session } ); + +# Try with a Collaboration and some Threads +my $tag = WebGUI::VersionTag->getWorking( $session ); +my $collab = $tempspace->addChild({ + className => 'WebGUI::Asset::Wobject::Collaboration', + groupIdEdit => "3", + status => "pending", + tagId => $tag->getId, +}); +my $thread = $collab->addChild({ + className => 'WebGUI::Asset::Post::Thread', + groupIdEdit => "3", + status => "pending", + tagId => $tag->getId, +}, undef, undef, { skipAutoCommitWorkflows => 1 }); +$tag->commit; +$thread->cut; +WebGUI::Asset::pasteInFork( $process, { assetId => $collab->getId, list => [ $thread->getId ] } ); +$thread = $thread->cloneFromDb; +is( $thread->get('state'), 'published', 'thread is pasted' );