aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2014-12-11 16:42:53 +0000
committerMatthew Somerville <matthew@mysociety.org>2014-12-12 12:41:31 +0000
commit43c98742ee85c73c4783451ceeea28108bb793c6 (patch)
tree40ced5bfa4a7b6c0328da62f8332cdc06a6637ea /t/cobrand
parent4edc79829ebf2f6dcce11185e929a2a592a3f5ed (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 't/cobrand')
-rw-r--r--t/cobrand/bromley.t6
-rw-r--r--t/cobrand/fixamingata.t2
-rw-r--r--t/cobrand/fixmybarangay.t22
-rw-r--r--t/cobrand/seesomething.t2
-rw-r--r--t/cobrand/zurich.t38
5 files changed, 33 insertions, 37 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 91a7038ec..6437ba3bd 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -7,9 +7,9 @@ my $mech = FixMyStreet::TestMech->new;
# Create test data
my $user = $mech->create_user_ok( 'bromley@example.com' );
-my $body = $mech->create_body_ok( 2482, 'Bromley' );
+my $body = $mech->create_body_ok( 2482, 'Bromley', id => 2482 );
-my @reports = $mech->create_problems_for_body( 1, 2482, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
cobrand => 'bromley',
user => $user,
});
@@ -38,5 +38,5 @@ $mech->content_contains( 'marked as no further action' );
# Clean up
$mech->delete_user($user);
-$mech->delete_problems_for_body( 2482 );
+$mech->delete_problems_for_body( $body->id );
done_testing();
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t
index daa7a2e8f..105847576 100644
--- a/t/cobrand/fixamingata.t
+++ b/t/cobrand/fixamingata.t
@@ -32,7 +32,7 @@ FixMyStreet::App->model('DB::Contact')->find_or_create({
note => 'Note',
});
-my @reports = $mech->create_problems_for_body( 1, 1, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
cobrand => 'fixamingata',
latitude => '55.605833',
longitude => '13.035833',
diff --git a/t/cobrand/fixmybarangay.t b/t/cobrand/fixmybarangay.t
index b996fa0a6..a431ca62b 100644
--- a/t/cobrand/fixmybarangay.t
+++ b/t/cobrand/fixmybarangay.t
@@ -22,16 +22,16 @@ $mech->content_like( qr/FixMyBarangay/ );
# Set up bodies
-my $luz = $mech->create_body_ok( 1, 'Bgy Luz' );
+my $luz = $mech->create_body_ok( 1, 'Bgy Luz', id => 1 );
$luz->update( { send_method => 'Email' } );
-my $bsn = $mech->create_body_ok( 2, 'Bgy BSN' );
+my $bsn = $mech->create_body_ok( 2, 'Bgy BSN', id => 2 );
$bsn->update( { send_method => 'Email' } );
my $dps = $mech->create_body_ok( 3, 'DPS' );
$dps->update( { send_method => 'Open311', endpoint => 'http://dps.endpoint.example.com', jurisdiction => 'FMB', api_key => 'test' } );
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 1, body_id => 3 });
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 2, body_id => 3 });
+FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 1, body_id => $dps->id });
+FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 2, body_id => $dps->id });
# Create contacts for these bodies
# TODO: log in as a Bgy user, and create a report using the front end,
@@ -49,26 +49,26 @@ FixMyStreet::App->model('DB::Contact')->search( {
} )->delete;
my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 1,
+ body_id => $luz->id,
category => 'Streetlight (BGY)',
email => 'bgy@example.com',
} );
my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 3,
+ body_id => $dps->id,
category => 'Streetlight (DPS)',
email => 'LIGHT',
} );
# Create a couple of reports
-my @reports = $mech->create_problems_for_body( 1, 1, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $luz->id, 'Test', {
cobrand => 'fixmybarangay',
category => 'Streetlight (BGY)',
});
my $luz_report = $reports[0];
-@reports = $mech->create_problems_for_body( 1, 3, 'Test', {
+@reports = $mech->create_problems_for_body( 1, $dps->id, 'Test', {
cobrand => 'fixmybarangay',
category => 'Streetlight (DPS)',
});
@@ -101,7 +101,7 @@ 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' } );
+my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $fmb_test_email, from_body => $luz->id, password => 'fmbsecret' } );
ok $user, "test user does exist";
$mech->log_out_ok;
@@ -132,8 +132,8 @@ 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 );
+$mech->delete_problems_for_body( $luz->id );
+$mech->delete_problems_for_body( $dps->id );
ok $mech->host("www.fixmystreet.com"), "change host back";
diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t
index 1c36925e4..57a8a11ed 100644
--- a/t/cobrand/seesomething.t
+++ b/t/cobrand/seesomething.t
@@ -20,7 +20,7 @@ $db->resultset('Problem')->delete;
my $user = $mech->create_user_ok( $EMAIL );
-my $body = $mech->create_body_ok( 2520, 'Coventry City Council' );
+my $body = $mech->create_body_ok( 2520, 'Coventry City Council', id => 2520 );
$mech->create_body_ok( 2522, 'Dudley Borough Council' );
$mech->create_body_ok( 2514, 'Birmingham City Council' );
$mech->create_body_ok( 2546, 'Walsall Borough Council' );
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index e8cf3bee3..8dbc43464 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -71,13 +71,6 @@ $external_body->send_method( 'Zurich' );
$external_body->endpoint( 'external_body@example.org' );
$external_body->update;
-sub cleanup {
- $mech->delete_problems_for_body( $division->id );
- $mech->delete_problems_for_body( $subdivision->id );
- $mech->delete_user( 'dm1@example.org' );
- $mech->delete_user( 'sdm1@example.org' );
-}
-
sub get_export_rows_count {
my $mech = shift;
FixMyStreet::override_config {
@@ -93,8 +86,6 @@ sub get_export_rows_count {
return;
}
-cleanup();
-
my $EXISTING_REPORT_COUNT = 0;
subtest "set up superuser" => sub {
@@ -105,7 +96,7 @@ subtest "set up superuser" => sub {
$mech->log_out_ok;
};
-my @reports = $mech->create_problems_for_body( 1, 2, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $division->id, 'Test', {
state => 'unconfirmed',
confirmed => undef,
cobrand => 'zurich',
@@ -131,7 +122,7 @@ FixMyStreet::override_config {
$user->update;
$mech->get_ok( '/admin' );
is $mech->uri->path, '/my', "got sent to /my";
- $user->from_body( 2 );
+ $user->from_body( $division->id );
$user->update;
$mech->get_ok( '/admin' );
@@ -325,10 +316,10 @@ FixMyStreet::override_config {
# Original description
$mech->submit_form_ok( { with_fields => { detail => 'Edited details text.' } } );
$mech->content_contains( 'Edited details text.' );
- $mech->content_contains( 'Originaltext: &ldquo;Test Test 1 for 2 Detail&rdquo;' );
+ $mech->content_contains( 'Originaltext: &ldquo;Test Test 1 for ' . $division->id . ' Detail&rdquo;' );
$mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { body_subdivision => 3, send_rejected_email => 1 } } );
+ $mech->submit_form_ok( { with_fields => { body_subdivision => $subdivision->id, send_rejected_email => 1 } } );
$mech->get_ok( '/report/' . $report->id );
$mech->content_contains('In Bearbeitung');
@@ -351,7 +342,7 @@ FixMyStreet::override_config {
$mech->get_ok( '/admin' );
};
is $mech->uri->path, '/my', "got sent to /my";
-$user->from_body( 3 );
+$user->from_body( $subdivision->id );
$user->update;
FixMyStreet::override_config {
@@ -431,7 +422,7 @@ like $email->body, qr/FINAL UPDATE/, 'body looks correct';
$mech->clear_emails_ok;
# Assign directly to planned, don't confirm email
-@reports = $mech->create_problems_for_body( 1, 2, 'Second', {
+@reports = $mech->create_problems_for_body( 1, $division->id, 'Second', {
state => 'unconfirmed',
confirmed => undef,
cobrand => 'zurich',
@@ -465,7 +456,7 @@ $mech->email_count_is(0);
# Report assigned to third party
-@reports = $mech->create_problems_for_body( 1, 2, 'Third', {
+@reports = $mech->create_problems_for_body( 1, $division->id, 'Third', {
state => 'unconfirmed',
confirmed => undef,
cobrand => 'zurich',
@@ -476,7 +467,7 @@ FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],
}, sub {
$mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { body_external => 4 } } );
+ $mech->submit_form_ok( { with_fields => { body_external => $external_body->id } } );
$mech->get_ok( '/report/' . $report->id );
};
$mech->content_contains('Beantwortet');
@@ -499,7 +490,7 @@ FixMyStreet::override_config {
$mech->content_contains( 'report_edit/' . $report->id );
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->submit_form_ok( { with_fields => { state => 'unconfirmed' } } );
- $mech->submit_form_ok( { with_fields => { body_external => 4, third_personal => 1 } } );
+ $mech->submit_form_ok( { with_fields => { body_external => $external_body->id, third_personal => 1 } } );
$mech->get_ok( '/report/' . $report->id );
};
$mech->content_contains('Beantwortet');
@@ -604,7 +595,7 @@ subtest "phone number is not mandatory for reports from mobile apps" => sub {
subtest "problems can't be assigned to deleted bodies" => sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
- $user->from_body( 1 );
+ $user->from_body( $zurich->id );
$user->update;
$report->state( 'confirmed' );
$report->update;
@@ -619,7 +610,7 @@ subtest "problems can't be assigned to deleted bodies" => sub {
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->content_lacks( $external_body->name );
};
- $user->from_body( 2 );
+ $user->from_body( $division->id );
$user->update;
$mech->log_out_ok;
};
@@ -681,7 +672,12 @@ subtest "test admin_log" => sub {
};
END {
- cleanup();
+ $mech->delete_body($subdivision);
+ $mech->delete_body($division);
+ $mech->delete_body($zurich);
+ $mech->delete_body($external_body);
+ $mech->delete_user( 'dm1@example.org' );
+ $mech->delete_user( 'sdm1@example.org' );
ok $mech->host("www.fixmystreet.com"), "change host back";
done_testing();
}