aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-02-16 14:26:20 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-02-16 18:02:18 +0000
commit3a594ab90c739afbc94b5ae0558696abb878c34c (patch)
treebb7ae6d7fbe9a51e8d014f1bb8a4fc95834288fd /t/app
parent6e2da95bc6a758c0cf070b9ddd51acc769f7acf1 (diff)
Add some /photo and questionnaire update tests.
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/photo.t36
-rw-r--r--t/app/controller/report_updates.t28
2 files changed, 61 insertions, 3 deletions
diff --git a/t/app/controller/photo.t b/t/app/controller/photo.t
index dbbc697d7..e9183836b 100644
--- a/t/app/controller/photo.t
+++ b/t/app/controller/photo.t
@@ -66,7 +66,43 @@ subtest "Check multiple upload worked" => sub {
'Returned upload_fileid contains expected hash, 3 times');
my $image_file = path($UPLOAD_DIR, '74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg');
ok $image_file->exists, 'File uploaded to temp';
+
+ $mech->submit_form_ok({ with_fields => { name => 'Bob Jones' } });
+ ok $mech->success, 'Made request with multiple photo upload';
};
};
+subtest "Check photo uploading URL works" => sub {
+ my $UPLOAD_DIR = tempdir( CLEANUP => 1 );
+
+ # submit initial pc form
+ FixMyStreet::override_config {
+ UPLOAD_DIR => $UPLOAD_DIR,
+ }, sub {
+ $mech->post( '/photo/upload',
+ Content_Type => 'form-data',
+ Content => {
+ photo1 => [ $sample_file, undef, Content_Type => 'application/octet-stream' ],
+ },
+ );
+ ok $mech->success, 'Made request with multiple photo upload';
+ 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";
+};
+
done_testing();
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index aefe77e47..0b6d4ae3e 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -148,6 +148,26 @@ subtest "unconfirmed updates not displayed" => sub {
subtest "several updates shown in correct order" => sub {
for my $fields ( {
problem_id => $report_id,
+ whensent => '2011-03-10 12:23:16',
+ whenanswered => '2011-03-10 12:23:16',
+ old_state => 'confirmed',
+ new_state => 'confirmed',
+ },
+ {
+ problem_id => $report_id,
+ whensent => '2011-03-15 08:12:36',
+ whenanswered => '2011-03-15 08:12:36',
+ old_state => 'confirmed',
+ new_state => 'fixed - user',
+ },
+ ) {
+ my $q = FixMyStreet::App->model('DB::Questionnaire')->find_or_create(
+ $fields
+ );
+ }
+
+ for my $fields ( {
+ problem_id => $report_id,
user_id => $user2->id,
name => 'Other User',
mark_fixed => 'false',
@@ -185,11 +205,13 @@ subtest "several updates shown in correct order" => sub {
$mech->get_ok("/report/$report_id");
my $meta = $mech->extract_update_metas;
- is scalar @$meta, 4, 'number of updates';
+ is scalar @$meta, 5, 'number of updates';
is $meta->[0], 'Posted by Other User at 12:23, Thu 10 March 2011', 'first update';
is $meta->[1], 'Posted by Main User at 12:23, Thu 10 March 2011', 'second update';
- is $meta->[2], 'State changed to: Fixed', 'third update, part 1';
- is $meta->[3], 'Posted anonymously at 08:12, Tue 15 March 2011', 'third update, part 2';
+ is $meta->[2], 'Still open, via questionnaire, 12:23, Thu 10 March 2011', 'questionnaire';
+ is $meta->[3], 'State changed to: Fixed', 'third update, part 1';
+ is $meta->[4], 'Posted anonymously at 08:12, Tue 15 March 2011', 'third update, part 2';
+ $report->questionnaires->delete;
};
for my $test (