[Rt-commit] rt branch, 4.0/helpers-http-cache-headers, updated. rt-4.0.8-307-g9aa9b13
? sunnavy
sunnavy at bestpractical.com
Thu Mar 14 11:59:30 EDT 2013
The branch, 4.0/helpers-http-cache-headers has been updated
via 9aa9b13390eacfc8f58544797217bcda92b8b405 (commit)
from 376192f06d58578d6d3b8ae7a007257720bd4502 (commit)
Summary of changes:
t/web/helpers-http-cache-headers.t | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
- Log -----------------------------------------------------------------
commit 9aa9b13390eacfc8f58544797217bcda92b8b405
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Mar 14 23:46:16 2013 +0800
use Test::MockTime to get fixed time
so no need to worry about time elapsing any more
diff --git a/t/web/helpers-http-cache-headers.t b/t/web/helpers-http-cache-headers.t
index 7988a77..67ccde0 100644
--- a/t/web/helpers-http-cache-headers.t
+++ b/t/web/helpers-http-cache-headers.t
@@ -6,6 +6,8 @@ use utf8;
# endpoints checking for the right headers.
use File::Find;
+use Test::MockTime 'set_fixed_time';
+set_fixed_time(time());
use RT::Test tests => undef;
@@ -54,11 +56,11 @@ diag "set up expected date headers";
$expected = {
Autocomplete => {
'Cache-Control' => 'max-age=120, private',
- 'Expires' => $autocomplete,
+ 'Expires' => $autocomplete->RFC2616,
},
default => {
'Cache-Control' => 'no-cache',
- 'Expires' => $default,
+ 'Expires' => $default->RFC2616,
},
};
}
@@ -74,23 +76,10 @@ foreach my $endpoint ( @endpoints ) {
'got expected Cache-Control header'
);
-# tests only pass for this if test script runs in the same second
-# is( $m->res->header('Expires') => $headers->{'Expires'} );
-
- # parse header in to RT::Date object
- my $date = RT::Date->new(RT->SystemUser);
- $date->Set(
- Format => 'unknown',
- Timezone => 'GMT',
- Value => $m->res->header('Expires'),
+ is(
+ $m->res->header('Expires') => $headers->{'Expires'},
+ 'got expected Expires header'
);
-
- # date/time in header cannot be less than expected date
- cmp_ok( $date->Unix, '>=', $headers->{'Expires'}->Unix, '>= expected time' );
-
- # date/time in header cannot be more than 5 seconds past expected date
- cmp_ok( $date->Unix, '<', $headers->{'Expires'}->Unix + 5, '< expected time+5' );
-
}
undef $m;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list