diff options
Diffstat (limited to 'perllib/FixMyStreet/TestMech.pm')
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 7f81c0fc2..addbb1752 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -519,11 +519,11 @@ sub get_ok_json { return decode_json( $res->content ); } -sub delete_problems_for_council { +sub delete_problems_for_body { my $mech = shift; - my $council = shift; + my $body = shift; - my $reports = FixMyStreet::App->model('DB::Problem')->search( { council => $council } ); + my $reports = FixMyStreet::App->model('DB::Problem')->search( { bodies_str => $body } ); if ( $reports ) { for my $r ( $reports->all ) { $r->comments->delete; @@ -532,8 +532,26 @@ sub delete_problems_for_council { } } -sub create_problems_for_council { - my ( $mech, $count, $council, $title, $params ) = @_; +sub create_body_ok { + my $self = shift; + my ( $id, $name ) = @_; + + my $params = { id => $id, name => $name }; + my $body = FixMyStreet::App->model('DB::Body')->find_or_create($params); + $body->update($params); # Make sure + ok $body, "found/created user for $id $name"; + + FixMyStreet::App->model('DB::BodyArea')->find_or_create({ + area_id => $id, + body_id => $id, + }); + + return $body; + +} + +sub create_problems_for_body { + my ( $mech, $count, $body, $title, $params ) = @_; my $dt = $params->{dt} || DateTime->now(); @@ -549,11 +567,11 @@ sub create_problems_for_council { while ($count) { my $default_params = { postcode => 'SW1A 1AA', - council => $council, + bodies_str => $body, areas => ',105255,11806,11828,2247,2504,', category => 'Other', - title => "$title Test $count for $council", - detail => "$title Test $count for $council Detail", + title => "$title Test $count for $body", + detail => "$title Test $count for $body Detail", used_map => 't', name => 'Test User', anonymous => 'f', |