diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-06-12 13:58:23 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-06-12 13:58:23 +0100 |
commit | 84d9686c524e380d53601314e2a4623ddf3bbded (patch) | |
tree | 16643045f74e9edab78d76c0c06185e346980658 | |
parent | 493984c28055333dc9f7736724d77eb50b6d5007 (diff) |
[Hounslow] Fix restriction lookup on around pages.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Hounslow.pm | 3 | ||||
-rw-r--r-- | t/cobrand/hounslow.t | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm index 1628715c6..ad764fdfd 100644 --- a/perllib/FixMyStreet/Cobrand/Hounslow.pm +++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm @@ -181,8 +181,9 @@ sub lookup_site_code_config { { # their cobrand at all. sub problems_restriction { my ($self, $rs) = @_; + my $table = ref $rs eq 'FixMyStreet::DB::ResultSet::Nearby' ? 'problem' : 'me'; return $rs->to_body($self->body)->search({ - 'me.confirmed' => { '>=', '2019-05-06' } + "$table.confirmed" => { '>=', '2019-05-06' } }); } diff --git a/t/cobrand/hounslow.t b/t/cobrand/hounslow.t index 8fac848b1..43a5a5523 100644 --- a/t/cobrand/hounslow.t +++ b/t/cobrand/hounslow.t @@ -21,11 +21,18 @@ $mech->create_contact_ok( $mech->create_problems_for_body(1, $hounslow_id, 'An old problem made before Hounslow FMS launched', { confirmed => '2018-12-25 09:00', lastupdate => '2018-12-25 09:00', + latitude => 51.482286, + longitude => -0.328163, + }); $mech->create_problems_for_body(1, $hounslow_id, 'A brand new problem made on the Hounslow site', { + latitude => 51.482286, + longitude => -0.328163, cobrand => 'hounslow' }); my ($report) = $mech->create_problems_for_body(1, $hounslow_id, 'A brand new problem made on fixmystreet.com', { + latitude => 51.482286, + longitude => -0.328163, external_id => 'ABC123', cobrand => 'fixmystreet' }); @@ -49,7 +56,18 @@ subtest "it does not show old reports on Hounslow" => sub { ALLOWED_COBRANDS => 'hounslow', }, sub { $mech->get_ok('/reports/Hounslow'); + $mech->content_lacks('An old problem made before Hounslow FMS launched'); + $mech->content_contains('A brand new problem made on the Hounslow site') or diag $mech->content; + $mech->content_contains('A brand new problem made on fixmystreet.com'); + }; +}; +subtest "it shows the right things on an /around page" => sub { + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + ALLOWED_COBRANDS => 'hounslow', + }, sub { + $mech->get_ok('/around?pc=TW7+5JN'); $mech->content_lacks('An old problem made before Hounslow FMS launched'); $mech->content_contains('A brand new problem made on the Hounslow site') or diag $mech->content; $mech->content_contains('A brand new problem made on fixmystreet.com'); |