diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-06-13 18:39:05 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-06-20 15:02:11 +0100 |
commit | e57cbf483790bedfef6496be3c7ffa42882c3ffc (patch) | |
tree | d01788502457f801a846cdac78213df5ecdf1ea5 /t | |
parent | a5f311e5147621f285cf31647ce675c502095882 (diff) |
[UK] Remove requirement for fixed body IDs.
Historically in UK cobrands, bodies have had IDs the same as the MapIt
area ID they cover. This can be confusing (if you are setting up a dev
environment, say) and should not be necessary. This commit removes the
requirement entirely, by switching any ID checks to either the name of
the body, or the actual area it covers.
One note: the body name in the test has to match so that we do not get
two bodies both covering 2237 created. This will not be necessary when
the tests are compartmentalized in the next commit.
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin.t | 6 | ||||
-rw-r--r-- | t/app/controller/admin_permissions.t | 4 | ||||
-rw-r--r-- | t/app/controller/index.t | 2 | ||||
-rw-r--r-- | t/app/controller/my_planned.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_display.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_inspect.t | 6 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 10 | ||||
-rw-r--r-- | t/app/model/defecttype.t | 6 | ||||
-rw-r--r-- | t/app/script/archive_old_enquiries.t | 6 | ||||
-rw-r--r-- | t/app/sendreport/inspection_required.t | 2 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 2 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 2 | ||||
-rw-r--r-- | t/cobrand/two_tier.t | 4 |
13 files changed, 27 insertions, 27 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 48a5edc44..07759197e 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -8,7 +8,7 @@ my $user2 = $mech->create_user_ok('test2@example.com', name => 'Test User 2'); my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); -my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $oxfordshirecontact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => 'potholes@example.com' ); $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Traffic lights', email => 'lights@example.com' ); my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxfordshire); @@ -16,7 +16,7 @@ my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => ' my $oxford = $mech->create_body_ok(2421, 'Oxford City Council'); $mech->create_contact_ok( body_id => $oxford->id, category => 'Graffiti', email => 'graffiti@example.net' ); -my $bromley = $mech->create_body_ok(2482, 'Bromley Council', id => 2482); +my $bromley = $mech->create_body_ok(2482, 'Bromley Council'); my $user3 = $mech->create_user_ok('test3@example.com', name => 'Test User 2'); @@ -115,7 +115,7 @@ subtest 'check summary counts' => sub { my ($num_alerts) = $mech->content =~ /(\d+) confirmed alerts/; my ($num_qs) = $mech->content =~ /(\d+) questionnaires sent/; - $report->bodies_str(2237); + $report->bodies_str($oxfordshire->id); $report->cobrand('oxfordshire'); $report->update; diff --git a/t/app/controller/admin_permissions.t b/t/app/controller/admin_permissions.t index c79087639..f30777d16 100644 --- a/t/app/controller/admin_permissions.t +++ b/t/app/controller/admin_permissions.t @@ -6,10 +6,10 @@ my $user = $mech->create_user_ok('test@example.com', name => 'Test User'); my $user2 = $mech->create_user_ok('test2@example.com', name => 'Test User 2'); my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); -my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxfordshire); -my $bromley = $mech->create_body_ok(2482, 'Bromley Council', id => 2482); +my $bromley = $mech->create_body_ok(2482, 'Bromley Council'); END { $mech->delete_user( $user ); diff --git a/t/app/controller/index.t b/t/app/controller/index.t index 91d0a8fcb..654ebfcce 100644 --- a/t/app/controller/index.t +++ b/t/app/controller/index.t @@ -71,7 +71,7 @@ ok $mech->get('/report/' . $edinburgh_problems[2]->id); is $mech->res->code, 403, 'page forbidden'; is $problem_rs->count, $num+5; -my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council'); subtest "prefilters /around if user has categories" => sub { my $user = $mech->log_in_ok('test@example.com'); my $categories = [ diff --git a/t/app/controller/my_planned.t b/t/app/controller/my_planned.t index 79d9e9e72..9e9ac06a2 100644 --- a/t/app/controller/my_planned.t +++ b/t/app/controller/my_planned.t @@ -4,7 +4,7 @@ my $mech = FixMyStreet::TestMech->new; $mech->get_ok('/my/planned'); is $mech->uri->path, '/auth', "got sent to the sign in page"; -my $body = $mech->create_body_ok(2237, 'Oxfordshire'); +my $body = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my ($problem) = $mech->create_problems_for_body(1, $body->id, 'Test Title'); $mech->get_ok($problem->url); diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 5993a6304..a8c618d49 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -526,7 +526,7 @@ subtest "Zurich banners are displayed correctly" => sub { }; }; -my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxfordshire); subtest "check user details show when a user has correct permissions" => sub { diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 8b375bfe4..a0407cb32 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -2,8 +2,8 @@ use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; -my $brum = $mech->create_body_ok(2514, 'Birmingham City Council', id => 2514); -my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $brum = $mech->create_body_ok(2514, 'Birmingham City Council'); +my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $contact = $mech->create_contact_ok( body_id => $oxon->id, category => 'Cows', email => 'cows@example.net' ); my $rp = FixMyStreet::DB->resultset("ResponsePriority")->create({ body => $oxon, @@ -13,7 +13,7 @@ FixMyStreet::DB->resultset("ContactResponsePriority")->create({ contact => $contact, response_priority => $rp, }); -my $wodc = $mech->create_body_ok(2420, 'West Oxfordshire District Council', id => 2420); +my $wodc = $mech->create_body_ok(2420, 'West Oxfordshire District Council'); $mech->create_contact_ok( body_id => $wodc->id, category => 'Horses', email => 'horses@example.net' ); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 36400ae81..0deef8196 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -36,13 +36,11 @@ for my $body ( { area_id => 2226, name => 'Gloucestershire County Council' }, { area_id => 2326, name => 'Cheltenham Borough Council' }, { area_id => 2504, name => 'Westminster City Council' }, - # The next three have fixed IDs because bits of the code rely on - # the body ID === MapIt area ID. - { area_id => 2482, name => 'Bromley Council', id => 2482 }, - { area_id => 2227, name => 'Hampshire County Council', id => 2227 }, - { area_id => 2333, name => 'Hart Council', id => 2333 }, + { area_id => 2482, name => 'Bromley Council' }, + { area_id => 2227, name => 'Hampshire County Council' }, + { area_id => 2333, name => 'Hart Council' }, ) { - my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name}, id => $body->{id}); + my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name}); push @bodies, $body_obj; $body_ids{$body->{area_id}} = $body_obj->id; } diff --git a/t/app/model/defecttype.t b/t/app/model/defecttype.t index 6a03deded..c3e3035a6 100644 --- a/t/app/model/defecttype.t +++ b/t/app/model/defecttype.t @@ -2,13 +2,13 @@ use FixMyStreet::App; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; -my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $potholes_contact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => 'potholes@example.com' ); my $traffic_lights_contact =$mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Traffic lights', email => 'lights@example.com' ); my $potholes_defect_type = FixMyStreet::App->model('DB::DefectType')->find_or_create( { - body_id => 2237, + body_id => $oxfordshire->id, name => 'Potholes', description => 'This defect type is to do with potholes' } @@ -19,7 +19,7 @@ $potholes_defect_type->contact_defect_types->find_or_create({ my $general_defect_type = FixMyStreet::App->model('DB::DefectType')->find_or_create( { - body_id => 2237, + body_id => $oxfordshire->id, name => 'All categories', description => 'This defect type is for all categories' } diff --git a/t/app/script/archive_old_enquiries.t b/t/app/script/archive_old_enquiries.t index 589aeceda..148f73cf2 100644 --- a/t/app/script/archive_old_enquiries.t +++ b/t/app/script/archive_old_enquiries.t @@ -12,8 +12,10 @@ my $opts = { }; my $user = $mech->create_user_ok('test@example.com', name => 'Test User'); -my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); -my $west_oxon = $mech->create_body_ok(2420, 'West Oxfordshire District Council', id => 2420); +my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council'); +my $west_oxon = $mech->create_body_ok(2420, 'West Oxfordshire District Council'); + +$opts->{body} = $oxfordshire->id; subtest 'sets reports to the correct status' => sub { FixMyStreet::override_config { diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t index f588e00f1..4301c259a 100644 --- a/t/app/sendreport/inspection_required.t +++ b/t/app/sendreport/inspection_required.t @@ -8,7 +8,7 @@ ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); my $user = $mech->create_user_ok( 'user@example.com' ); -my $body = $mech->create_body_ok( 2237, 'Oxfordshire County Council', id => 2237 ); +my $body = $mech->create_body_ok( 2237, 'Oxfordshire County Council'); # $body->update({ send_method => 'Email' }); my $contact = $mech->create_contact_ok( diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index 0a0ac5163..ad0ef7b14 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -4,7 +4,7 @@ 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 Council', id => 2482 ); +my $body = $mech->create_body_ok( 2482, 'Bromley Council'); my $contact = $mech->create_contact_ok( body_id => $body->id, category => 'Other', diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index fad41be31..7a7d85412 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -1,7 +1,7 @@ use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; -my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council'); subtest 'check /ajax defaults to open reports only' => sub { my $categories = [ 'Bridges', 'Fences', 'Manhole' ]; diff --git a/t/cobrand/two_tier.t b/t/cobrand/two_tier.t index 97bbccc01..6c6a36758 100644 --- a/t/cobrand/two_tier.t +++ b/t/cobrand/two_tier.t @@ -19,8 +19,8 @@ FixMyStreet::override_config { for my $c (@cobrands) { my ($m, $id) = @$c; my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($m); - my $council_id = $cobrand->council_id; - is $council_id, $id, "council_id for $m"; + my $council_area_id = $cobrand->council_area_id; + is $council_area_id, $id, "council_area_id for $m"; } }; |