From f93f38c0cd21ecf3e90bd926a67b9e798c80e0d0 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 13 Mar 2013 13:36:40 +0000 Subject: check for mm_url before refreshing Message Manager messages (fixes mysociety/message-manager#169) --- templates/web/fixmybarangay/report/_message_manager.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/web/fixmybarangay/report/_message_manager.html b/templates/web/fixmybarangay/report/_message_manager.html index b2537e907..3845feeef 100644 --- a/templates/web/fixmybarangay/report/_message_manager.html +++ b/templates/web/fixmybarangay/report/_message_manager.html @@ -73,7 +73,7 @@ $(document).ready(function() { // call this to push the auto-refresh timeout off so it's only triggered // if there's no activity for a while function reset_timeout() { - if (refresh_period && can_refresh) { + if (mm_url && refresh_period && can_refresh) { if (timeout_id) { clearTimeout(timeout_id); } -- cgit v1.2.3 From c4637a42cc8eae31cc6c0d22cb8f465ea9824363 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 13 Mar 2013 22:19:40 +0000 Subject: FMB council_id should be string not array --- perllib/FixMyStreet/Cobrand/FixMyBarangay.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perllib/FixMyStreet/Cobrand/FixMyBarangay.pm b/perllib/FixMyStreet/Cobrand/FixMyBarangay.pm index 1eda6cf43..c7535f856 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyBarangay.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyBarangay.pm @@ -34,7 +34,7 @@ sub only_authed_can_create { } # effectively allows barangay staff to hide reports -sub council_id { return [ 1, 2 ]; } +sub council_id { return '1,2' ; } sub areas_on_around { return [ 1, 2 ]; -- cgit v1.2.3 From f9770a0c938cd1587f275d5ed2fa64bdaf40b567 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 13 Mar 2013 22:21:06 +0000 Subject: use body id for user-can-hide-this-body check --- perllib/FixMyStreet/App/Controller/Report.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 460ccaec5..3a707b18c 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -218,7 +218,7 @@ sub delete :Local :Args(1) { my $body = $c->user->obj->from_body; return $c->res->redirect($uri) unless $body; - return $c->res->redirect($uri) unless $p->bodies->{$body}; + return $c->res->redirect($uri) unless $p->bodies->{$body->id}; $p->state('hidden'); $p->lastupdate( \'ms_current_timestamp()' ); -- cgit v1.2.3 From 67944e4bf8a716a45b7986b7df8fb44014265007 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 13 Mar 2013 22:21:48 +0000 Subject: tests for hide-a-report (in fixmybarangay cobrand) --- t/cobrand/fixmybarangay.t | 28 +++++++++++++++++++++++++++ templates/web/fixmystreet/report/display.html | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/t/cobrand/fixmybarangay.t b/t/cobrand/fixmybarangay.t index bc099bb20..d02dbe2e3 100644 --- a/t/cobrand/fixmybarangay.t +++ b/t/cobrand/fixmybarangay.t @@ -90,6 +90,34 @@ ok $dps_report->whensent, 'DPS report marked as sent'; is $dps_report->send_method_used, 'Open311', 'DPS report sent via Open311'; is $dps_report->external_id, 248, 'DPS report has right external ID'; +my $fmb_test_email = 'luz_test_user@example.com'; +my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $fmb_test_email, from_body => 1, password => 'fmbsecret' } ); +ok $user, "test user does exist"; + +$mech->log_out_ok; +$mech->get_ok( '/report/' . $luz_report->id ); +$mech->content_lacks( "Remove from site" ); +$mech->content_contains( "Report abuse" ); + +$mech->post_ok('/report/delete/' . $luz_report->id); +is $mech->uri->path, '/report/' . $luz_report->id, "should redirect to report page, deletion ignored"; +$luz_report->discard_changes; +is $luz_report->state, 'confirmed', 'should be confirmed'; + +$user = $mech->log_in_ok($fmb_test_email); + +$mech->get_ok( '/report/' . $luz_report->id ); +$mech->content_contains( "Remove from site" ); +$mech->content_lacks( "Report abuse" ); + +$mech->form_id('remove-from-site-form'); +$mech->submit_form(); +is $mech->uri->path, '/report/' . $luz_report->id, "should redirect to report page, deletion successful"; +$luz_report->discard_changes; +is $luz_report->state, 'hidden', 'should be hidden'; + +$mech->delete_user($fmb_test_email); + $mech->delete_problems_for_body( 1 ); $mech->delete_problems_for_body( 3 ); diff --git a/templates/web/fixmystreet/report/display.html b/templates/web/fixmystreet/report/display.html index 9bcf1e5b9..44838c0ab 100644 --- a/templates/web/fixmystreet/report/display.html +++ b/templates/web/fixmystreet/report/display.html @@ -28,7 +28,7 @@
    [% IF c.user_exists AND c.cobrand.users_can_hide AND c.user.belongs_to_body( c.cobrand.council_id ) %] -
  • +
  • [% ELSIF c.cobrand.moniker != 'zurich' %] -- cgit v1.2.3