aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/moderate.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-11-18 14:05:56 +0000
committerMatthew Somerville <matthew@mysociety.org>2019-11-18 14:35:21 +0000
commit5b3731b263864722f26c4ab9ce28209b089a6942 (patch)
treea3c8066d786f19b684677af5685fd587bf193ab7 /t/app/controller/moderate.t
parent7b3c6513022a76409ae175187ecfb8064cff6e0d (diff)
Remove cached photos before updating db field.
If the photo field is updated first, then the cache removal doesn't think there are any photos to remove.
Diffstat (limited to 't/app/controller/moderate.t')
-rw-r--r--t/app/controller/moderate.t47
1 files changed, 34 insertions, 13 deletions
diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t
index fdbd0abb6..8e84bd392 100644
--- a/t/app/controller/moderate.t
+++ b/t/app/controller/moderate.t
@@ -12,6 +12,8 @@ sub moderate_permission_title { 0 }
package main;
+use Path::Tiny;
+use File::Temp 'tempdir';
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -172,23 +174,42 @@ subtest 'Problem moderation' => sub {
};
subtest 'Hide photo' => sub {
- $mech->content_contains('Photo of this report');
+ my $UPLOAD_DIR = tempdir( CLEANUP => 1 );
- $mech->submit_form_ok({ with_fields => {
- %problem_prepopulated,
- problem_photo => 0,
- }});
- $mech->base_like( qr{\Q$REPORT_URL\E} );
+ FixMyStreet::override_config {
+ PHOTO_STORAGE_BACKEND => 'FileSystem',
+ PHOTO_STORAGE_OPTIONS => {
+ UPLOAD_DIR => $UPLOAD_DIR,
+ },
+ }, sub {
+ my $image_path = path('t/app/controller/sample.jpg');
+ $image_path->copy( path($UPLOAD_DIR, '74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg') );
- $mech->content_lacks('Photo of this report');
+ $mech->get_ok('/photo/' . $report->id . '.0.jpeg');
- $mech->submit_form_ok({ with_fields => {
- %problem_prepopulated,
- problem_photo => 1,
- }});
- $mech->base_like( qr{\Q$REPORT_URL\E} );
+ $mech->get_ok($REPORT_URL);
+ $mech->content_contains('Photo of this report');
- $mech->content_contains('Photo of this report');
+ $mech->submit_form_ok({ with_fields => {
+ %problem_prepopulated,
+ problem_photo => 0,
+ }});
+ $mech->base_like( qr{\Q$REPORT_URL\E} );
+
+ my $res = $mech->get('/photo/' . $report->id . '.0.jpeg');
+ is $res->code, 404, 'got 404';
+
+ $mech->get_ok($REPORT_URL);
+ $mech->content_lacks('Photo of this report');
+
+ $mech->submit_form_ok({ with_fields => {
+ %problem_prepopulated,
+ problem_photo => 1,
+ }});
+ $mech->base_like( qr{\Q$REPORT_URL\E} );
+
+ $mech->content_contains('Photo of this report');
+ };
};
subtest 'Hide report' => sub {