diff options
author | Matthew Somerville <matthew@mysociety.org> | 2014-12-11 16:42:53 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-12-12 12:41:31 +0000 |
commit | 43c98742ee85c73c4783451ceeea28108bb793c6 (patch) | |
tree | 40ced5bfa4a7b6c0328da62f8332cdc06a6637ea /perllib/FixMyStreet/TestMech.pm | |
parent | 4edc79829ebf2f6dcce11185e929a2a592a3f5ed (diff) |
By default, use area-based alerts.
The body-based alert only works if the body ID matches the MapIt ID.
This fixes #959. Further work needs to be done to enable proper
body-based alerts that work properly in all circumstances.
Consequently, factor out fixed body IDs from many tests.
Also fix a couple of tests not overriding geocoder correctly.
Diffstat (limited to 'perllib/FixMyStreet/TestMech.pm')
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 5b063ebe5..72a6810bc 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -534,6 +534,17 @@ sub get_ok_json { return decode_json( $res->content ); } +sub delete_body { + my $mech = shift; + my $body = shift; + + $mech->delete_problems_for_body($body->id); + $body->contacts->delete; + $mech->delete_user($_) for $body->users; + $body->body_areas->delete; + $body->delete; +} + sub delete_problems_for_body { my $mech = shift; my $body = shift; @@ -542,6 +553,7 @@ sub delete_problems_for_body { if ( $reports ) { for my $r ( $reports->all ) { $r->comments->delete; + $r->questionnaires->delete; } $reports->delete; } @@ -549,16 +561,21 @@ sub delete_problems_for_body { 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"; + my ( $area_id, $name, %extra ) = @_; + + my $body = FixMyStreet::App->model('DB::Body'); + my $params = { name => $name }; + if ($extra{id}) { + $body = $body->update_or_create({ %$params, id => $extra{id} }, { key => 'primary' }); + } else { + $body = $body->find_or_create($params); + } + ok $body, "found/created body $name"; + $body->body_areas->delete; FixMyStreet::App->model('DB::BodyArea')->find_or_create({ - area_id => $id, - body_id => $id, + area_id => $area_id, + body_id => $body->id, }); return $body; |