diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-12 16:48:27 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-15 00:11:05 +0000 |
commit | fa4947c017af7599699892c1c3a647fc61f971ed (patch) | |
tree | 71cf677abe1891f40a79fa2a1e606929ad8f7640 /t | |
parent | 07b07d90cf666a06cb071ceebcecbd21d91e6b60 (diff) |
Rename area_id on Contacts table to body_id.
Add foreign key constraint from contacts to body.
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin.t | 4 | ||||
-rw-r--r-- | t/app/controller/dashboard.t | 4 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 14 | ||||
-rw-r--r-- | t/app/controller/report_new_open311.t | 4 | ||||
-rw-r--r-- | t/app/model/problem.t | 16 | ||||
-rw-r--r-- | t/app/sendreport/email.t | 2 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 40 |
7 files changed, 42 insertions, 42 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 644e488b2..71a391c59 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -151,12 +151,12 @@ $mech->content_contains("$host/around"); subtest 'check contact creation' => sub { my $contact = FixMyStreet::App->model('DB::Contact')->search( - { area_id => 2650, category => [ 'test category', 'test/category' ] } + { body_id => 2650, category => [ 'test category', 'test/category' ] } ); $contact->delete_all; my $history = FixMyStreet::App->model('DB::ContactsHistory')->search( - { area_id => 2650, category => [ 'test category', 'test/category' ] } + { body_id => 2650, category => [ 'test category', 'test/category' ] } ); $history->delete_all; diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 945f7a9d7..307943abd 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -44,7 +44,7 @@ $mech->submit_form_ok( { $mech->content_contains( 'City of Edinburgh' ); -FixMyStreet::App->model('DB::Contact')->search( { area_id => $test_council } ) +FixMyStreet::App->model('DB::Contact')->search( { body_id => $test_council } ) ->delete; delete_problems(); @@ -53,7 +53,7 @@ my @cats = qw( Grafitti Litter Potholes Other ); for my $contact ( @cats ) { FixMyStreet::App->model('DB::Contact')->create( { - area_id => $test_council, + body_id => $test_council, category => $contact, email => "$contact\@example.org", confirmed => 1, diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 77afb071c..92943bde9 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -39,43 +39,43 @@ FixMyStreet::App->model('DB::Contact')->search( { } )->delete; my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2651, # Edinburgh + body_id => 2651, # Edinburgh category => 'Street lighting', email => 'highways@example.com', } ); my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2226, # Gloucestershire + body_id => 2226, # Gloucestershire category => 'Potholes', email => 'potholes@example.com', } ); my $contact3 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2326, # Cheltenham + body_id => 2326, # Cheltenham category => 'Trees', email => 'trees@example.com', } ); my $contact4 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2482, # Bromley + body_id => 2482, # Bromley category => 'Trees', email => 'trees@example.com', } ); my $contact5 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2651, # Edinburgh + body_id => 2651, # Edinburgh category => 'Trees', email => 'trees@example.com', } ); my $contact6 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2434, # Lichfield + body_id => 2434, # Lichfield category => 'Trees', email => 'trees@example.com', } ); my $contact7 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2240, # Lichfield + body_id => 2240, # Lichfield category => 'Street lighting', email => 'highways@example.com', } ); diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index 4b009c746..e9ada9f41 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -24,7 +24,7 @@ my %contact_params = ( # Let's make some contacts to send things to! my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2651, # Edinburgh + body_id => 2651, # Edinburgh category => 'Street lighting', email => '100', extra => [ { description => 'Lamppost number', code => 'number', required => 'True' }, @@ -35,7 +35,7 @@ my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( { } ); my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - area_id => 2651, # Edinburgh + body_id => 2651, # Edinburgh category => 'Graffiti Removal', email => '101', } ); diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 9aa52c3cf..baec6baf0 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -361,36 +361,36 @@ FixMyStreet::App->model('DB::Contact')->search( { } )->delete; my @contacts; for my $contact ( { - area_id => 2651, # Edinburgh + body_id => 2651, # Edinburgh category => 'potholes', email => 'test@example.org', }, { - area_id => 2226, # Gloucestershire + body_id => 2226, # Gloucestershire category => 'potholes', email => '2226@example.org', }, { - area_id => 2326, # Cheltenham + body_id => 2326, # Cheltenham category => 'potholes', email => '2326@example.org', }, { - area_id => 2434, # Lichfield + body_id => 2434, # Lichfield category => 'potholes', email => 'trees@example.com', }, { - area_id => 2240, # Staffordshire + body_id => 2240, # Staffordshire category => 'potholes', email => 'highways@example.com', }, { - area_id => 14279, # Ballymoney + body_id => 14279, # Ballymoney category => 'Street lighting', email => 'roads.western@drdni.example.org', }, { - area_id => 14279, # Ballymoney + body_id => 14279, # Ballymoney category => 'Graffiti', email => 'highways@example.com', }, { confirmed => 0, - area_id => 2636, # Isle of Wight + body_id => 2636, # Isle of Wight category => 'potholes', email => '2636@example.com', } ) { diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t index f0e1f153a..04b3854cc 100644 --- a/t/app/sendreport/email.t +++ b/t/app/sendreport/email.t @@ -16,7 +16,7 @@ my $e = FixMyStreet::SendReport::Email->new(); my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( email => 'council@example.com', - area_id => 1000, + body_id => 1000, category => 'category', confirmed => 1, deleted => 0, diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index 8c23e6465..ec6c175f9 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -20,7 +20,7 @@ ok $processor, 'created object'; subtest 'check basic functionality' => sub { - FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete(); + FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete(); my $service_list = get_xml_simple_object( get_standard_xml() ); @@ -32,16 +32,16 @@ subtest 'check basic functionality' => sub { $processor->_current_council( $council ); $processor->process_services( $service_list ); - my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count(); + my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count(); is $contact_count, 3, 'correct number of contacts'; }; subtest 'check non open311 contacts marked as deleted' => sub { - FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete(); + FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete(); my $contact = FixMyStreet::App->model('DB::Contact')->create( { - area_id => 1, + body_id => 1, email => 'contact@example.com', category => 'An old category', confirmed => 1, @@ -62,19 +62,19 @@ subtest 'check non open311 contacts marked as deleted' => sub { $processor->_current_council( $council ); $processor->process_services( $service_list ); - my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count(); + my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count(); is $contact_count, 4, 'correct number of contacts'; - $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1, deleted => 1 } )->count(); + $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1, deleted => 1 } )->count(); is $contact_count, 1, 'correct number of deleted contacts'; }; subtest 'check email changed if matching category' => sub { - FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete(); + FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete(); my $contact = FixMyStreet::App->model('DB::Contact')->create( { - area_id => 1, + body_id => 1, email => '009', category => 'Cans left out 24x7', confirmed => 1, @@ -102,16 +102,16 @@ subtest 'check email changed if matching category' => sub { is $contact->confirmed, 1, 'contact still confirmed'; is $contact->deleted, 0, 'contact still not deleted'; - my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count(); + my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count(); is $contact_count, 3, 'correct number of contacts'; }; subtest 'check category name changed if updated' => sub { - FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete(); + FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete(); my $contact = FixMyStreet::App->model('DB::Contact')->create( { - area_id => 1, + body_id => 1, email => '001', category => 'Bins left out 24x7', confirmed => 1, @@ -140,16 +140,16 @@ subtest 'check category name changed if updated' => sub { is $contact->confirmed, 1, 'contact still confirmed'; is $contact->deleted, 0, 'contact still not deleted'; - my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count(); + my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count(); is $contact_count, 3, 'correct number of contacts'; }; subtest 'check conflicting contacts not changed' => sub { - FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete(); + FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete(); my $contact = FixMyStreet::App->model('DB::Contact')->create( { - area_id => 1, + body_id => 1, email => 'existing@example.com', category => 'Cans left out 24x7', confirmed => 1, @@ -164,7 +164,7 @@ subtest 'check conflicting contacts not changed' => sub { my $contact2 = FixMyStreet::App->model('DB::Contact')->create( { - area_id => 1, + body_id => 1, email => '001', category => 'Bins left out 24x7', confirmed => 1, @@ -199,7 +199,7 @@ subtest 'check conflicting contacts not changed' => sub { is $contact2->confirmed, 1, 'second contact contact still confirmed'; is $contact2->deleted, 0, 'second contact contact still not deleted'; - my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count(); + my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count(); is $contact_count, 4, 'correct number of contacts'; }; @@ -225,7 +225,7 @@ subtest 'check meta data population' => sub { my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( { - area_id => 1, + body_id => 1, email => '001', category => 'Bins left out 24x7', confirmed => 1, @@ -409,7 +409,7 @@ for my $test ( my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( { - area_id => 1, + body_id => 1, email => '100', category => 'Cans left out 24x7', confirmed => 1, @@ -487,7 +487,7 @@ subtest 'check attribute ordering' => sub { my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( { - area_id => 1, + body_id => 1, email => '001', category => 'Bins left out 24x7', confirmed => 1, @@ -593,7 +593,7 @@ subtest 'check bromely skip code' => sub { my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( { - area_id => 1, + body_id => 1, email => '001', category => 'Bins left out 24x7', confirmed => 1, |