diff --git a/lib/WebGUI/Asset/MatrixListing.pm b/lib/WebGUI/Asset/MatrixListing.pm
index f55ed6224..18f09ef73 100644
--- a/lib/WebGUI/Asset/MatrixListing.pm
+++ b/lib/WebGUI/Asset/MatrixListing.pm
@@ -432,7 +432,7 @@ sub incrementCounter {
my $currentIp = $self->session->env->get("HTTP_X_FORWARDED_FOR");
- unless ($self->get($counter."LastIp") eq $currentIp) {
+ unless ($self->get($counter."LastIp") && ($self->get($counter."LastIp") eq $currentIp)) {
$self->update({
$counter."LastIp" => $currentIp,
$counter => $self->get($counter)+1
diff --git a/t/Asset/Wobject/Matrix.t b/t/Asset/Wobject/Matrix.t
index 82285726c..94e9581f4 100644
--- a/t/Asset/Wobject/Matrix.t
+++ b/t/Asset/Wobject/Matrix.t
@@ -17,7 +17,7 @@ use lib "$FindBin::Bin/../../lib";
use WebGUI::Test;
use WebGUI::Session;
-use Test::More tests => 18; # increment this value for each test you create
+use Test::More tests => 21; # increment this value for each test you create
use Test::Deep;
use JSON;
use WebGUI::Asset::Wobject::Matrix;
@@ -51,6 +51,8 @@ foreach my $newSetting (keys %{$newMatrixSettings}) {
}
}
+is ($matrix->getCompareColor('4'),'#aaffaa',"Getting compareColorYes");
+
cmp_deeply (
$matrix->getCategories,
{
@@ -106,6 +108,14 @@ is($matrixListing->getAutoCommitWorkflowId,undef,"The matrix listings getAutoCom
is($matrixListing->hasRated,'0',"The matrix listings hasRated method returns correct value.");
+$matrixListing->www_click;
+
+is($matrixListing->get('clicks'),'1','Clicks were incremented');
+
+$matrixListing->www_view;
+
+is($matrixListing->get('views'),'1','Views were incremented');
+
# Test getListings
my $expectedAssetId = $matrixListing->getId;
@@ -115,9 +125,9 @@ my $listings = $matrix->getListings;
cmp_deeply(
$listings,
[{
- views=>"0",
+ views=>"1",
lastUpdated=>$matrixListing->get('lastUpdated'),
- clicks=>"0",
+ clicks=>"1",
compares=>"0",
assetId=>$expectedAssetId,
url=>$session->url->gateway($matrixListing->get('url')),
@@ -136,9 +146,9 @@ $listings = JSON->new->decode($listingsEncoded);
cmp_deeply(
$listings,
[{
- views=>"0",
+ views=>"1",
lastUpdated=>$matrixListing->get('lastUpdated'),
- clicks=>"0",
+ clicks=>"1",
compares=>"0",
assetId=>$expectedAssetId,
url=>$session->url->gateway($matrixListing->get('url')),
@@ -161,9 +171,9 @@ cmp_deeply(
$compareFormData,
{ResultSet=>{
Result=>[{
- views=>"0",
+ views=>"1",
lastUpdated=>$matrixListing->get('lastUpdated'),
- clicks=>"0",
+ clicks=>"1",
compares=>"0",
assetId=>$expectedAssetId,
url=>'/'.$matrixListing->get('url'),
@@ -186,7 +196,7 @@ cmp_deeply(
{
alphanumeric_sortButton=>"
",
bestViews_url=>'/'.$matrixListing->get('url'),
- bestViews_count=>0,
+ bestViews_count=>1,
bestViews_name=>$matrixListing->get('title'),
bestViews_sortButton=>"
",
bestCompares_url=>'/'.$matrixListing->get('url'),
@@ -194,7 +204,7 @@ cmp_deeply(
bestCompares_name=>$matrixListing->get('title'),
bestCompares_sortButton=>"
",
bestClicks_url=>'/'.$matrixListing->get('url'),
- bestClicks_count=>0,
+ bestClicks_count=>1,
bestClicks_name=>$matrixListing->get('title'),
bestClicks_sortButton=>"
",
last_updated_loop=>[{