diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-01-18 14:06:24 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-01-18 14:06:24 +0000 |
commit | f9b2ff83e731364f9780d42bf59bb1e4c71018f0 (patch) | |
tree | 31509711f28b74945435e6d0a57a1b8c44ddb7b8 /t | |
parent | aa1ada8de28f8af2c4ef1ea5a8f4e633d3995741 (diff) | |
parent | 4394236a96f797d31033f6760607548266b0d354 (diff) |
Merge branch 'issues/commercial/988-c6-email-address-link'
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/rss.t | 60 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 34 |
2 files changed, 33 insertions, 61 deletions
diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t index 171121eaa..a8101b593 100644 --- a/t/app/controller/rss.t +++ b/t/app/controller/rss.t @@ -14,28 +14,19 @@ my $user1 = $mech->create_user_ok('reporter-rss@example.com', name => 'Reporter my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser; -my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { +my ($report) = $mech->create_problems_for_body(1, 2651, '', { postcode => 'eh1 1BB', - bodies_str => '2651', areas => ',11808,135007,14419,134935,2651,20728,', category => 'Street lighting', title => '&Test’i<n>g \'☃"', detail => 'Testing Detail', - used_map => 1, name => $user1->name, - anonymous => 0, - state => 'confirmed', confirmed => $dt_parser->format_datetime($dt), lastupdate => $dt_parser->format_datetime($dt), whensent => $dt_parser->format_datetime($dt->clone->add( minutes => 5 )), - lang => 'en-gb', - service => '', - cobrand => 'default', - cobrand_data => '', - send_questionnaire => 1, latitude => '55.951963', longitude => '-3.189944', - user_id => $user1->id, + user => $user1, } ); $mech->host('www.fixmystreet.com'); @@ -127,54 +118,19 @@ $report->delete(); my $council = $mech->create_body_ok(2333, 'Hart Council'); my $county = $mech->create_body_ok(2227, 'Hampshire Council'); -my $now = DateTime->now(); -my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create( - { - postcode => 'GU51 4AE', - bodies_str => $council->id, +my ($report_to_council) = $mech->create_problems_for_body(1, $council->id, '', { + user => $user1, areas => ',2333,2227,', - category => 'Other', - title => 'council report', - detail => 'Test 2 Detail', - used_map => 't', - name => 'Test User', - anonymous => 'f', - state => 'closed', - confirmed => $now->ymd . ' ' . $now->hms, - lang => 'en-gb', - service => '', - cobrand => 'default', - cobrand_data => '', - send_questionnaire => 't', latitude => '51.279616', longitude => '-0.846040', - user_id => $user1->id, - } -); +}); -my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_create( - { - postcode => 'GU51 4AE', - bodies_str => $county->id, +my ($report_to_county_council) = $mech->create_problems_for_body(1, $county->id, '', { + user => $user1, areas => ',2333,2227,', - category => 'Other', - title => 'county report', - detail => 'Test 2 Detail', - used_map => 't', - name => 'Test User', - anonymous => 'f', - state => 'closed', - confirmed => $now->ymd . ' ' . $now->hms, - lang => 'en-gb', - service => '', - cobrand => 'default', - cobrand_data => '', - send_questionnaire => 't', latitude => '51.279616', longitude => '-0.846040', - user_id => $user1->id, - } -); +}); subtest "check RSS feeds on cobrand have correct URLs for non-cobrand reports" => sub { $mech->host('hart.fixmystreet.com'); diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index 8c2c70c2f..385f7f077 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -3,6 +3,7 @@ use DateTime; use Email::MIME; +use File::Temp; use LWP::Protocol::PSGI; use Test::LongString; use Path::Tiny; @@ -25,7 +26,6 @@ my $cobrand = FixMyStreet::Cobrand::Zurich->new(); 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 STAGING_FLAGS send_reports needs to be true, and @@ -103,7 +103,7 @@ my $superuser; subtest "set up superuser" => sub { $superuser = $mech->log_in_ok( 'super@example.org' ); # a user from body $zurich is a superuser, as $zurich has no parent id! - $superuser->update({ from_body => $zurich->id }); + $superuser->update({ from_body => $zurich->id }); $EXISTING_REPORT_COUNT = get_export_rows_count($mech); $mech->log_out_ok; }; @@ -112,7 +112,6 @@ my @reports = $mech->create_problems_for_body( 1, $division->id, 'Test', { state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', - photo => $sample_photo, areas => ',423017,', }); my $report = $reports[0]; @@ -315,15 +314,30 @@ subtest "report_edit" => sub { } }; +# Give the report three photos +my $UPLOAD_DIR = File::Temp->newdir(); +my @files = map { $_ x 40 . ".jpeg" } (1..3); +$sample_file->copy(path($UPLOAD_DIR, $_)) for @files; +$report->photo(join(',', @files)); +$report->update; + FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'zurich' ], + MAPIT_URL => 'http://mapit.zurich/', MAP_TYPE => 'Zurich,OSM', + UPLOAD_DIR => $UPLOAD_DIR, }, sub { # Photo publishing $mech->get_ok( '/admin/report_edit/' . $report->id ); - $mech->submit_form_ok( { with_fields => { state => 'confirmed', publish_photo => 1 } } ); + $mech->submit_form_ok( { with_fields => { state => 'confirmed', publish_photo_1 => 1 } } ); + $mech->get_ok( '/around?lat=' . $report->latitude . ';lon=' . $report->longitude); + $mech->content_lacks('photo/' . $report->id . '.0.fp.jpeg'); + $mech->content_contains('photo/' . $report->id . '.1.fp.jpeg'); + $mech->content_lacks('photo/' . $report->id . '.2.fp.jpeg'); $mech->get_ok( '/report/' . $report->id ); - $mech->content_contains('photo/' . $report->id . '.0.jpeg'); + $mech->content_lacks('photo/' . $report->id . '.0.jpeg'); + $mech->content_contains('photo/' . $report->id . '.1.jpeg'); + $mech->content_lacks('photo/' . $report->id . '.2.jpeg'); # Internal notes $mech->get_ok( '/admin/report_edit/' . $report->id ); @@ -451,12 +465,16 @@ $mech->content_contains( DateTime->now->strftime("%d.%m.%Y") ); # User confirms their email address $report->set_extra_metadata(email_confirmed => 1); +$report->confirmed(DateTime->now); $report->update; FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'zurich' ], MAP_TYPE => 'Zurich,OSM', }, sub { + # Quick RSS check here, while we have a report + $mech->get_ok('/rss/problems'); + $mech->get_ok( '/admin/report_edit/' . $report->id ); $mech->content_lacks( 'Unbestätigt' ); # Confirmed email $mech->submit_form_ok( { with_fields => { status_update => 'FINAL UPDATE' } } ); @@ -480,7 +498,6 @@ $mech->clear_emails_ok; state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', - photo => $sample_photo, areas => ',423017,', }); $report = $reports[0]; @@ -522,7 +539,6 @@ $mech->email_count_is(0); state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', - photo => $sample_photo, areas => ',423017,', }); $report = $reports[0]; @@ -830,7 +846,7 @@ subtest "test stats" => sub { $mech->content_contains('Innerhalb von fünf Arbeitstagen abgeschlossen: 3'); # my @data = $mech->content =~ /(?:moderiert|abgeschlossen): \d+/g; # diag Dumper(\@data); use Data::Dumper; - + my $export_count = get_export_rows_count($mech); if (defined $export_count) { is $export_count - $EXISTING_REPORT_COUNT, 3, 'Correct number of reports'; @@ -865,7 +881,7 @@ subtest 'email images to external partners' => sub { }); my $fileid = $photoset->data; - $report->set_extra_metadata('publish_photo' => 1); + $report->set_extra_metadata('publish_photo' => { 0 => 1 }); # The below email comparison must not have an external message. $report->unset_extra_metadata('external_message'); $report->update({ |