diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 97e207f65..abf90f3b0 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -1076,8 +1076,8 @@ sub www_preview { my $session = $self->session; return $session->privilege->insufficient unless $self->canEdit; - my $form = $session->form; - my $http = $session->http; + my $form = $session->form; + my $response = $session->response; try { my $output = $self->processRaw( @@ -1087,14 +1087,14 @@ sub www_preview { $form->get('parser'), ); if ($form->get('plainText')) { - $http->setMimeType('text/plain'); + $response->content_type('text/plain'); } elsif ($output !~ //) { $output = $session->style->userStyle($output); } return $output; } catch { - $http->setMimeType('text/plain'); + $response->content_type('text/plain'); $_[0]; } } diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 4eebd5cf6..04fa1561c 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -916,7 +916,7 @@ sub www_createAccountSave { $profile->{'language'} = $self->session->scratch->getLanguageOverride; } $u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma")); - $u->updateProfileFields($profile) if ($profile); + $u->update($profile); $self->update($properties); my $address = {}; @@ -927,6 +927,8 @@ sub www_createAccountSave { $address->{$address_key} = $profile->{$fieldId} if ($address_key); } + $self->session->user({user=>$u}); + #Update or create and update the shop address if ( keys %$address ) { $address->{'isProfile' } = 1; @@ -962,7 +964,6 @@ sub www_createAccountSave { }); } - $self->session->user({user=>$u}); $self->_logLogin($userId,"success"); if ($self->session->setting->get("runOnRegistration")) { diff --git a/lib/WebGUI/Content/PDFGenerator.pm b/lib/WebGUI/Content/PDFGenerator.pm index eba836e35..649abec9f 100644 --- a/lib/WebGUI/Content/PDFGenerator.pm +++ b/lib/WebGUI/Content/PDFGenerator.pm @@ -138,7 +138,7 @@ sub handler { return undef unless $op && $op eq 'generatePdf'; my $asset = getRequestedAsset($session); return $session->privilege->noAccess unless $asset->canView; - $session->http->setMimeType('application/pdf'); + $session->response->content_type('application/pdf'); return cache($asset); } diff --git a/lib/WebGUI/Shop/Address.pm b/lib/WebGUI/Shop/Address.pm index a6dff5236..aaead6464 100644 --- a/lib/WebGUI/Shop/Address.pm +++ b/lib/WebGUI/Shop/Address.pm @@ -91,6 +91,7 @@ property "addressBookId" => ( property "isProfile" => ( noFormPost => 1, required => 0, + default => 0, ); has [ qw/addressId addressBook/] => ( diff --git a/lib/WebGUI/Shop/AddressBook.pm b/lib/WebGUI/Shop/AddressBook.pm index 1315068ae..0eddd777c 100644 --- a/lib/WebGUI/Shop/AddressBook.pm +++ b/lib/WebGUI/Shop/AddressBook.pm @@ -625,18 +625,18 @@ sub www_ajaxSearch { my $name = $form->get('name'); my $fields = { - firstName => (split(" ",$name))[0] || "", - lastName => (split(" ",$name))[1] || "", - organization => $form->get('organization') || "", - address1 => $form->get('address1') || "", - address2 => $form->get('address2') || "", - address3 => $form->get('address3') || "", - city => $form->get('city') || "", - state => $form->get('state') || "", - code => $form->get('zipcode') || "", - country => $form->get('country') || "", - email => $form->get('email') || "", - phoneNumber => $form->get('phone') || "", + 'address.firstName' => (split(" ",$name))[0] || "", + 'address.lastName' => (split(" ",$name))[1] || "", + 'address.organization' => $form->get('organization') || "", + 'address.address1' => $form->get('address1') || "", + 'address.address2' => $form->get('address2') || "", + 'address.address3' => $form->get('address3') || "", + 'address.city' => $form->get('city') || "", + 'address.state' => $form->get('state') || "", + 'address.code' => $form->get('zipcode') || "", + 'address.country' => $form->get('country') || "", + 'address.email' => $form->get('email') || "", + 'address.phoneNumber' => $form->get('phone') || "", }; my $clause = []; @@ -645,7 +645,7 @@ sub www_ajaxSearch { foreach my $field (keys %$fields) { my $field_value = $fields->{$field}; if($field_value) { - $field = $session->db->dbh->quote_identifier($field); + $field = join('.', map { $session->db->quote_identifier($_) } split(/\./, $field)); $field_value = $field_value."%"; push(@$clause,qq{$field like ?}); push(@$params,$field_value); @@ -663,8 +663,8 @@ sub www_ajaxSearch { my $query = qq{ select - address.*, - users.username + users.username, + address.* from address join addressBook on address.addressBookId = addressBook.addressBookId @@ -679,7 +679,7 @@ sub www_ajaxSearch { push(@$var,$hash); } - $session->http->setMimeType('text/plain'); + $session->response->content_type('text/plain'); return JSON->new->encode($var); } diff --git a/lib/WebGUI/Shop/Pay.pm b/lib/WebGUI/Shop/Pay.pm index d1f6ec4fa..9a3b2ba3f 100644 --- a/lib/WebGUI/Shop/Pay.pm +++ b/lib/WebGUI/Shop/Pay.pm @@ -114,6 +114,7 @@ sub getDrivers { my $self = shift; my %drivers = (); CLASS: foreach my $class (@{$self->session->config->get('paymentDrivers')}) { + $self->session->log->warn($class); my $driverName = eval { WebGUI::Pluggable::instanciate($class, 'getName', [ $self->session ])}; if ($@) { $self->session->log->warn("Error loading $class: $@"); diff --git a/lib/WebGUI/Shop/PayDriver/CreditCard.pm b/lib/WebGUI/Shop/PayDriver/CreditCard.pm index fe41ac590..ab9446330 100644 --- a/lib/WebGUI/Shop/PayDriver/CreditCard.pm +++ b/lib/WebGUI/Shop/PayDriver/CreditCard.pm @@ -20,10 +20,26 @@ The following methods are available from this class. =cut -use base qw/WebGUI::Shop::PayDriver/; +use Moose; +use WebGUI::Definition::Shop; +extends 'WebGUI::Shop::PayDriver'; Readonly my $I18N => 'PayDriver_CreditCard'; +define pluginName => 'Credit Card Base Class'; +property useCVV2 => ( + fieldType => 'yesNo', + label => ['use cvv2', $I18N], + hoverHelp => ['use cvv2 help', $I18N], + ); +property credentialsTemplateId => ( + fieldType => 'template', + label => ['credentials template', $I18N], + hoverHelp => ['credentials template help', $I18N], + namespace => 'Shop/Credentials', + default => 'itransact_credentials1', + ); + #------------------------------------------------------------------- sub _monthYear { my $session = shift; @@ -92,35 +108,6 @@ sub appendCredentialVars { return; } -#------------------------------------------------------------------- -sub definition { - my ($class, $session, $definition) = @_; - - my $i18n = WebGUI::International->new($session, $I18N); - - tie my %fields, 'Tie::IxHash', ( - useCVV2 => { - fieldType => 'yesNo', - label => $i18n->get('use cvv2'), - hoverHelp => $i18n->get('use cvv2 help'), - }, - credentialsTemplateId => { - fieldType => 'template', - label => $i18n->get('credentials template'), - hoverHelp => $i18n->get('credentials template help'), - namespace => 'Shop/Credentials', - defaultValue => 'itransact_credentials1', - }, - ); - - push @{ $definition }, { - name => 'Credit Card Base Class', - properties => \%fields, - }; - - return $class->SUPER::definition($session, $definition); -} - #------------------------------------------------------------------- =head2 processCredentials diff --git a/lib/WebGUI/Shop/PayDriver/CreditCard/AuthorizeNet.pm b/lib/WebGUI/Shop/PayDriver/CreditCard/AuthorizeNet.pm index dbeb31dee..05a0d0bef 100644 --- a/lib/WebGUI/Shop/PayDriver/CreditCard/AuthorizeNet.pm +++ b/lib/WebGUI/Shop/PayDriver/CreditCard/AuthorizeNet.pm @@ -8,8 +8,29 @@ use DateTime; use Readonly; use Business::OnlinePayment; +use Moose; +use WebGUI::Definition::Shop; +extends 'WebGUI::Shop::PayDriver::CreditCard'; + Readonly my $I18N => 'PayDriver_AuthorizeNet'; +define pluginName => ['name', $I18N]; +property login => ( + fieldType => 'text', + label => ['login', $I18N], + hoverHelp => ['login help', $I18N], + ); +property transaction_key => ( + fieldType => 'text', + label => ['transaction key', $I18N], + hoverHelp => ['transaction key help', $I18N], + ); +property testMode => ( + fieldType => 'YesNo', + label => ['test mode', $I18N], + hoverHelp => ['test mode help', $I18N], + ); + =head1 NAME WebGUI::Shop::PayDriver::CreditCard::AuthorizeNet @@ -87,38 +108,6 @@ sub cancelRecurringPayment { return $self->gatewayResponse($tx); } -#------------------------------------------------------------------- -sub definition { - my ( $class, $session, $definition ) = @_; - - my $i18n = WebGUI::International->new( $session, $I18N ); - - tie my %fields, 'Tie::IxHash', ( - login => { - fieldType => 'text', - label => $i18n->get('login'), - hoverHelp => $i18n->get('login help'), - }, - transaction_key => { - fieldType => 'text', - label => $i18n->get('transaction key'), - hoverHelp => $i18n->get('transaction key help'), - }, - testMode => { - fieldType => 'YesNo', - label => $i18n->get('test mode'), - hoverHelp => $i18n->get('test mode help'), - }, - ); - - push @{$definition}, { - name => $i18n->get('name'), - properties => \%fields, - }; - - return $class->SUPER::definition( $session, $definition ); -} ## end sub definition - #------------------------------------------------------------------- =head2 gatewayObject ( params ) diff --git a/t/Asset/Post/Thread/bug_12206_bad_subscription_groups_in_duplicate.t b/t/Asset/Post/Thread/bug_12206_bad_subscription_groups_in_duplicate.t index c2bd5390b..217f93e06 100644 --- a/t/Asset/Post/Thread/bug_12206_bad_subscription_groups_in_duplicate.t +++ b/t/Asset/Post/Thread/bug_12206_bad_subscription_groups_in_duplicate.t @@ -31,12 +31,17 @@ use WebGUI::Test; use WebGUI::Asset; my $session = WebGUI::Test->session; -my $thread = WebGUI::Asset->getImportNode($session)->addChild( +my $cs = WebGUI::Asset->getImportNode($session)->addChild( + { + className => 'WebGUI::Asset::Wobject::Collaboration', + } +); +my $thread = $cs->addChild( { className => 'WebGUI::Asset::Post::Thread', } ); -WebGUI::Test->addToCleanup($thread); +WebGUI::Test->addToCleanup($cs); $thread->createSubscriptionGroup(); my $admin = WebGUI::User->new($session, 3); ok !$admin->isInGroup($thread->get('subscriptionGroupId')); diff --git a/t/Asset/Wobject/Thingy/www_editThingDataSaveViaAjax.t b/t/Asset/Wobject/Thingy/www_editThingDataSaveViaAjax.t index 8130d90be..0740a51b3 100644 --- a/t/Asset/Wobject/Thingy/www_editThingDataSaveViaAjax.t +++ b/t/Asset/Wobject/Thingy/www_editThingDataSaveViaAjax.t @@ -92,10 +92,10 @@ $session->request->setup_body({ }); $session->user({userId => '3'}); -$session->http->setStatus(200); +$session->response->status(200); my $json = $thingy->www_editThingDataSaveViaAjax(); is $json, '{}', 'www_editThingDataSaveViaAjax: Empty JSON hash'; -is $session->http->getStatus, 200, '... http status=200'; +is $session->response->status, 200, '... http status=200'; $session->request->setup_body({ diff --git a/t/Auth.t b/t/Auth.t index 597951a29..e4c94a8a1 100644 --- a/t/Auth.t +++ b/t/Auth.t @@ -28,7 +28,6 @@ my $session = WebGUI::Test->session; my @cleanupUsernames = (); # Will be cleaned up when we're done my $auth; # will be used to create auth instances -my ($request, $oldRequest, $output); #---------------------------------------------------------------------------- # Tests @@ -54,7 +53,7 @@ WebGUI::Test->addToCleanup(sub { }); $createAccountSession->scratch->setLanguageOverride($language); -$output = $auth->www_createAccountSave( $username, { }, "PASSWORD" ); +my $output = $auth->www_createAccountSave( $username, { }, "PASSWORD" ); WebGUI::Test->addToCleanup(sub { for my $username ( @cleanupUsernames ) { # We don't create actual, real users, so we have to cleanup by hand @@ -92,7 +91,7 @@ is( "returnUrl field is used to set redirect after createAccountSave", ); -is $createAccountSession->user->profileField('language'), $language, 'languageOverride is taken in to account in createAccountSave'; +is $createAccountSession->user->get('language'), $language, 'languageOverride is taken in to account in createAccountSave'; $createAccountSession->scratch->delete('language'); ##Remove language override @@ -109,7 +108,7 @@ $auth = WebGUI::Auth->new( $loginSession, 3 ); my $username = $loginSession->id->generate; push @cleanupUsernames, $username; $session->setting->set('showMessageOnLogin', 0); -$output = $auth->login; +$output = $auth->www_login; is( $loginSession->response->location, 'REDIRECT_LOGIN_URL', @@ -117,11 +116,9 @@ is( ); is $output, undef, 'login returns undef when showMessageOnLogin is false'; -# Session Cleanup -$session->{_request} = $oldRequest; - #---------------------------------------------------------------------------- # Test createAccountSave +$auth = WebGUI::Auth->new( $session ); $username = $session->id->generate; push @cleanupUsernames, $username; @@ -138,14 +135,14 @@ tie my %profile_info, "Tie::IxHash", ( email => 'andy@shawshank.com' ); -$auth->createAccountSave( $username, { }, "PASSWORD", \%profile_info ); +diag $auth->www_createAccountSave( $username, { }, "PASSWORD", \%profile_info ); #Reset andy to the session users since stuff has changed my $andy = $session->user; #Test that the address was saved to the profile cmp_bag( - [ map { $andy->profileField($_) } keys %profile_info ], + [ map { $andy->get($_) } keys %profile_info ], [ values %profile_info ], 'Profile fields were saved' ); diff --git a/t/Shop/Address.t b/t/Shop/Address.t index c3b5d01f5..e7f493740 100644 --- a/t/Shop/Address.t +++ b/t/Shop/Address.t @@ -123,7 +123,7 @@ cmp_deeply( addressId => ignore(), #checked elsewhere addressBookId => $book->getId, addressBook => $book, - isProfile => 0, + isProfile => bool(0), }, 'get the whole thing and check a new, blank object' ); diff --git a/t/Shop/AddressBook.t b/t/Shop/AddressBook.t index 1fc0ef476..0b02117f0 100644 --- a/t/Shop/AddressBook.t +++ b/t/Shop/AddressBook.t @@ -16,6 +16,7 @@ use strict; use Test::More; use Test::Deep; +use Data::Dumper; use Exception::Class; use WebGUI::Test; # Must use this before any other WebGUI modules @@ -194,9 +195,6 @@ is($profile_address->getId,$address1->getId,"getProfileAddress returns addresses # ####################################################################### -#Clear the book address cache -$book->uncache; - my $address_info = { label => 'Profile Label', addressId => $address1->getId, @@ -232,14 +230,11 @@ cmp_bag( my $u = WebGUI::User->new($session,$book->get("userId")); cmp_bag( - [ map { $u->profileField($_) } keys %{ $book->getProfileAddressMappings } ], + [ map { $u->get($_) } keys %{ $book->getProfileAddressMappings } ], [ map { $address1->get($_) } values %{ $book->getProfileAddressMappings } ], 'Profile address was updated and matches address fields' ); -#Test that updates to non profile address does not update the profile -$book->uncache; - $address_info = { label => 'Non Profile Label', addressId => $address2->getId, @@ -275,7 +270,7 @@ cmp_bag( ); cmp_bag( - [ map { $u->profileField($_) } keys %{ $book->getProfileAddressMappings } ], + [ map { $u->get($_) } keys %{ $book->getProfileAddressMappings } ], [ map { $address1->get($_) } values %{ $book->getProfileAddressMappings } ], 'Profile address was not updated when non profile fields were saved' ); @@ -286,9 +281,6 @@ cmp_bag( # ####################################################################### -#clear the cache -$book->uncache; - $session->request->setup_body({ 'addressId' => $address2->getId, 'callback' => q|{'url':''}| @@ -304,9 +296,6 @@ cmp_bag( ); -#clear the cache -$book->uncache; - $session->request->setup_body({ 'addressId' => $address1->getId, 'callback' => q|{'url':''}| @@ -328,9 +317,6 @@ cmp_bag( # ####################################################################### -#clear the cache -$book->uncache; - my $addressBookId = $alreadyHaveBook->getId; my $firstCount = $session->db->quickScalar('select count(*) from addressBook where addressBookId=?',[$addressBookId]); $alreadyHaveBook->delete(); @@ -381,6 +367,7 @@ cmp_bag( #Create some data to search for my $andySession = WebGUI::Test->newSession; my $andy = WebGUI::User->create($andySession); +$andy->username('andy'); WebGUI::Test->addToCleanup($andy); $andySession->user({ userId => $andy->getId }); my $andyBook = WebGUI::Shop::AddressBook->create($andySession); @@ -421,6 +408,7 @@ my $andyAddr2 = $andyBook->addAddress({ my $redSession = WebGUI::Test->newSession; my $red = WebGUI::User->create($redSession); +$red->username('red'); WebGUI::Test->addToCleanup($red); $redSession->user({userId => $red->getId}); my $redBook = WebGUI::Shop::AddressBook->create($redSession); @@ -439,12 +427,14 @@ my $redAddr = $redBook->addAddress({ country => 'US', phoneNumber => '111-111-1111', email => 'red@shawshank.com', - organization => 'Shawshank' + organization => 'Shawshank', + isProfile => 0, }); my $brooksSession = WebGUI::Test->newSession; my $brooks = WebGUI::User->create($brooksSession); +$brooks->username('brooks'); WebGUI::Test->addToCleanup($brooks); $brooksSession->user({userId => $brooks->getId}); my $brooksBook = WebGUI::Shop::AddressBook->create($brooksSession); @@ -463,7 +453,8 @@ my $brooksAddr = $brooksBook->addAddress({ country => 'US', phoneNumber => '111-111-1111', email => 'brooks@shawshank.com', - organization => 'Shawshank' + organization => 'Shawshank', + isProfile => 0, }); #Test search as admin @@ -473,11 +464,20 @@ $session->request->setup_body({ my $results = JSON->new->decode($book->www_ajaxSearch); +my $andyAddr1_get = $andyAddr1->get; +my $andyAddr2_get = $andyAddr2->get; +my $redAddr_get = $redAddr->get; +my $brooksAddr_get = $brooksAddr->get; + +foreach my $addr ($andyAddr1_get, $andyAddr2_get, $redAddr_get, $brooksAddr_get) { + delete $addr->{addressBook}; +} + cmp_bag( $results, [ - { %{$andyAddr1->get}, username => $andy->username }, - { %{$andyAddr2->get}, username => $andy->username }, + { %{$andyAddr1_get}, username => $andy->username, }, + { %{$andyAddr2_get}, username => $andy->username, }, ], 'Ajax Address Search matches name correctly for admins' ); @@ -501,7 +501,7 @@ $results = JSON->new->decode($book->www_ajaxSearch); cmp_bag( $results, - [{ %{$andyAddr1->get}, username => $andy->username }], + [{ %{$andyAddr1_get}, username => $andy->username }], 'Ajax Address Search matches multiple fields correctly' ); @@ -539,9 +539,9 @@ $results = JSON->new->decode($book->www_ajaxSearch); cmp_bag( $results, [ - { %{$andyAddr1->get}, username => $andy->username }, - { %{$redAddr->get}, username => $red->username }, - { %{$brooksAddr->get}, username => $brooks->username }, + { %{$andyAddr1_get}, username => $andy->username }, + { %{$redAddr_get}, username => $red->username }, + { %{$brooksAddr_get}, username => $brooks->username }, ], 'Ajax Address Search returns cross user results for admins' ); @@ -556,9 +556,9 @@ $results = JSON->new->decode($andyBook->www_ajaxSearch); cmp_bag( $results, [ - { %{$andyAddr1->get}, username => $andy->username }, - { %{$redAddr->get}, username => $red->username }, - { %{$brooksAddr->get}, username => $brooks->username }, + { %{$andyAddr1_get}, username => $andy->username }, + { %{$redAddr_get}, username => $red->username }, + { %{$brooksAddr_get}, username => $brooks->username }, ], 'Ajax Address Search returns cross user results for shop admins' ); @@ -573,9 +573,9 @@ $results = JSON->new->decode($redBook->www_ajaxSearch); cmp_bag( $results, [ - { %{$andyAddr1->get}, username => $andy->username }, - { %{$redAddr->get}, username => $red->username }, - { %{$brooksAddr->get}, username => $brooks->username }, + { %{$andyAddr1_get}, username => $andy->username }, + { %{$redAddr_get}, username => $red->username }, + { %{$brooksAddr_get}, username => $brooks->username }, ], 'Ajax Address Search returns cross user results for shop cashiers' ); @@ -588,7 +588,7 @@ $results = JSON->new->decode($brooksBook->www_ajaxSearch); cmp_bag( $results, - [{ %{$brooksAddr->get}, username => $brooks->username }], + [{ %{$brooksAddr_get}, username => $brooks->username }], 'Ajax Address Search returns only current user results for non privileged users' ); diff --git a/t/Shop/Pay.t b/t/Shop/Pay.t index 28fb0bc59..297d11fd7 100644 --- a/t/Shop/Pay.t +++ b/t/Shop/Pay.t @@ -17,6 +17,7 @@ use strict; use Test::More; use Test::Deep; use Test::Exception; +use Data::Dumper; use JSON; use HTML::Form; @@ -132,7 +133,8 @@ my $defaultPayDrivers = { 'WebGUI::Shop::PayDriver::CreditCard::AuthorizeNet' => 'Credit Card (Authorize.net)', }; -cmp_deeply( $drivers, $defaultPayDrivers, 'getDrivers returns the default PayDrivers'); +cmp_deeply( $drivers, $defaultPayDrivers, 'getDrivers returns the default PayDrivers') + or diag Dumper $drivers; ####################################################################### #