aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2014-01-01 00:12:28 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2014-04-07 17:50:04 +0100
commit397252f4463fb787753d99ea57e8a1385fa31a1e (patch)
treefcea734c86fad4ed0523fc85a11d7d2d1c23cb68
parentb0170c4be0c2c3befcbe0159d4e218db5e0e37a8 (diff)
Mock a date for dashboard tests
Fixes #365 (how appropriate) by mocking datetime to allow the dashboard test's assumptions (that we're not so near beginning of year that a report from X days ago isn't still in same year) to hold.
-rw-r--r--cpanfile1
-rw-r--r--cpanfile.snapshot9
-rw-r--r--t/app/controller/dashboard.t6
3 files changed, 15 insertions, 1 deletions
diff --git a/cpanfile b/cpanfile
index 995c7ccf2..ca82f9ae2 100644
--- a/cpanfile
+++ b/cpanfile
@@ -106,6 +106,7 @@ requires 'Sort::Key';
requires 'Sub::Override';
requires 'Test::Exception';
requires 'Test::LongString';
+requires 'Test::MockTime';
requires 'Test::More', '0.88';
requires 'Test::Warn';
requires 'Test::WWW::Mechanize::Catalyst';
diff --git a/cpanfile.snapshot b/cpanfile.snapshot
index 16f4f3b95..d64ba4c63 100644
--- a/cpanfile.snapshot
+++ b/cpanfile.snapshot
@@ -5404,6 +5404,15 @@ DISTRIBUTIONS
requirements:
ExtUtils::MakeMaker 6.03
Test::More 0
+ Test-MockTime-0.12
+ pathname: D/DD/DDICK/Test-MockTime-0.12.tar.gz
+ provides:
+ Test::MockTime 0.12
+ requirements:
+ ExtUtils::MakeMaker 0
+ Test::More 0
+ Time::Local 0
+ Time::Piece 1.08
Test-NoWarnings-1.04
pathname: A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz
provides:
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index 9a6d3e0f9..a87232e9b 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -1,6 +1,7 @@
use strict;
use warnings;
use Test::More;
+use Test::MockTime ':all';
use FixMyStreet::TestMech;
use Web::Scraper;
@@ -24,6 +25,9 @@ my $p_user = FixMyStreet::App->model('DB::User')->find_or_create( {
email => 'p_user@example.com'
} );
+# Dashboard tests assume we are not too early in year, to allow reporting
+# within same year, as a convenience.
+set_absolute_time('2014-03-01T12:00:00');
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
MAPIT_URL => 'http://mapit.mysociety.org/',
@@ -610,7 +614,7 @@ FixMyStreet::override_config {
is scalar @lines, 6, '1 (header) + 5 (reports) = 6 lines';
};
};
-
+restore_time;
sub make_problem {
my $args = shift;