diff options
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 26 | ||||
-rw-r--r-- | t/app/controller/around.t | 25 |
2 files changed, 42 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index dc08f0240..2a9c3ba7b 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -532,19 +532,22 @@ sub delete_problems_for_council { } sub create_problems_for_council { - my ( $mech, $count, $council, $title, $dt, $user ) = @_; + my ( $mech, $count, $council, $title, $params ) = @_; - $dt = DateTime->now() unless $dt; + my $dt = DateTime->now() || $params->{dt}; - my @problems; - - $user = + my $user = FixMyStreet::App->model('DB::User') ->find_or_create( { email => 'test@example.com', name => 'Test User' } ) - unless $user;; + or $params->{user}; + + delete $params->{user}; + delete $params->{dt}; - while ( $count ) { - my $problem = FixMyStreet::App->model('DB::Problem')->create( { + my @problems; + + while ($count) { + my $default_params = { postcode => 'SW1A 1AA', council => $council, areas => ',105255,11806,11828,2247,2504,', @@ -565,7 +568,12 @@ sub create_problems_for_council { longitude => '-0.142497580865087', user_id => $user->id, photo => 1, - } ); + }; + + my %report_params = ( %$default_params, %$params ); + + my $problem = + FixMyStreet::App->model('DB::Problem')->create( \%report_params ); push @problems, $problem; $count--; diff --git a/t/app/controller/around.t b/t/app/controller/around.t index db03e00f4..0ef9c95cf 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -78,4 +78,29 @@ foreach my $test ( }; } +subtest 'check non public reports are not displayed on around page' => sub { + my $params = { + postcode => 'EH99 1SP', + latitude => 55.9519637512, + longitude => -3.17492254484, + }; + my @edinburgh_problems = + $mech->create_problems_for_council( 5, 2651, 'Around page', $params ); + + $mech->get_ok('/'); + $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP' } }, + "good location" ); + $mech->content_contains( 'Around page Test 3 for 2651', + 'problem to be marked non public visible' ); + + my $private = $edinburgh_problems[2]; + ok $private->update( { non_public => 1 } ), 'problem marked non public'; + + $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP' } }, + "good location" ); + $mech->content_lacks( 'Around page Test 3 for 2651', + 'problem marked non public is not visible' ); +}; + + done_testing(); |