Add i18n for Tax, for the UI.

Begin to flesh out the DataTable JS for www_view.  Add a method to slurp all the
tax data out of the db at once.
Add a test for the slurp method, and stop using the private sub that used to
do it in the tests.
This commit is contained in:
Colin Kuskie 2008-03-10 04:25:36 +00:00
parent 1bbf5a3c7c
commit f40bed7ef3
3 changed files with 112 additions and 20 deletions

View file

@ -36,7 +36,7 @@ my $session = WebGUI::Test->session;
my $addExceptions = getAddExceptions($session);
my $tests = 72 + 2*scalar(@{$addExceptions});
my $tests = 73 + 2*scalar(@{$addExceptions});
plan tests => 1 + $tests;
#----------------------------------------------------------------------------
@ -138,7 +138,7 @@ $taxIterator = $taxer->getItems;
is($taxIterator->rows, 2, 'add added another row to the tax table');
$taxData = {
country => 'state',
country => 'USA',
state => 'Oregon',
taxRate => '0.1',
};
@ -153,6 +153,42 @@ is($taxIterator->rows, 3, 'add permits adding duplicate information.');
##city rate: 0.5%
##Wisconsin rate 5.0%
#######################################################################
#
# getAllItems
#
#######################################################################
my $expectedTaxData = [
{
country => 'USA',
state => 'OR',
city => undef,
code => undef,
taxRate => 0,
},
{
country => 'USA',
state => 'Wisconsin',
city => 'Madcity',
code => '53702',
taxRate => 5,
},
{
country => 'USA',
state => 'Oregon',
city => undef,
code => undef,
taxRate => 0.1,
},
];
cmp_bag(
$taxer->getAllItems,
$expectedTaxData,
'getAllItems returns the whole set of tax data',
);
#######################################################################
#
# delete
@ -307,9 +343,8 @@ ok(
$taxIterator = $taxer->getItems;
is($taxIterator->rows, 3, 'import: Old data deleted, new data imported');
my @goodTaxData = _grabTaxData($taxIterator);
cmp_bag(
\@goodTaxData,
$taxer->getAllItems,
$expectedTaxData,
'Correct data inserted.',
);
@ -323,9 +358,8 @@ ok(
$taxIterator = $taxer->getItems;
is($taxIterator->rows, 3, 'import: Old data deleted, new data imported again');
my @orderedTaxData = _grabTaxData($taxIterator);
cmp_bag(
\@orderedTaxData,
$taxer->getAllItems,
$expectedTaxData,
'Correct data inserted, with CSV in different columnar order.',
);
@ -339,9 +373,8 @@ ok(
$taxIterator = $taxer->getItems;
is($taxIterator->rows, 3, 'import: Old data deleted, new data imported the third time');
my @orderedTaxData = _grabTaxData($taxIterator);
cmp_bag(
\@orderedTaxData,
$taxer->getAllItems,
$expectedTaxData,
'Correct data inserted, with comments in the CSV file',
);
@ -572,16 +605,6 @@ $cart->delete;
$book->delete;
}
sub _grabTaxData {
my $tax = shift;
my @taxData = ();
while (my $taxRow = $tax->hashRef) {
delete $taxRow->{'taxId'};
push @taxData, $taxRow;
}
return @taxData;
}
sub getAddExceptions {
my $session = shift;
my $inputValidion = [