aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-02-23 16:43:51 +0000
committerStruan Donald <struan@exo.org.uk>2012-02-23 16:43:51 +0000
commit73b9d630c713ca37f86cdff6fa95b64c36f29a31 (patch)
tree775289a40dc21d5643101d44f4caa39d764809fb /t
parent37655d9b76cbd6b4fe8e8948226e2537b543e198 (diff)
move send-report into problem resultset plus basic test
Diffstat (limited to 't')
-rw-r--r--t/app/model/problem.t35
1 files changed, 33 insertions, 2 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index ad42c5fdf..58c66ac74 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -7,6 +7,7 @@ use Test::More;
use FixMyStreet;
use FixMyStreet::App;
+use FixMyStreet::TestMech;
use mySociety::Locale;
mySociety::Locale::gettext_domain('FixMyStreet');
@@ -16,8 +17,8 @@ my $problem_rs = FixMyStreet::App->model('DB::Problem');
my $problem = $problem_rs->new(
{
postcode => 'EH99 1SP',
- latitude => 1,
- longitude => 1,
+ latitude => '51.5016605453401',
+ longitude => '-0.142497580865087',
areas => 1,
title => '',
detail => '',
@@ -345,6 +346,36 @@ for my $test (
};
}
+my $mech = FixMyStreet::TestMech->new();
+
+foreach my $test ( {
+ }
+) {
+ subtest "sending report" => sub {
+ $mech->clear_emails_ok;
+
+ FixMyStreet::App->model('DB::Problem')->search(
+ {
+ whensent => undef
+ }
+ )->update( { whensent => \'ms_current_timestamp()' } );
+
+ $problem->discard_changes;
+ $problem->update( {
+ council => 2651,
+ state => 'confirmed',
+ confirmed => \'ms_current_timestamp()',
+ whensent => undef,
+ } );
+
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+
+ $mech->email_count_is( 1 );
+ my $email = $mech->get_email;
+ like $email->body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
+ };
+}
+
$problem->comments->delete;
$problem->delete;
$user->delete;