diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 1 | ||||
-rw-r--r-- | t/app/model/problem.t | 13 | ||||
-rw-r--r-- | t/app/sendreport/inspection_required.t | 15 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 3 | ||||
-rw-r--r-- | t/cobrand/fixamingata.t | 3 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 3 | ||||
-rw-r--r-- | t/sendreport/open311.t | 3 | ||||
-rw-r--r-- | templates/web/oxfordshire/header.html | 6 | ||||
-rw-r--r-- | templates/web/oxfordshire/tracking_code.html | 17 |
11 files changed, 36 insertions, 35 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f908665e..1b9283bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Fix JavaScript error on /my calculating bounds #1954 - Change text on /reports to match lower down (fix translation). - Ensure all reports graph can't dip downward. #1956 + - Fix error sending `requires_inspection` reports. #1961 - UK: - Lazy load images in the footer. diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index ae45351c4..3f083c073 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -232,12 +232,6 @@ sub categories_summary { return \%categories; } -sub send_reports { - my ( $rs, $site_override ) = @_; - require FixMyStreet::Script::Reports; - return FixMyStreet::Script::Reports::send($site_override); -} - sub include_comment_counts { my $rs = shift; my $order_by = $rs->{attrs}{order_by}; diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index 04ad1c893..aca894d03 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -45,6 +45,7 @@ sub send(;$) { while (my $row = $unsent->next) { my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($row->cobrand)->new(); + FixMyStreet::DB->schema->cobrand($cobrand); if ($debug_mode) { $debug_unsent_count++; diff --git a/t/app/model/problem.t b/t/app/model/problem.t index efc9057da..27f6aed66 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -2,6 +2,7 @@ use FixMyStreet::TestMech; use FixMyStreet; use FixMyStreet::App; use FixMyStreet::DB; +use FixMyStreet::Script::Reports; use Sub::Override; my $problem_rs = FixMyStreet::DB->resultset('Problem'); @@ -541,7 +542,7 @@ foreach my $test ( { } ); FixMyStreet::override_config $override, sub { - $problem_rs->send_reports(); + FixMyStreet::Script::Reports::send(); }; $mech->email_count_is( $test->{ email_count } ); @@ -619,7 +620,7 @@ subtest 'check can set mutiple emails as a single contact' => sub { } ); FixMyStreet::override_config $override, sub { - $problem_rs->send_reports(); + FixMyStreet::Script::Reports::send(); }; $mech->email_count_is(1); @@ -652,7 +653,7 @@ subtest 'check can turn on report sent email alerts' => sub { send_fail_count => 0, } ); - $problem_rs->send_reports(); + FixMyStreet::Script::Reports::send(); $mech->email_count_is( 2 ); my @emails = $mech->get_email; @@ -698,7 +699,7 @@ subtest 'check iOS app store test reports not sent' => sub { send_fail_count => 0, } ); - $problem_rs->send_reports(); + FixMyStreet::Script::Reports::send(); $mech->email_count_is( 0 ); @@ -727,7 +728,7 @@ subtest 'check reports from abuser not sent' => sub { send_fail_count => 0, } ); - $problem_rs->send_reports(); + FixMyStreet::Script::Reports::send(); $mech->email_count_is( 1 ); @@ -743,7 +744,7 @@ subtest 'check reports from abuser not sent' => sub { my $abuse = FixMyStreet::DB->resultset('Abuse')->create( { email => $problem->user->email } ); $mech->clear_emails_ok; - $problem_rs->send_reports(); + FixMyStreet::Script::Reports::send(); $mech->email_count_is( 0 ); diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t index c8cb30592..64d6f70ee 100644 --- a/t/app/sendreport/inspection_required.t +++ b/t/app/sendreport/inspection_required.t @@ -1,13 +1,10 @@ use FixMyStreet; use FixMyStreet::DB; use FixMyStreet::TestMech; -use FixMyStreet::SendReport::Email; +use FixMyStreet::Script::Reports; ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); -use_ok 'FixMyStreet::Cobrand'; -FixMyStreet::DB->schema->cobrand(FixMyStreet::Cobrand::FixMyStreet->new()); - my $user = $mech->create_user_ok( 'user@example.com' ); my $body = $mech->create_body_ok( 2237, 'Oxfordshire County Council'); @@ -31,7 +28,7 @@ my $report = $reports[0]; subtest "Report isn't sent if uninspected" => sub { $mech->clear_emails_ok; - FixMyStreet::DB->resultset('Problem')->send_reports(); + FixMyStreet::Script::Reports::send(); $mech->email_count_is( 0 ); is $report->whensent, undef, "Report hasn't been sent"; @@ -42,7 +39,7 @@ subtest 'Report is sent when inspected' => sub { $report->set_extra_metadata(inspected => 1); $report->update; - FixMyStreet::DB->resultset('Problem')->send_reports(); + FixMyStreet::Script::Reports::send(); $report->discard_changes; $mech->email_count_is( 1 ); @@ -61,7 +58,7 @@ subtest 'Uninspected report is sent when made by trusted user' => sub { }); ok $user->has_permission_to('trusted', $report->bodies_str_ids), 'User can make trusted reports'; - FixMyStreet::DB->resultset('Problem')->send_reports(); + FixMyStreet::Script::Reports::send(); $report->discard_changes; $mech->email_count_is( 1 ); @@ -81,7 +78,7 @@ subtest "Uninspected report isn't sent when user rep is too low" => sub { $contact->set_extra_metadata(reputation_threshold => 20); $contact->update; - FixMyStreet::DB->resultset('Problem')->send_reports(); + FixMyStreet::Script::Reports::send(); $report->discard_changes; $mech->email_count_is( 0 ); @@ -92,7 +89,7 @@ subtest 'Uninspected report is sent when user rep is high enough' => sub { $user->set_extra_metadata(reputation => 21); $user->update; - FixMyStreet::DB->resultset('Problem')->send_reports(); + FixMyStreet::Script::Reports::send(); $report->discard_changes; $mech->email_count_is( 1 ); diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index a64337085..a3a807bb1 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -1,5 +1,6 @@ use CGI::Simple; use FixMyStreet::TestMech; +use FixMyStreet::Script::Reports; my $mech = FixMyStreet::TestMech->new; # Create test data @@ -54,7 +55,7 @@ subtest 'testing special Open311 behaviour', sub { STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'fixmystreet', 'bromley' ], }, sub { - $test_data = FixMyStreet::DB->resultset('Problem')->send_reports(); + $test_data = FixMyStreet::Script::Reports::send(); }; $report->discard_changes; ok $report->whensent, 'Report marked as sent'; diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 133a8c950..0aa264660 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -1,5 +1,6 @@ use mySociety::Locale; +use FixMyStreet::Script::Reports; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -35,7 +36,7 @@ $mech->email_count_is(0); FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'fixamingata' ], }, sub { - FixMyStreet::DB->resultset('Problem')->send_reports(); + FixMyStreet::Script::Reports::send(); }; my $email = $mech->get_email; my $plain = $mech->get_text_body_from_email($email, 1); diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index e0671db2a..8c2c70c2f 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -7,6 +7,7 @@ use LWP::Protocol::PSGI; use Test::LongString; use Path::Tiny; use t::Mock::MapItZurich; +use FixMyStreet::Script::Reports; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -36,7 +37,7 @@ sub send_reports_for_zurich { ALLOWED_COBRANDS => ['zurich'] }, sub { # Actually send the report - FixMyStreet::DB->resultset('Problem')->send_reports('zurich'); + FixMyStreet::Script::Reports::send('zurich'); }; } sub reset_report_state { diff --git a/t/sendreport/open311.t b/t/sendreport/open311.t index 52b1952f4..1eb5535aa 100644 --- a/t/sendreport/open311.t +++ b/t/sendreport/open311.t @@ -1,4 +1,5 @@ use CGI::Simple; +use FixMyStreet::Script::Reports; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -25,7 +26,7 @@ subtest 'testing Open311 behaviour', sub { STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'fixmystreet' ], }, sub { - $test_data = FixMyStreet::DB->resultset('Problem')->send_reports(); + $test_data = FixMyStreet::Script::Reports::send(); }; $report->discard_changes; ok $report->whensent, 'Report marked as sent'; diff --git a/templates/web/oxfordshire/header.html b/templates/web/oxfordshire/header.html index fce316bf9..a1d42a777 100644 --- a/templates/web/oxfordshire/header.html +++ b/templates/web/oxfordshire/header.html @@ -19,6 +19,12 @@ [% INCLUDE 'tracking_code.html' %] </head> <body class="[% bodyclass | html IF bodyclass %]"> + +<!-- Google Tag Manager (noscript) --> +<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NT76GJ5" +height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> +<!-- End Google Tag Manager (noscript) --> + <div id="oxford-wrapper"> <div id="oxford-header" class="desk-only"> <a href="https://www.oxfordshire.gov.uk/" title="Home" class="logo">Oxfordshire County Council</a> diff --git a/templates/web/oxfordshire/tracking_code.html b/templates/web/oxfordshire/tracking_code.html index 7a100f8ad..14afb5de0 100644 --- a/templates/web/oxfordshire/tracking_code.html +++ b/templates/web/oxfordshire/tracking_code.html @@ -1,15 +1,12 @@ [% IF c.config.BASE_URL == "https://www.fixmystreet.com" %] -<script type="text/javascript"> - - var _gaq = _gaq || []; - _gaq.push(['_setAccount', 'UA-22094787-2']); - _gaq.push(['_setDomainName', '.oxfordshire.gov.uk']); - _gaq.push(['_setCustomVar',1,'level1','Roads and transport',3]); - _gaq.push(['_setCustomVar',2,'level2','FixMyStreet',3]); - _gaq.push(['_trackPageview']); - -</script> +<!-- Google Tag Manager --> +<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': +new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], +j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= +'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); +})(window,document,'script','dataLayer','GTM-NT76GJ5');</script> +<!-- End Google Tag Manager --> [% ELSE %] <!-- Tracking code not inserted as "[% c.config.BASE_URL %]" not "https://www.fixmystreet.com" --> |