diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2015-01-27 18:32:02 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2015-10-06 09:09:22 +0100 |
commit | a78bb3fc98dd1851e371c78d9743125d02baf04e (patch) | |
tree | be8bb660db9c982ac6b0b2add70a82acc01f30b9 /t/cobrand/zurich.t | |
parent | ccc71f8f2d4a514f6ffaab2f3bbc76ea423f212b (diff) |
Add support for multiple photos per report.
For Zurich, see mysociety/FixMyStreet-Commercial#664.
This commit includes a new PhotoSet class (NB: called Model:: though not
really a model), should handle binary data (e.g. old style photos in
database), fileids (40-char hash), and Catalyst::Upload objects.
Diffstat (limited to 't/cobrand/zurich.t')
-rw-r--r-- | t/cobrand/zurich.t | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index 6394c8942..e1cb55b16 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -6,6 +6,7 @@ use warnings; use DateTime; use Test::More; use JSON; +use Path::Tiny; # Check that you have the required locale installed - the following # should return a line with de_CH.utf8 in. If not install that locale. @@ -21,6 +22,10 @@ my $c = FixMyStreet::App->new(); my $cobrand = FixMyStreet::Cobrand::Zurich->new({ c => $c }); $c->stash->{cobrand} = $cobrand; +my $sample_file = path(__FILE__)->parent->parent->child("app/controller/sample.jpg"); +ok $sample_file->exists, "sample file $sample_file exists"; +my $sample_photo = $sample_file->slurp_raw; + # This is a helper method that will send the reports but with the config # correctly set - notably SEND_REPORTS_ON_STAGING needs to be true. sub send_reports_for_zurich { @@ -103,6 +108,7 @@ my @reports = $mech->create_problems_for_body( 1, $division->id, 'Test', { state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', + photo => $sample_photo, }); my $report = $reports[0]; @@ -136,7 +142,6 @@ $mech->content_contains( 'report_edit/' . $report->id ); $mech->content_contains( DateTime->now->strftime("%d.%m.%Y") ); $mech->content_contains( 'Erfasst' ); - subtest "changing of categories" => sub { # create a few categories (which are actually contacts) foreach my $name ( qw/Cat1 Cat2/ ) { @@ -213,11 +218,14 @@ subtest "report_edit" => sub { $mech->content_contains( 'Unbestätigt' ); # Unconfirmed email $mech->submit_form_ok( { with_fields => { state => 'confirmed' } } ); $mech->get_ok( '/report/' . $report->id ); + + $report->discard_changes(); + is $report->state, 'confirmed', 'state has been updated to confirmed'; }; $mech->content_contains('Aufgenommen'); $mech->content_contains('Test Test'); - $mech->content_lacks('photo/' . $report->id . '.jpeg'); + $mech->content_lacks('photo/' . $report->id . '.0.jpeg'); $mech->email_count_is(0); $report->discard_changes; @@ -302,7 +310,7 @@ FixMyStreet::override_config { $mech->get_ok( '/admin/report_edit/' . $report->id ); $mech->submit_form_ok( { with_fields => { state => 'confirmed', publish_photo => 1 } } ); $mech->get_ok( '/report/' . $report->id ); - $mech->content_contains('photo/' . $report->id . '.jpeg'); + $mech->content_contains('photo/' . $report->id . '.0.jpeg'); # Internal notes $mech->get_ok( '/admin/report_edit/' . $report->id ); @@ -424,6 +432,7 @@ $mech->clear_emails_ok; state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', + photo => $sample_photo, }); $report = $reports[0]; @@ -458,6 +467,7 @@ $mech->email_count_is(0); state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', + photo => $sample_photo, }); $report = $reports[0]; @@ -679,3 +689,5 @@ END { ok $mech->host("www.fixmystreet.com"), "change host back"; done_testing(); } + +1; |