aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/TestMech.pm
diff options
context:
space:
mode:
authorDave Whiteland <dave@mysociety.org>2013-02-06 15:08:23 +0000
committerDave Whiteland <dave@mysociety.org>2013-02-06 15:08:23 +0000
commit0f24a44cd6e8b056db482cb91c85768b6d1e7d1d (patch)
tree09a90f38574ee62754f3c8ac077152ed99a38296 /perllib/FixMyStreet/TestMech.pm
parentc061769ba72f420e2f2c6064fa526648e57339f1 (diff)
parent5b2e18389734751165d2eeb21a3b3f2e8d2e8755 (diff)
Merge remote branch 'origin/master' into oxfordshire-header
Diffstat (limited to 'perllib/FixMyStreet/TestMech.pm')
-rw-r--r--perllib/FixMyStreet/TestMech.pm34
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',