diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/Reporting.pm | 2 | ||||
-rw-r--r-- | t/cobrand/bucks.t | 22 |
3 files changed, 30 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index f39558f45..ca041bf70 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -347,4 +347,13 @@ sub manifest { }; } +sub report_new_munge_before_insert { + my ($self, $report) = @_; + + # Make sure TfL reports are marked safety critical + $self->SUPER::report_new_munge_before_insert($report); + + FixMyStreet::Cobrand::Buckinghamshire::report_new_munge_before_insert($self, $report); +} + 1; diff --git a/perllib/FixMyStreet/Reporting.pm b/perllib/FixMyStreet/Reporting.pm index b5b5876b9..4573d78fc 100644 --- a/perllib/FixMyStreet/Reporting.pm +++ b/perllib/FixMyStreet/Reporting.pm @@ -88,7 +88,7 @@ has filename => ( is => 'rw', isa => Str, lazy => 1, default => sub { $self->on_updates ? ('updates') : (), map { my $value = $where{$_}; - (my $nosp = $value) =~ s/ /-/g; + (my $nosp = $value || '') =~ s/ /-/g; (defined $value and length $value) ? ($_, $nosp) : () } sort keys %where }); diff --git a/t/cobrand/bucks.t b/t/cobrand/bucks.t index 36e149a13..8d99178f5 100644 --- a/t/cobrand/bucks.t +++ b/t/cobrand/bucks.t @@ -130,6 +130,24 @@ subtest 'Flytipping not on a road gets recategorised' => sub { is $report->category, "Flytipping (off-road)", 'Report was recategorised correctly'; }; +subtest 'Flytipping not on a road on .com gets recategorised' => sub { + ok $mech->host("www.fixmystreet.com"), "change host to www"; + $mech->get_ok('/report/new?latitude=51.615559&longitude=-0.556903&category=Flytipping'); + $mech->submit_form_ok({ + with_fields => { + title => "Test Report", + detail => 'Test report details.', + category => 'Flytipping', + 'road-placement' => 'off-road', + } + }, "submit details"); + $mech->content_contains('on its way to the council right now'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + ok $report, "Found the report"; + is $report->category, "Flytipping (off-road)", 'Report was recategorised correctly'; + ok $mech->host("buckinghamshire.fixmystreet.com"), "change host to bucks"; +}; + subtest 'Flytipping not on a road going to HE does not get recategorised' => sub { $mech->get_ok('/report/new?latitude=51.615559&longitude=-0.556903&category=Flytipping'); $mech->submit_form_ok({ @@ -151,7 +169,7 @@ subtest 'Flytipping not on a road going to HE does not get recategorised' => sub subtest 'Ex-district reports are sent to correct emails' => sub { FixMyStreet::Script::Reports::send(); - $mech->email_count_is(2); # one for council, one confirmation for user + $mech->email_count_is(4); # (one for council, one confirmation for user) x 2 my @email = $mech->get_email; is $email[0]->header('To'), 'Buckinghamshire <flytipping@chiltern>'; }; @@ -245,7 +263,7 @@ subtest 'extra CSV columns are present' => sub { $mech->get_ok('/dashboard?export=1'); my @rows = $mech->content_as_csv; - is scalar @rows, 5, '1 (header) + 4 (reports) = 5 lines'; + is scalar @rows, 6, '1 (header) + 4 (reports) = 6 lines'; is scalar @{$rows[0]}, 21, '21 columns present'; is_deeply $rows[0], |