diff --git a/lib/WebGUI/Asset/Sku/Subscription.pm b/lib/WebGUI/Asset/Sku/Subscription.pm
index 53a05c1ec..9b4b94c88 100644
--- a/lib/WebGUI/Asset/Sku/Subscription.pm
+++ b/lib/WebGUI/Asset/Sku/Subscription.pm
@@ -764,13 +764,13 @@ sub www_listSubscriptionCodeBatches {
my $dcStop = $session->datetime->addToTime($session->form->date('dcStop'), 23, 59);
my $selection = $session->form->process('selection');
- my $f = WebGUI::HTMLForm->new( $session );
- $f->hidden(
+ my $f = WebGUI::FormBuilder->new( $session, action => $self->getUrl );
+ $f->addField( "hidden",
name => 'func',
value => 'listSubscriptionCodeBatches',
);
- $f->readOnly(
+ $f->addField( "readOnly",
label =>
WebGUI::Form::radio( $session, { name => 'selection', value => 'dc', checked => ($selection eq 'dc') } )
. $i18n->get('selection created'),
@@ -779,13 +779,13 @@ sub www_listSubscriptionCodeBatches {
. ' ' . $i18n->get( 'and' ) . ' '
. WebGUI::Form::date( $session, { name => 'dcStop', value=> $dcStop } ),
);
- $f->readOnly(
+ $f->addField( "readOnly",
label =>
WebGUI::Form::radio( $session, { name => 'selection', value => 'all', checked => ($selection ne 'dc') } )
. $i18n->get('display all'),
value => '',
);
- $f->submit(
+ $f->addField( "submit",
value => $i18n->get('select'),
);
@@ -804,7 +804,7 @@ sub www_listSubscriptionCodeBatches {
# Fetch the list of batches at the current paginition index
my $batches = $p->getPageData;
- my $output = $f->print;
+ my $output = $f->toHtml;
$output .= $p->getBarTraditional($session->form->process("pn"));
$output .= '
';
foreach my $batch ( @{$batches} ) {
@@ -826,7 +826,7 @@ sub www_listSubscriptionCodeBatches {
$output = $i18n->get('no subscription code batches') unless $session->db->quickScalar('select count(*) from Subscription_codeBatch');
- return $self->getAdminConsoleWithSubmenu->render( $output, $i18n->get('manage batches') );
+ return $output;
}
#-------------------------------------------------------------------
diff --git a/t/Asset/Sku/Subscription.t b/t/Asset/Sku/Subscription.t
index 474fdbae9..a19420f24 100644
--- a/t/Asset/Sku/Subscription.t
+++ b/t/Asset/Sku/Subscription.t
@@ -35,7 +35,7 @@ WebGUI::Test->addToCleanup($user);
#----------------------------------------------------------------------------
# Tests
-plan tests => 9; # Increment this number for each test you create
+plan tests => 16; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@@ -126,7 +126,34 @@ cmp_deeply( $codes,
);
-
+#----------------------------------------------------------------------------
+# www_listSubscriptionCodeBatches
+my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
+$mech->get_ok( '/' );
+$mech->session->user({ userId => 3 });
+
+# Add another code for the selection
+$session->db->setRow( 'Subscription_codeBatch', 'batchId', {
+ batchId => 'new',
+ name => "Fired!",
+ description => "Sign up to get fired!",
+ subscriptionId => $sku->getId,
+ expirationDate => 3600 * 24 * 7,
+ dateCreated => time+1500,
+});
+
+$mech->get_ok( $sku->getUrl( 'func=listSubscriptionCodeBatches' ) );
+$mech->text_contains( "Sign up to get your paycheck!" );
+$mech->text_contains( "Sign up to get fired!" );
+$mech->submit_form_ok( {
+ fields => {
+ selection => "dc",
+ dcStart => time+1000,
+ dcStop => time+2000,
+ },
+}, 'limit subscription code batches' );
+$mech->content_lacks( "Sign up to get your paycheck!" );
+$mech->text_contains( "Sign up to get fired!" );