diff options
Diffstat (limited to 't/app/sendreport/email.t')
-rw-r--r-- | t/app/sendreport/email.t | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t index 04b3854cc..471145dcb 100644 --- a/t/app/sendreport/email.t +++ b/t/app/sendreport/email.t @@ -1,33 +1,34 @@ -#!/usr/bin/perl - use strict; use warnings; use Test::More; use FixMyStreet; -use FixMyStreet::App; -use FixMyStreet::DB::Result::Contact; +use FixMyStreet::DB; use FixMyStreet::SendReport::Email; use FixMyStreet::TestMech; use mySociety::Locale; +ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); + my $e = FixMyStreet::SendReport::Email->new(); -my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( +# area id 1000 +my $params = { id => 1000, name => 'Council of the Thousand' }; +my $body = FixMyStreet::DB->resultset('Body')->find_or_create($params); +ok $body, "found/created body"; + +my $contact = $mech->create_contact_ok( email => 'council@example.com', body_id => 1000, category => 'category', - confirmed => 1, - deleted => 0, - editor => 'test suite', - whenedited => DateTime->now, note => '', ); -my $row = FixMyStreet::App->model('DB::Problem')->new( { - council => '1000', +my $row = FixMyStreet::DB->resultset('Problem')->new( { + bodies_str => '1000', category => 'category', + cobrand => '', } ); ok $e; @@ -44,14 +45,14 @@ foreach my $test ( { }, { desc => 'unconfirmed contact results in no receipients', - count => undef, + count => 0, add_council => 1, unconfirmed => 1, - expected_note => 'Council 1000 deleted', + expected_note => 'Body 1000 deleted', }, { desc => 'unconfirmed contact note uses note from contact table', - count => undef, + count => 0, add_council => 1, unconfirmed => 1, note => 'received bounced so unconfirmed', @@ -62,7 +63,7 @@ foreach my $test ( { my $e = FixMyStreet::SendReport::Email->new; $contact->update( { confirmed => 0 } ) if $test->{unconfirmed}; $contact->update( { note => $test->{note} } ) if $test->{note}; - $e->add_council( 1000, { name => 'test council' } ) if $test->{add_council}; + $e->add_body( $body ) if $test->{add_council}; is $e->build_recipient_list( $row, {} ), $test->{count}, 'correct recipient list count'; if ( $test->{unconfirmed} ) { @@ -72,6 +73,8 @@ foreach my $test ( { }; } -$contact->delete; - done_testing(); + +END { + $mech->delete_body($body); +} |