diff --git a/lib/WebGUI/AdSpace/Ad.pm b/lib/WebGUI/AdSpace/Ad.pm
index dc0dc2fd6..9f97cf870 100644
--- a/lib/WebGUI/AdSpace/Ad.pm
+++ b/lib/WebGUI/AdSpace/Ad.pm
@@ -261,27 +261,32 @@ sub set {
$self->{_properties}{priority} = exists $properties->{priority} ? $properties->{priority} : $self->{_properties}{priority};
# prerender the ad for faster display
my $adSpace = WebGUI::AdSpace->new($self->session, $self->get("adSpaceId"));
- if ($self->get("type") eq "text") {
- $self->{_properties}{renderedAd} = '
';
- } elsif ($self->get("type") eq "image") {
- my $storage = WebGUI::Storage->get($self->session, $self->get("storageId"));
- $self->{_properties}{renderedAd} = '';
- } elsif ($self->get("type") eq "rich") {
+ if ($self->get("type") eq "text") {
+ $self->{_properties}{renderedAd} =
+ q{};
+ }
+ elsif ($self->get("type") eq "image") {
+ my $storage = WebGUI::Storage->get($self->session, $self->get("storageId"));
+ $self->{_properties}{renderedAd} =
+ q{};
+ }
+ elsif ($self->get("type") eq "rich") {
my $ad = $self->get("richMedia");
WebGUI::Macro::process($self->session, \$ad);
$self->{_properties}{renderedAd} = $ad;
diff --git a/t/AdSpace.t b/t/AdSpace.t
index 9932de530..135196fdf 100644
--- a/t/AdSpace.t
+++ b/t/AdSpace.t
@@ -47,6 +47,9 @@ SKIP: {
skip "Unable to load WebGUI::AdSpace", $numTests-1 unless $loaded;
+ local $ENV{REMOTE_ADDR} = '10.0.0.1';
+ local $ENV{HTTP_USER_AGENT} = 'Mozilla/5.0';
+
$adSpace = WebGUI::AdSpace->create($session, {name=>"Alfred"});
isa_ok($adSpace, 'WebGUI::AdSpace');
diff --git a/t/AdSpace/Ad.t b/t/AdSpace/Ad.t
index d0f725285..d81603190 100644
--- a/t/AdSpace/Ad.t
+++ b/t/AdSpace/Ad.t
@@ -54,6 +54,10 @@ $imageStorage->addFileFromScalar('foo.bmp', 'This is not really an image');
SKIP: {
skip "Unable to load WebGUI::AdSpace::Ad", $numTests-1 unless $loaded;
+
+ local $ENV{REMOTE_ADDR} = '10.0.0.1';
+ local $ENV{HTTP_USER_AGENT} = 'Mozilla/5.0';
+
$adSpace = WebGUI::AdSpace->create($session, {name=>"Alfred"});
$ad=WebGUI::AdSpace::Ad->create($session, $adSpace->getId, {"type" => "text"});
isa_ok($ad,"WebGUI::AdSpace::Ad");
@@ -115,11 +119,11 @@ SKIP: {
##Link checks
$token = $textP->get_tag("a");
- my $href = $token->[1]{href};
+ my $href = $token->[1]{onclick};
like($href, qr/op=clickAd/, 'ad link has correct operation');
my $adId = $textAd->getId;
- like($href, qr/id=$adId/, 'ad link has correct ad id');
+ like($href, qr/id=\Q$adId\E/, 'ad link has correct ad id');
$style = $token->[1]{style};
like($style, qr/background-color:white/, 'ad link background is white');
@@ -159,11 +163,11 @@ SKIP: {
##Link checks
$token = $textP->get_tag("a");
- my $href = $token->[1]{href};
+ my $href = $token->[1]{onclick};
like($href, qr/op=clickAd/, 'ad link has correct operation, image');
$adId = $imageAd->getId;
- like($href, qr/id=$adId/, 'ad link has correct ad id, image');
+ like($href, qr/id=\Q$adId\E/, 'ad link has correct ad id, image');
$token = $textP->get_tag("img");
$style = $token->[1]{src};