fix bugs revealed by Test::Class tests
This commit is contained in:
parent
1de9a12365
commit
664e7686c6
16 changed files with 93 additions and 75 deletions
|
|
@ -2282,8 +2282,6 @@ sub processEditForm {
|
|||
}
|
||||
}
|
||||
|
||||
$self->session->log->info( Dumper \%data );
|
||||
|
||||
$self->session->db->beginTransaction;
|
||||
$self->update( \%data );
|
||||
$self->session->db->commit;
|
||||
|
|
@ -2939,7 +2937,7 @@ sub www_editSave {
|
|||
});
|
||||
if ($commitStatus eq 'redirect') {
|
||||
##Redirect set by tag. Return nothing to send the user over to the redirect.
|
||||
return undef;
|
||||
return 'redirect';
|
||||
}
|
||||
elsif ($commitStatus eq 'commit') {
|
||||
##Commit was successful. Update the local object cache so that it will no longer
|
||||
|
|
|
|||
|
|
@ -628,25 +628,6 @@ sub view {
|
|||
return $out;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit
|
||||
|
||||
Display the edit form to the user. Manually handles the template for displaying
|
||||
the inline view of the asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $f = $self->getEditForm;
|
||||
return $self->getAdminConsole->render($f->print,$self->addEditLabel);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view
|
||||
|
|
|
|||
|
|
@ -237,24 +237,6 @@ sub view {
|
|||
return $out;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
||||
Web facing method which is the default edit page
|
||||
|
||||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_Wobject');
|
||||
my $addEdit = ($self->session->form->process("func") eq 'add') ? $i18n->get('add') : $i18n->get('edit');
|
||||
return $self->getAdminConsole->render($self->getEditForm->toHtml, $self->addEditLabel);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view ( )
|
||||
|
|
|
|||
|
|
@ -833,7 +833,7 @@ sub www_edit {
|
|||
my $var = $self->get;
|
||||
my $matrix = $self->getParent;
|
||||
# TODO: Change to FormBuilder
|
||||
$var->{form} = $self->getEditForm->print;
|
||||
$var->{form} = $self->getEditForm->toHtml;
|
||||
|
||||
return $matrix->processStyle($self->processTemplate($var,$matrix->get("editListingTemplateId")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1128,6 +1128,7 @@ override processEditForm => sub {
|
|||
}
|
||||
delete $self->{_storageLocation};
|
||||
$self->postProcess;
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1593,7 +1594,7 @@ sub www_edit {
|
|||
});
|
||||
$var{'form.header'} .= WebGUI::Form::hidden($session, {
|
||||
name=>"revision",
|
||||
value=>$form->param("revision")
|
||||
value=>$form->param("revision") || $self->revisionDate
|
||||
});
|
||||
$var{'form.header'} .= WebGUI::Form::hidden($session, {
|
||||
name=>"ownerUserId",
|
||||
|
|
|
|||
|
|
@ -122,12 +122,14 @@ sub www_view {
|
|||
my $url = $self->redirectUrl;
|
||||
WebGUI::Macro::process($self->session, \$url);
|
||||
if ($self->session->isAdminOn() && $self->canEdit) {
|
||||
return $self->getAdminConsole->render($i18n->get("what do you want to do with this redirect").'
|
||||
return '<h1>' . $i18n->get('assetName') . '</h1>'
|
||||
. $i18n->get("what do you want to do with this redirect").'
|
||||
<ul>
|
||||
<li><a href="'.$url.'">'.$i18n->get("go to the redirect url").'</a></li>
|
||||
<li><a href="'.$self->getUrl("func=edit").'">'.$i18n->get("edit the redirect properties").'</a></li>
|
||||
<li><a href="'.$self->getParent->getUrl.'">'.$i18n->get("go to the redirect parent page").'</a></li>
|
||||
</ul>',$i18n->get("assetName"));
|
||||
</ul>'
|
||||
;
|
||||
}
|
||||
unless ($url eq $self->url) {
|
||||
$self->session->response->setRedirect($url,$self->redirectType);
|
||||
|
|
|
|||
|
|
@ -94,14 +94,11 @@ override getEditForm => sub {
|
|||
$self->session->style->setScript($self->session->url->extras('wobject/Carousel/carousel.js'), {type =>
|
||||
'text/javascript'});
|
||||
|
||||
my $tableRowStart =
|
||||
'<tr id="items_row">'
|
||||
.' <td class="formDescription" valign="top" style="width: 180px;"><label for="item1">'
|
||||
.$i18n->get("items label").'</label><div class="wg-hoverhelp">'.$i18n->get("items description").'</div></td>'
|
||||
.' <td id="items_td" valign="top" class="tableData">'
|
||||
.' <input type="hidden" id="items_formId" name="items" />'
|
||||
.' <input type="button" value="Add item" onclick="window.carouselEditor.addTab()"></input><br />'
|
||||
." <br />\n";
|
||||
my $tableRowStart = ' <label for="item1">'
|
||||
. $i18n->get("items label").'</label><div class="wg-hoverhelp">'.$i18n->get("items description").'</div>'
|
||||
. ' <input type="hidden" id="items_formId" name="items" />'
|
||||
. ' <input type="button" value="Add item" onclick="window.carouselEditor.addTab()"></input><br />'
|
||||
. " <br />\n";
|
||||
|
||||
$tabform->getTab("properties")->addField('ReadOnly', value => $tableRowStart);
|
||||
|
||||
|
|
@ -161,7 +158,7 @@ onClick='javascript:deleteItem(this.id)'></input>\n"
|
|||
$items = JSON->new->encode( $items );
|
||||
my $i18nJson = JSON->new->encode( { "delete" => $i18n->get("delete") } );
|
||||
|
||||
$tabform->getTab('properties')->raw(<<"ENDHTML");
|
||||
$tabform->getTab('properties')->addField( "ReadOnly", name => 'editor', value => <<"ENDHTML");
|
||||
<div id="carouselEditor"></div>
|
||||
<script type="text/javascript">
|
||||
$loadMcePlugins
|
||||
|
|
@ -171,12 +168,6 @@ onClick='javascript:deleteItem(this.id)'></input>\n"
|
|||
</script>
|
||||
ENDHTML
|
||||
|
||||
my $tableRowEnd = qq|
|
||||
</td>
|
||||
</tr>
|
||||
|;
|
||||
$tabform->getTab("properties")->addField('ReadOnly', value => $tableRowEnd);
|
||||
|
||||
return $tabform;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -204,7 +204,6 @@ sub getLanguages {
|
|||
my ($self) = @_;
|
||||
my $hashRef;
|
||||
for my $lang ( findsubmod 'WebGUI::i18n' ) {
|
||||
$self->session->log->info( "Found language $lang" );
|
||||
$lang =~ s/^WebGUI::i18n:://;
|
||||
$hashRef->{$lang} = $self->getLanguage($lang, "label");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package WebGUI::Role::Asset::Dashlet;
|
||||
|
||||
use Moose::Role;
|
||||
use JSON;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ sub fetchUserOverrides {
|
|||
my $userId = shift || $self->session->user->userId;
|
||||
my $properties_json = $self->session->db->quickScalar('select properties from Dashboard_userPrefs where dashboardAssetId=? and userId=? and dashletAssetId=?',[$dashboardAssetId, $userId, $self->getId,]);
|
||||
$properties_json ||= '{}';
|
||||
my $properties = from_json($properties_json);
|
||||
my $properties = JSON->new->decode($properties_json);
|
||||
return $properties;
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +116,7 @@ sub storeUserOverrides {
|
|||
my $dashboardAssetId = shift;
|
||||
my $properties = shift;
|
||||
my $userId = shift || $session->user->userId;
|
||||
my $properties_json = to_json($properties);
|
||||
my $properties_json = JSON->new->encode($properties);
|
||||
$session->db->write('DELETE FROM Dashboard_userPrefs where dashboardAssetId=? and userId=? and dashletAssetId=?',[$dashboardAssetId, $userId, $self->getId]);
|
||||
$session->db->write('INSERT INTO Dashboard_userPrefs (dashboardAssetId, userId, dashletAssetId, properties) VALUES (?,?,?,?)', [$dashboardAssetId, $userId, $self->getId, $properties_json]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ use Test::Exception;
|
|||
use WebGUI::Test;
|
||||
use Data::Dumper;
|
||||
use List::MoreUtils;
|
||||
use WebGUI::Test::Mechanize;
|
||||
|
||||
use UNIVERSAL::isa;
|
||||
no warnings 'UNIVERSAL::isa';
|
||||
|
||||
# XXXX fix the Test(n) numbers to match reality
|
||||
|
||||
|
|
@ -109,16 +113,25 @@ sub getAnchoredAsset {
|
|||
status => "pending",
|
||||
tagId => $tag->getId,
|
||||
$test->constructorExtras($session),
|
||||
}, undef, undef, {skipNotification => 1});
|
||||
}, undef, (time-10), {skipNotification => 1});
|
||||
# warn "XXX getAnchoredAsset: created new asset of Id: " . $asset->getId . ' of type: ' . ref $asset;
|
||||
$tag->commit;
|
||||
foreach my $a ($asset, @parents) {
|
||||
$a = $a->cloneFromDb;
|
||||
}
|
||||
WebGUI::Test->addToCleanup($tag);
|
||||
$test->{_currentTag} = $tag;
|
||||
return ($tag, $asset, @parents);
|
||||
}
|
||||
|
||||
sub deleteAssets : Test(teardown) {
|
||||
my ( $test ) = shift;
|
||||
if ( $test->{_currentTag} ) {
|
||||
$test->{_currentTag}->rollback;
|
||||
delete $test->{_currentTag};
|
||||
}
|
||||
}
|
||||
|
||||
sub getMyParents {
|
||||
my $test = shift;
|
||||
my $session = $test->session;
|
||||
|
|
@ -127,17 +140,17 @@ sub getMyParents {
|
|||
my $default = WebGUI::Asset->getDefault($session);
|
||||
push @parents, $default;
|
||||
my $parent = $default;
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
my $tag = WebGUI::VersionTag->getWorking( $session );
|
||||
foreach my $parent_class (@{ $parent_classes }) {
|
||||
my $new_parent = $parent->addChild(
|
||||
{
|
||||
className => $parent_class,
|
||||
status => "pending",
|
||||
tagId => $tag->getId,
|
||||
$test->constructorExtras($session),
|
||||
status => 'pending',
|
||||
tagId => $tag->getId,
|
||||
},
|
||||
undef,
|
||||
undef,
|
||||
(time-10),
|
||||
{skipNotification => 1,},
|
||||
);
|
||||
push @parents, $new_parent;
|
||||
|
|
@ -564,8 +577,6 @@ sub t_20_www_editSave : Tests {
|
|||
$asset->groupIdEdit( 7 ); # Everybody! Everybody!
|
||||
|
||||
$asset->commit;
|
||||
$tag->setWorking;
|
||||
sleep 2; # XXXX Todo -- investigate whether this is actually fixing duplicate commit problems
|
||||
|
||||
my %mergedProperties = (
|
||||
formProperties($asset),
|
||||
|
|
@ -577,15 +588,28 @@ sub t_20_www_editSave : Tests {
|
|||
# local $SIG{__DIE__} = sub { use Carp; Carp::confess "@_"; };
|
||||
# local $SIG{__DIE__} = sub { use wth; wth::wth "@_"; }; # see note above about wth
|
||||
|
||||
$session->request->setup_body( \%mergedProperties );
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get('/');
|
||||
$mech->session->user({ userId => 3 });
|
||||
$tag = WebGUI::VersionTag->getWorking( $mech->session );
|
||||
$tag->setWorking;
|
||||
$mech->get_ok( $asset->getUrl('func=edit') );
|
||||
|
||||
my $content;
|
||||
ok(eval { $asset->www_editSave; }, 'www_editSave returns true');
|
||||
debug($@);
|
||||
undef $@;
|
||||
my $form_content = $mech->content;
|
||||
if ( $test->isa( 'Test::WebGUI::Asset::File::GalleryFile::Photo' )
|
||||
|| $test->isa( 'Test::WebGUI::Asset::Wobject::GalleryAlbum' )
|
||||
|| $test->isa( 'Test::WebGUI::Asset::Event' )
|
||||
) {
|
||||
$session->log->info( $form_content );
|
||||
}
|
||||
$mech->submit_form_ok( {
|
||||
fields => \%mergedProperties,
|
||||
},
|
||||
"submit www_editSave form"
|
||||
);
|
||||
|
||||
# Get the newly-created revision of the asset
|
||||
ok( my $newRevision = eval { WebGUI::Asset->newPending( $session, $asset->getId ); }, 'newPending returns true' );
|
||||
ok( my $newRevision = eval { WebGUI::Asset->newPending( $mech->session, $asset->getId ); }, 'newPending returns true' );
|
||||
debug($@);
|
||||
undef $@;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,4 +24,10 @@ sub parent_list {
|
|||
return ['WebGUI::Asset::Wobject::Calendar'];
|
||||
}
|
||||
|
||||
sub postProcessMergedProperties {
|
||||
my ( $test, $props ) = @_;
|
||||
$props->{startDate} = "2010-01-01";
|
||||
$props->{endDate} = "2010-01-02";
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -25,4 +25,9 @@ sub parent_list {
|
|||
return [ map { "WebGUI::Asset::$_"} qw/Wobject::Collaboration Post::Thread/ ];
|
||||
}
|
||||
|
||||
sub postProcessMergedProperties {
|
||||
my ( $test, $props ) = @_;
|
||||
$props->{func} = "editSave"; # func defaults to preview mode
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -25,4 +25,9 @@ sub list_of_tables {
|
|||
return [qw/assetData snippet/];
|
||||
}
|
||||
|
||||
sub postProcessMergedProperties {
|
||||
my ( $test, $props ) = @_;
|
||||
$props->{snippet} = "some text";
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -21,4 +21,17 @@ sub list_of_tables {
|
|||
return [qw/assetData wobject Carousel/];
|
||||
}
|
||||
|
||||
sub postProcessMergedProperties {
|
||||
my ( $test, $props ) = @_;
|
||||
$props->{something} = JSON->new->encode({
|
||||
items => [
|
||||
{
|
||||
sequenceNumber => 1,
|
||||
text => "Item 1",
|
||||
},
|
||||
],
|
||||
});
|
||||
return $props;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -25,4 +25,9 @@ sub parent_list {
|
|||
return [qw/WebGUI::Asset::Wobject::Gallery/];
|
||||
}
|
||||
|
||||
sub postProcessMergedProperties {
|
||||
my ( $test, $props ) = @_;
|
||||
$props->{save} = "save"; # GalleryAlbum www_edit checks for this to go to editSave
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -25,4 +25,9 @@ sub list_of_tables {
|
|||
return [qw/assetData wobject SQLReport/];
|
||||
}
|
||||
|
||||
sub postProcessMergedProperties {
|
||||
my ( $test, $props ) = @_;
|
||||
$props->{dbQuery1} = "SELECT * FROM users";
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue