Merge commit 'v7.10.17' into 8
Conflicts: docs/upgrades/upgrade_7.9.13-7.10.0.pl lib/WebGUI.pm lib/WebGUI/Asset/Template/TemplateToolkit.pm lib/WebGUI/Asset/Wobject/AssetReport.pm lib/WebGUI/Asset/Wobject/Thingy.pm lib/WebGUI/Form/Captcha.pm lib/WebGUI/Macro/AdminBar.pm lib/WebGUI/Shop/Cart.pm lib/WebGUI/Shop/PayDriver.pm lib/WebGUI/Shop/PayDriver/PayPal/ExpressCheckout.pm lib/WebGUI/Shop/PayDriver/PayPal/PayPalStd.pm lib/WebGUI/Shop/Transaction.pm lib/WebGUI/Workflow/Instance.pm lib/WebGUI/Workflow/Spectre.pm lib/WebGUI/i18n/English/PayDriver.pm t/Asset/Asset.t t/Asset/AssetExportHtml.t t/Asset/AssetLineage.t t/Asset/Wobject/Thingy.t
This commit is contained in:
commit
795d88e7e5
69 changed files with 972 additions and 170 deletions
|
|
@ -15,7 +15,7 @@ use strict;
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 39; # increment this value for each test you create
|
||||
use Test::More tests => 47; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use JSON;
|
||||
use WebGUI::Asset::Wobject::Thingy;
|
||||
|
|
@ -123,6 +123,7 @@ cmp_deeply(
|
|||
field_loop=>[],
|
||||
exportMetaData=>undef,
|
||||
maxEntriesPerUser=>undef,
|
||||
maxEntriesTotal=>undef,
|
||||
},
|
||||
'Getting newly added thing as JSON: www_getThingViaAjax returns correct data as JSON.'
|
||||
);
|
||||
|
|
@ -166,6 +167,7 @@ cmp_deeply(
|
|||
canSearch=>1,
|
||||
exportMetaData=>undef,
|
||||
maxEntriesPerUser=>undef,
|
||||
maxEntriesTotal=>undef,
|
||||
}],
|
||||
'Getting all things in Thingy as JSON: www_getThingsViaAjax returns correct data as JSON.'
|
||||
);
|
||||
|
|
@ -347,6 +349,56 @@ ok( $thingy->hasEnteredMaxPerUser($otherThingId), 'hasEnteredMaxPerUser returns
|
|||
);
|
||||
}
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# maxEntriesTotal
|
||||
#
|
||||
#################################################################
|
||||
|
||||
my %otherThingProperties = %thingProperties;
|
||||
$otherThingProperties{maxEntriesTotal} = 1;
|
||||
$otherThingProperties{editTemplateId } = $templateId;
|
||||
my $otherThingId = $thingy->addThing(\%otherThingProperties, 0);
|
||||
my %otherFieldProperties = %fieldProperties;
|
||||
$otherFieldProperties{thingId} = $otherThingId;
|
||||
my $otherFieldId = $thingy->addField(\%otherFieldProperties, 0);
|
||||
ok( ! $thingy->hasEnteredMaxEntries($otherThingId), 'hasEnteredMaxEntries: returns false with no data entered');
|
||||
|
||||
my @edit_thing_form_fields = qw/form_start form_end form_submit field_loop/;
|
||||
|
||||
{
|
||||
$thingy->editThingData($otherThingId);
|
||||
my %miniVars;
|
||||
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
|
||||
cmp_deeply(
|
||||
\%miniVars,
|
||||
{
|
||||
form_start => ignore,
|
||||
form_end => ignore,
|
||||
form_submit => ignore,
|
||||
field_loop => ignore,
|
||||
},
|
||||
'thing edit form variables exist, because max entries not reached yet'
|
||||
);
|
||||
}
|
||||
|
||||
$thingy->editThingDataSave($otherThingId, 'new', {"field_".$otherFieldId => 'other test value'} );
|
||||
ok( $thingy->hasEnteredMaxEntries($otherThingId), 'hasEnteredMaxEntries returns true with one row entered, and maxEntriesTotal=1');
|
||||
|
||||
{
|
||||
$thingy->editThingData($otherThingId);
|
||||
my %miniVars;
|
||||
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
|
||||
my $existance = 0;
|
||||
foreach my $tmplVar (@edit_thing_form_fields) {
|
||||
$existance ||= exists $templateVars->{$tmplVar}
|
||||
}
|
||||
ok(
|
||||
! $existance,
|
||||
'thing edit form variables do not exist, because max entries was reached'
|
||||
);
|
||||
}
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# deleteThing
|
||||
|
|
@ -525,4 +577,27 @@ cmp_deeply(
|
|||
) or diag( explain \@thingData );
|
||||
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# Unique fields
|
||||
#
|
||||
#################################################################
|
||||
|
||||
{
|
||||
my %newThingProperties = %thingProperties;
|
||||
$newThingProperties{'groupIdView'} = 3;
|
||||
my $newThingId = $thingy->addThing(\%newThingProperties, 0);
|
||||
my %newFieldProperties = %fieldProperties;
|
||||
$newFieldProperties{thingId} = $newThingId;
|
||||
$newFieldProperties{isUnique} = 1;
|
||||
my $newFieldId = $thingy->addField(\%newFieldProperties, 0);
|
||||
my $fieldValue = 'value 1';
|
||||
my ($dataId,undef) = $thingy->editThingDataSave($newThingId, 'new', {"field_".$newFieldId => $fieldValue} );
|
||||
ok( $thingy->isUniqueEntry($newThingId,"field_${newFieldId}",$fieldValue,$dataId), "unique if the same entry" );
|
||||
ok( !$thingy->isUniqueEntry($newThingId,"field_${newFieldId}",$fieldValue,"new"), "new data is not unique" );
|
||||
my ( undef, $errors ) = $thingy->editThingDataSave($newThingId, 'new', {"field_".$newFieldId => $fieldValue} );
|
||||
ok( @$errors >= 1, "an error was returned" );
|
||||
my $errorMessage = $i18n->get('needs to be unique error');
|
||||
ok( grep( { $_->{error_message} =~ m/$errorMessage/ } @$errors), "error about uniqueness in right field" );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue