aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-15 10:56:30 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-15 10:56:30 +0100
commit8a6bcedac3697e2c1c07c27bc0b42224b8f5ba16 (patch)
tree11425a253717e8ced02aef0fbc14460ed247bbb9 /t/app/controller
parentc12c7836af432302fe3805e6081df3182f0bc2b6 (diff)
check one report included in figures
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/dashboard.t51
1 files changed, 47 insertions, 4 deletions
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index eccbc0cde..93aee9a72 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -10,6 +10,7 @@ my $mech = FixMyStreet::TestMech->new;
my $test_user = 'council_user@example.com';
my $test_pass = 'password';
my $test_council = 2651;
+my $test_ward = 20723;
$mech->delete_user( $test_user );
my $user = FixMyStreet::App->model('DB::User')->create( {
@@ -17,6 +18,10 @@ my $user = FixMyStreet::App->model('DB::User')->create( {
password => $test_pass,
} );
+my $p_user = FixMyStreet::App->model('DB::User')->find_or_create( {
+ email => 'p_user@example.com'
+} );
+
$mech->not_logged_in_ok;
$mech->get_ok('/dashboard');
@@ -42,10 +47,8 @@ $mech->content_contains( 'Summary Statistics for City of Edinburgh' );
FixMyStreet::App->model('DB::Contact')->search( { area_id => $test_council } )
->delete;
-my $eight_weeks_ago = DateTime->now->subtract( weeks => 8 );
-
FixMyStreet::App->model('DB::Problem')->search( { council => $test_council } )
- ->update( { confirmed => $eight_weeks_ago } );
+ ->delete();
my @cats = qw( Grafitti Litter Potholes );
for my $contact ( @cats ) {
@@ -70,7 +73,18 @@ my $categories = scraper {
process "select[name=ward] > option", 'wards[]' => 'TEXT',
process "table[id=overview] > tr", 'rows[]' => scraper {
process 'td', 'cols[]' => 'TEXT'
- }
+ },
+ process "tr[id=total] > td", 'totals[]' => 'TEXT',
+ process "tr[id=fixed_council] > td", 'council[]' => 'TEXT',
+ process "tr[id=fixed_user] > td", 'user[]' => 'TEXT',
+ process "tr[id=total_fixed] > td", 'total_fixed[]' => 'TEXT',
+ process "tr[id=in_progress] > td", 'in_progress[]' => 'TEXT',
+ process "tr[id=planned] > td", 'planned[]' => 'TEXT',
+ process "tr[id=investigating] > td", 'investigating[]' => 'TEXT',
+ process "tr[id=marked] > td", 'marked[]' => 'TEXT',
+ process "tr[id=avg_marked] > td", 'avg_marked[]' => 'TEXT',
+ process "tr[id=avg_fixed] > td", 'avg_fixed[]' => 'TEXT',
+ process "tr[id=not_marked] > td", 'not_marked[]' => 'TEXT',
};
my $expected_cats = [ 'All', '-- Pick a category --', @cats, 'Other' ];
@@ -83,4 +97,33 @@ foreach my $row ( @{ $res->{rows} }[1 .. 11] ) {
}
}
+make_problem( { state => 'confirmed', conf_dt => DateTime->now } );
+
+$mech->get_ok('/dashboard');
+$res = $categories->scrape( $mech->content );
+
+is $res->{ totals }->[1], 1, 'Report in total';
+is $res->{ not_marked }->[1], 1, 'Report in not marked';
+
+sub make_problem {
+ my $args = shift;
+
+ my $p = FixMyStreet::App->model('DB::Problem')->create( {
+ title => 'a problem',
+ name => 'a user',
+ anonymous => 1,
+ detail => 'some detail',
+ state => $args->{state},
+ confirmed => $args->{conf_dt},
+ whensent => $args->{conf_dt},
+ council => $test_council,
+ postcode => 'EH99 1SP',
+ latitude => '51',
+ longitude => '1',
+ areas => $test_ward,
+ used_map => 0,
+ user_id => $p_user->id,
+ } );
+}
+
done_testing;