Return a list of shipper to choose from in stead of none if no shipper has be chosen yet.

This commit is contained in:
Martin Kamerbeek 2010-12-17 15:59:45 +00:00
parent e222cd97b6
commit f748aa1b83
3 changed files with 35 additions and 3 deletions

View file

@ -2,6 +2,8 @@
- added #11968: use the language override in the registration form (Jukka Raimovaara / Mentalhouse Oy)
- Changed Carousel to use TinyMCE with WebGUI plugins
- fixed #11984: No JS allows invalid dates in Event asset
- fixed bug in shopping cart where in some cases the shipper selectbox would
be empty ( Martin Kamerbeek / Oqapi )
7.10.6
- fixed #11974: Toolbar icons unclickable in Webkit using HTML5

View file

@ -875,8 +875,10 @@ sub www_ajaxPrices {
} || 0,
shipping => eval {
die unless $shipping;
$self->update({ shippingAddressId => $shipping });
#die unless $shipping;
if ( $shipping ) {
$self->update({ shippingAddressId => $shipping });
}
my $ship = WebGUI::Shop::Ship->new($self->session);
$ship->getOptions($self);
} || [],

View file

@ -17,12 +17,14 @@ use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use Test::Deep;
use Scalar::Util qw/refaddr/;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Asset;
use WebGUI::Shop::Cart;
use WebGUI::TestException;
use JSON 'from_json';
#----------------------------------------------------------------------------
@ -33,7 +35,7 @@ my $i18n = WebGUI::International->new($session, "Shop");
#----------------------------------------------------------------------------
# Tests
plan tests => 30; # Increment this number for each test you create
plan tests => 34; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -179,5 +181,31 @@ $cart->delete;
is($cart->delete, undef, "Can destroy cart.");
# Test (shipping part of) www_ajaxPrices
{
local *WebGUI::Shop::Ship::getOptions = sub { [ qw{ a b c } ] };
$cart->update( { shippingAddressId => $address->getId } );
my $response = from_json $cart->www_ajaxPrices;
cmp_deeply(
$response->{ shipping },
[ qw{ a b c } ],
'shipping contains available shipping option when no shipper is passed',
);
is( $cart->get('shippingAddressId'), $address->getId, 'calling www_ajaxPrices w/o shipperId doesn\'t change the cart shipperId' );
local *WebGUI::Session::Form::get = sub { return 'OtherShippert' };
$response = from_json $cart->www_ajaxPrices;
cmp_deeply(
$response->{ shipping },
[ qw{ a b c } ],
'shipping contains available shipping option when a shipper is passed',
);
is( $cart->get('shippingAddressId'), 'OtherShippert', 'calling www_ajaxPrices w/ shipperId updates the cart shipperId' );
$cart->update( { shippingAddressId => $shipper->getId } );
}
$product->purge;