aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-09-28 16:20:09 +0100
committerDave Arter <davea@mysociety.org>2018-09-28 16:20:09 +0100
commitaedfb6de6b4839396b8bcc885e075b28ea9b4885 (patch)
tree1ac3c9d0148b3f98ff29985e8c760740bb8d2548 /t/app
parentec55469dadd99dd0f20d3d0c3b4202b6b70bb6ab (diff)
parent07bc1188dc149e05b61e0d93ecf3ef1c26dc8690 (diff)
Merge branch 'pluggable-photo-storage'
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/photo.t10
-rw-r--r--t/app/model/photoset.t30
2 files changed, 37 insertions, 3 deletions
diff --git a/t/app/controller/photo.t b/t/app/controller/photo.t
index e9183836b..e28ee1946 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');
@@ -77,7 +80,10 @@ subtest "Check photo uploading URL works" => sub {
# 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',
diff --git a/t/app/model/photoset.t b/t/app/model/photoset.t
index d171ba88b..29a28d232 100644
--- a/t/app/model/photoset.t
+++ b/t/app/model/photoset.t
@@ -15,7 +15,10 @@ my $db = FixMyStreet::DB->schema;
my $user = $db->resultset('User')->find_or_create({ name => 'Bob', email => 'bob@example.com' });
FixMyStreet::override_config {
- UPLOAD_DIR => $UPLOAD_DIR,
+ PHOTO_STORAGE_BACKEND => 'FileSystem',
+ PHOTO_STORAGE_OPTIONS => {
+ UPLOAD_DIR => $UPLOAD_DIR,
+ },
}, sub {
my $image_path = path('t/app/controller/sample.jpg');
@@ -69,4 +72,29 @@ subtest 'Photoset with 3 referenced photo' => sub {
};
+subtest 'Correct storage backends are instantiated' => sub {
+ FixMyStreet::override_config {
+ PHOTO_STORAGE_BACKEND => 'FileSystem'
+ }, sub {
+ my $photoset = FixMyStreet::App::Model::PhotoSet->new;
+ isa_ok $photoset->storage, 'FixMyStreet::PhotoStorage::FileSystem';
+ };
+
+ FixMyStreet::override_config {
+ PHOTO_STORAGE_BACKEND => undef
+ }, sub {
+ my $photoset = FixMyStreet::App::Model::PhotoSet->new;
+ isa_ok $photoset->storage, 'FixMyStreet::PhotoStorage::FileSystem';
+ };
+
+ FixMyStreet::override_config {
+ PHOTO_STORAGE_BACKEND => 'S3'
+ }, sub {
+ my $photoset = FixMyStreet::App::Model::PhotoSet->new;
+ isa_ok $photoset->storage, 'FixMyStreet::PhotoStorage::S3';
+ };
+
+};
+
+
done_testing();