aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/photo.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/photo.t')
-rw-r--r--t/app/controller/photo.t39
1 files changed, 23 insertions, 16 deletions
diff --git a/t/app/controller/photo.t b/t/app/controller/photo.t
index e9183836b..842daa0dc 100644
--- a/t/app/controller/photo.t
+++ b/t/app/controller/photo.t
@@ -24,7 +24,10 @@ subtest "Check multiple upload worked" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
MAPIT_URL => 'http://mapit.uk/',
- UPLOAD_DIR => $UPLOAD_DIR,
+ PHOTO_STORAGE_BACKEND => 'FileSystem',
+ PHOTO_STORAGE_OPTIONS => {
+ UPLOAD_DIR => $UPLOAD_DIR,
+ },
}, sub {
$mech->log_in_ok('test@example.com');
@@ -72,12 +75,15 @@ subtest "Check multiple upload worked" => sub {
};
};
-subtest "Check photo uploading URL works" => sub {
+subtest "Check photo uploading URL and endpoints work" => sub {
my $UPLOAD_DIR = tempdir( CLEANUP => 1 );
# submit initial pc form
FixMyStreet::override_config {
- UPLOAD_DIR => $UPLOAD_DIR,
+ PHOTO_STORAGE_BACKEND => 'FileSystem',
+ PHOTO_STORAGE_OPTIONS => {
+ UPLOAD_DIR => $UPLOAD_DIR,
+ },
}, sub {
$mech->post( '/photo/upload',
Content_Type => 'form-data',
@@ -89,20 +95,21 @@ subtest "Check photo uploading URL works" => sub {
is $mech->content, '{"id":"74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg"}';
my $image_file = path($UPLOAD_DIR, '74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg');
ok $image_file->exists, 'File uploaded to temp';
- };
-};
-subtest "Check photo URL endpoints work" => sub {
- my $p = FixMyStreet::DB->resultset("Problem")->first;
-
- $mech->get_ok('/photo/temp.74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg');
- my $image_file = FixMyStreet->path_to('web/photo/temp.74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg');
- ok -e $image_file, 'File uploaded to temp';
- $mech->get_ok('/photo/' . $p->id . '.jpeg');
- $image_file = FixMyStreet->path_to('web/photo/' . $p->id . '.jpeg');
- ok -e $image_file, 'File uploaded to temp';
- my $res = $mech->get('/photo/0.jpeg');
- is $res->code, 404, "got 404";
+ my $p = FixMyStreet::DB->resultset("Problem")->first;
+
+ foreach my $i (
+ '/photo/temp.74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg',
+ '/photo/fulltemp.74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg',
+ '/photo/' . $p->id . '.jpeg',
+ '/photo/' . $p->id . '.full.jpeg') {
+ $mech->get_ok($i);
+ $image_file = FixMyStreet->path_to("web$i");
+ ok -e $image_file, 'File uploaded to temp';
+ }
+ my $res = $mech->get('/photo/0.jpeg');
+ is $res->code, 404, "got 404";
+ };
};
done_testing();