diff options
author | Dave Arter <davea@mysociety.org> | 2015-10-06 11:50:48 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2015-10-06 11:50:48 +0100 |
commit | 2ed2c57659c0d288cd1cec391baef9faf002030d (patch) | |
tree | 742c5ad6e4671050805292061f85e9ff6ec308a0 /perllib/FixMyStreet/TestMech.pm | |
parent | de8ba7899dd4692cdf062f4b2735157f7fd14cb7 (diff) | |
parent | ffc03ca3330a43a98a3728df6f3d56c7fc1837d1 (diff) |
Merge branch 'zurich-2015-dev-candidate'
This is the work done in early 2015 to improve the Zürich admin interface, primarily.
Diffstat (limited to 'perllib/FixMyStreet/TestMech.pm')
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index bd2ca4096..1035a47ba 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -165,6 +165,7 @@ sub delete_user { $a->delete; } $_->delete for $user->comments; + $_->delete for $user->admin_logs; $user->delete; return 1; @@ -221,6 +222,24 @@ sub get_email { return $emails[0]; } +=head2 get_first_email + + $email = $mech->get_first_email(@emails); + +Returns first email in queue as a string and fails a test if the mail doesn't have a date and epoch-containing Message-ID header. + +=cut + +sub get_first_email { + my $mech = shift; + my $email = shift or do { fail 'No email retrieved'; return }; + my $email_as_string = $email->as_string; + ok $email_as_string =~ s{\s+Date:\s+\S.*?$}{}xmsg, "Found and stripped out date"; + ok $email_as_string =~ s{\s+Message-ID:\s+\S.*?$}{}xmsg, "Found and stripped out message ID (contains epoch)"; + return $email_as_string; +} + + =head2 page_errors my $arrayref = $mech->page_errors; @@ -631,7 +650,7 @@ sub create_problems_for_body { latitude => '51.5016605453401', longitude => '-0.142497580865087', user_id => $user->id, - photo => 1, + photo => $mech->get_photo_data, }; my %report_params = ( %$default_params, %$params ); @@ -646,4 +665,13 @@ sub create_problems_for_body { return @problems; } +sub get_photo_data { + my $mech = shift; + return $mech->{sample_photo} ||= do { + my $sample_file = FixMyStreet->path_to( 't/app/controller/sample.jpg' ); + $mech->builder->ok( -f "$sample_file", "sample file $sample_file exists" ); + $sample_file->slurp(iomode => '<:raw'); + }; +} + 1; |