diff options
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/admin.t | 60 | ||||
-rw-r--r-- | t/app/controller/alert.t | 1 | ||||
-rw-r--r-- | t/app/controller/alert_new.t | 6 | ||||
-rw-r--r-- | t/app/controller/around.t | 8 | ||||
-rw-r--r-- | t/app/controller/dashboard.t | 14 | ||||
-rw-r--r-- | t/app/controller/index.t | 7 | ||||
-rw-r--r-- | t/app/controller/json.t | 2 | ||||
-rw-r--r-- | t/app/controller/moderate.t | 4 | ||||
-rw-r--r-- | t/app/controller/report_display.t | 29 | ||||
-rw-r--r-- | t/app/controller/report_import.t | 4 | ||||
-rw-r--r-- | t/app/controller/report_interest_count.t | 17 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 46 | ||||
-rw-r--r-- | t/app/controller/report_new_open311.t | 4 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 16 | ||||
-rw-r--r-- | t/app/controller/reports.t | 22 |
15 files changed, 124 insertions, 116 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 1757e386f..9ff5b5c90 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -155,23 +155,23 @@ FixMyStreet::override_config { }, sub { my $body = $mech->create_body_ok(2650, 'Aberdeen City Council'); -$mech->get_ok('/admin/body/2650'); +$mech->get_ok('/admin/body/' . $body->id); $mech->content_contains('Aberdeen City Council'); $mech->content_like(qr{AB\d\d}); $mech->content_contains("http://www.example.org/around"); subtest 'check contact creation' => sub { my $contact = FixMyStreet::App->model('DB::Contact')->search( - { body_id => 2650, category => [ 'test category', 'test/category' ] } + { body_id => $body->id, category => [ 'test category', 'test/category' ] } ); $contact->delete_all; my $history = FixMyStreet::App->model('DB::ContactsHistory')->search( - { body_id => 2650, category => [ 'test category', 'test/category' ] } + { body_id => $body->id, category => [ 'test category', 'test/category' ] } ); $history->delete_all; - $mech->get_ok('/admin/body/2650'); + $mech->get_ok('/admin/body/' . $body->id); $mech->submit_form_ok( { with_fields => { category => 'test category', @@ -201,12 +201,12 @@ subtest 'check contact creation' => sub { note => 'test/note', non_public => 'on', } } ); - $mech->get_ok('/admin/body_edit/2650/test/category'); + $mech->get_ok('/admin/body_edit/' . $body->id . '/test/category'); }; subtest 'check contact editing' => sub { - $mech->get_ok('/admin/body_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/' . $body->id .'/test%20category'); $mech->submit_form_ok( { with_fields => { email => 'test2@example.com', @@ -219,7 +219,7 @@ subtest 'check contact editing' => sub { $mech->content_contains( '<td>test2 note' ); $mech->content_contains( 'Private: No' ); - $mech->get_ok('/admin/body_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category'); $mech->submit_form_ok( { with_fields => { email => 'test2@example.com', note => 'test2 note', @@ -228,29 +228,29 @@ subtest 'check contact editing' => sub { $mech->content_contains( 'Private: Yes' ); - $mech->get_ok('/admin/body_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category'); $mech->content_contains( '<td><strong>test2@example.com' ); }; subtest 'check contact updating' => sub { - $mech->get_ok('/admin/body_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category'); $mech->content_like(qr{test2\@example.com</strong>[^<]*</td>[^<]*<td>No}s); - $mech->get_ok('/admin/body/2650'); + $mech->get_ok('/admin/body/' . $body->id); $mech->form_number( 1 ); $mech->tick( 'confirmed', 'test category' ); $mech->submit_form_ok({form_number => 1}); $mech->content_like(qr'test2@example.com</td>[^<]*<td>\s*Confirmed: Yes's); - $mech->get_ok('/admin/body_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category'); $mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>Yes}s); }; $body->update({ send_method => undef }); subtest 'check open311 configuring' => sub { - $mech->get_ok('/admin/body/2650'); + $mech->get_ok('/admin/body/' . $body->id); $mech->content_lacks('Council contacts configured via Open311'); $mech->form_number(3); @@ -268,7 +268,7 @@ subtest 'check open311 configuring' => sub { $mech->content_contains('Council contacts configured via Open311'); $mech->content_contains('Configuration updated - contacts will be generated automatically later'); - my $conf = FixMyStreet::App->model('DB::Body')->find( 2650 ); + my $conf = FixMyStreet::App->model('DB::Body')->find( $body->id ); is $conf->endpoint, 'http://example.com/open311', 'endpoint configured'; is $conf->api_key, 'api key', 'api key configured'; is $conf->jurisdiction, 'mySociety', 'jurisdiction configures'; @@ -288,14 +288,14 @@ subtest 'check open311 configuring' => sub { $mech->content_contains('Configuration updated'); - $conf = FixMyStreet::App->model('DB::Body')->find( 2650 ); + $conf = FixMyStreet::App->model('DB::Body')->find( $body->id ); is $conf->endpoint, 'http://example.org/open311', 'endpoint updated'; is $conf->api_key, 'new api key', 'api key updated'; is $conf->jurisdiction, 'open311', 'jurisdiction configures'; }; subtest 'check text output' => sub { - $mech->get_ok('/admin/body/2650?text=1'); + $mech->get_ok('/admin/body/' . $body->id . '?text=1'); is $mech->content_type, 'text/plain'; $mech->content_contains('test category'); }; @@ -851,7 +851,9 @@ for my $test ( }; } -$mech->create_body_ok(2504, 'Westminster City Council'); +my $westminster = $mech->create_body_ok(2504, 'Westminster City Council'); +$report->bodies_str($westminster->id); +$report->update; for my $test ( { @@ -871,8 +873,8 @@ for my $test ( update_fixed => 0, update_reopen => 0, update_state => undef, - user_body => 2504, - content => 'user is from same council as problem - 2504', + user_body => $westminster->id, + content => 'user is from same council as problem - ' . $westminster->id, }, { desc => 'update changed problem state', @@ -881,7 +883,7 @@ for my $test ( update_fixed => 0, update_reopen => 0, update_state => 'planned', - user_body => 2504, + user_body => $westminster->id, content => 'Update changed problem state to planned', }, { @@ -1096,7 +1098,7 @@ subtest 'show flagged entries' => sub { $mech->content_contains( $user->email ); }; -$mech->create_body_ok(2509, 'Haringey Borough Council'); +my $haringey = $mech->create_body_ok(2509, 'Haringey Borough Council'); subtest 'user search' => sub { $mech->get_ok('/admin/users'); @@ -1110,9 +1112,9 @@ subtest 'user search' => sub { $mech->content_like( qr{user_edit/$u_id">Edit</a>} ); - $user->from_body(2509); + $user->from_body($haringey->id); $user->update; - $mech->get_ok('/admin/users?search=2509' ); + $mech->get_ok('/admin/users?search=' . $haringey->id ); $mech->content_contains('Haringey'); }; @@ -1131,7 +1133,7 @@ is $log_entries->count, 0, 'no admin log entries'; $user->flagged( 0 ); $user->update; -$mech->create_body_ok(2607, 'Southend-on-Sea Borough Council'); +my $southend = $mech->create_body_ok(2607, 'Southend-on-Sea Borough Council'); for my $test ( { @@ -1139,7 +1141,7 @@ for my $test ( fields => { name => 'Test User', email => 'test@example.com', - body => 2509, + body => $haringey->id, flagged => undef, }, changes => { @@ -1153,7 +1155,7 @@ for my $test ( fields => { name => 'Changed User', email => 'test@example.com', - body => 2509, + body => $haringey->id, flagged => undef, }, changes => { @@ -1167,11 +1169,11 @@ for my $test ( fields => { name => 'Changed User', email => 'changed@example.com', - body => 2509, + body => $haringey->id, flagged => undef, }, changes => { - body => 2607, + body => $southend->id, }, log_count => 3, log_entries => [qw/edit edit edit/], @@ -1181,7 +1183,7 @@ for my $test ( fields => { name => 'Changed User', email => 'changed@example.com', - body => 2607, + body => $southend->id, flagged => undef, }, changes => { @@ -1195,7 +1197,7 @@ for my $test ( fields => { name => 'Changed User', email => 'changed@example.com', - body => 2607, + body => $southend->id, flagged => 'on', }, changes => { diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t index 6fab4d3e3..9189f5e97 100644 --- a/t/app/controller/alert.t +++ b/t/app/controller/alert.t @@ -15,6 +15,7 @@ $mech->content_contains('html class="no-js" lang="en-gb"'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], MAPIT_URL => 'http://mapit.mysociety.org/', + GEOCODER => '', }, sub { $mech->get_ok('/alert/list'); $mech->title_like(qr/^Local RSS feeds and email alerts/); diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 14cf32d7c..115bb181a 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -349,7 +349,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { }, { fields => { - feed => 'council:2651:City_of_Edinburgh', + feed => 'area:2651:City_of_Edinburgh', } }, ) { @@ -383,7 +383,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { my $report_time = '2011-03-01 12:00:00'; my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'EH1 1BB', - bodies_str => '2651', + bodies_str => '1', areas => ',11808,135007,14419,134935,2651,20728,', category => 'Street lighting', title => 'Testing', @@ -451,7 +451,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { my $count; for (@emails) { $count++ if $_->body =~ /The following updates have been left on this report:/; - $count++ if $_->body =~ /The following new FixMyStreet reports have been sent to City of\s+Edinburgh\s+Council:/; + $count++ if $_->body =~ /The following new FixMyStreet reports have been added in City of\s+Edinburgh\s+Council:/; $count++ if $_->body =~ /The following FixMyStreet reports have been made within the area you\s+specified:/; $count++ if $_->body =~ /\s+-\s+Testing/; } diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 892231ef1..df4f18660 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -54,8 +54,12 @@ foreach my $test ( { subtest "test bad pc value '$test->{pc}'" => sub { $mech->get_ok('/'); - $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } }, - "bad location" ); + FixMyStreet::override_config { + GEOCODER => '', + }, sub { + $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } }, + "bad location" ); + }; is_deeply $mech->page_errors, $test->{errors}, "expected errors for pc '$test->{pc}'"; is_deeply $mech->pc_alternatives, $test->{pc_alternatives}, diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 4e62028b5..3829873e5 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -13,7 +13,7 @@ my $test_pass = 'password'; my $test_council = 2651; my $test_ward = 20723; -$mech->create_body_ok($test_council, 'City of Edinburgh Council'); +my $body = $mech->create_body_ok($test_council, 'City of Edinburgh Council'); $mech->delete_user( $test_user ); my $user = FixMyStreet::App->model('DB::User')->create( { @@ -44,7 +44,7 @@ FixMyStreet::override_config { is $mech->status, '404', 'If not council user get 404'; - $user->from_body( $test_council ); + $user->from_body( $body->id ); $user->update; $mech->log_out_ok; @@ -55,7 +55,7 @@ FixMyStreet::override_config { $mech->content_contains( 'City of Edinburgh' ); - FixMyStreet::App->model('DB::Contact')->search( { body_id => $test_council } ) + FixMyStreet::App->model('DB::Contact')->search( { body_id => $body->id } ) ->delete; delete_problems(); @@ -64,7 +64,7 @@ FixMyStreet::override_config { for my $contact ( @cats ) { FixMyStreet::App->model('DB::Contact')->create( { - body_id => $test_council, + body_id => $body->id, category => $contact, email => "$contact\@example.org", confirmed => 1, @@ -638,7 +638,7 @@ sub make_problem { confirmed => $args->{conf_dt}, whensent => $args->{conf_dt}, lastupdate => $args->{mark_dt} || $args->{conf_dt}, - bodies_str => $test_council, + bodies_str => $body->id, postcode => 'EH99 1SP', latitude => '51', longitude => '1', @@ -692,10 +692,10 @@ sub check_report_counts { sub delete_problems { FixMyStreet::App->model('DB::Comment') - ->search( { 'problem.bodies_str' => $test_council }, { join => 'problem' } ) + ->search( { 'problem.bodies_str' => $body->id }, { join => 'problem' } ) ->delete; FixMyStreet::App->model('DB::Problem') - ->search( { bodies_str => $test_council } )->delete(); + ->search( { bodies_str => $body->id } )->delete(); } done_testing; diff --git a/t/app/controller/index.t b/t/app/controller/index.t index 308dd2c32..346ccb2e1 100644 --- a/t/app/controller/index.t +++ b/t/app/controller/index.t @@ -63,8 +63,6 @@ subtest "does pc, (x,y), (e,n) or (lat,lon) go to /around" => sub { } }; -$mech->delete_problems_for_body( 2651 ); - my $problem_rs = FixMyStreet::App->model('DB::Problem'); my $num = $problem_rs->count; @@ -82,4 +80,7 @@ ok $mech->get('/report/' . $edinburgh_problems[2]->id); is $mech->res->code, 403, 'page forbidden'; is $problem_rs->count, $num+5; -done_testing(); +END { + $mech->delete_problems_for_body( 2651 ); + done_testing(); +} diff --git a/t/app/controller/json.t b/t/app/controller/json.t index 405a84821..b2cea674f 100644 --- a/t/app/controller/json.t +++ b/t/app/controller/json.t @@ -49,7 +49,7 @@ my $body = $mech->create_body_ok(2501, 'Wandsworth Borough Council'); my $problem_args = { postcode => 'sw1a 1aa', - bodies_str => '2501', + bodies_str => $body->id, areas => ',105164,11806,11827,2247,2501,34817,42011,66045,70786,8519,', category => 'test category', title => 'Test title', diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t index 82e178f9b..84e8670b7 100644 --- a/t/app/controller/moderate.t +++ b/t/app/controller/moderate.t @@ -24,7 +24,7 @@ sub create_report { FixMyStreet::App->model('DB::Problem')->create( { postcode => 'BR1 3SB', - bodies_str => $BROMLEY_ID, + bodies_str => $body->id, areas => ",$BROMLEY_ID,", category => 'Other', title => 'Good bad good', @@ -64,7 +64,7 @@ subtest 'Auth' => sub { $mech->get_ok($REPORT_URL); $mech->content_lacks('Moderat'); - $user->update({ from_body => $BROMLEY_ID }); + $user->update({ from_body => $body->id }); $mech->get_ok($REPORT_URL); $mech->content_lacks('Moderat'); diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 07e8caa9b..002cdc1e5 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -470,33 +470,33 @@ subtest "Zurich banners are displayed correctly" => sub { }; }; -$mech->create_body_ok(2504, 'Westminster City Council'); -$mech->create_body_ok(2505, 'Camden Borough Council'); +my $body_westminster = $mech->create_body_ok(2504, 'Westminster City Council'); +my $body_camden = $mech->create_body_ok(2505, 'Camden Borough Council'); for my $test ( { desc => 'no state dropdown if user not from authority', from_body => undef, no_state => 1, - report_body => '2504', + report_body => $body_westminster->id, }, { desc => 'state dropdown if user from authority', - from_body => 2504, + from_body => $body_westminster->id, no_state => 0, - report_body => '2504', + report_body => $body_westminster->id, }, { desc => 'no state dropdown if user not from same body as problem', - from_body => 2505, + from_body => $body_camden->id, no_state => 1, - report_body => '2504', + report_body => $body_westminster->id, }, { desc => 'state dropdown if user from authority and problem sent to multiple bodies', - from_body => 2504, + from_body => $body_westminster->id, no_state => 0, - report_body => '2504,2506', + report_body => $body_westminster->id . ',2506', }, ) { subtest $test->{desc} => sub { @@ -518,10 +518,7 @@ for my $test ( }; } -$report->discard_changes; -$report->bodies_str( 2504 ); -$report->update; - -# tidy up -$mech->delete_user('test@example.com'); -done_testing(); +END { + $mech->delete_user('test@example.com'); + done_testing(); +} diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t index 4dcc7e939..e5e9e2899 100644 --- a/t/app/controller/report_import.t +++ b/t/app/controller/report_import.t @@ -17,6 +17,8 @@ ok -e $sample_file, "sample file $sample_file exists"; FixMyStreet::App->log->disable('info'); END { FixMyStreet::App->log->enable('info'); } +$mech->create_body_ok(2504, 'Westminster City Council'); + # submit an empty report to import - check we get all errors subtest "Test creating bad partial entries" => sub { @@ -121,7 +123,7 @@ subtest "Submit a correct entry" => sub { "check only pc field is shown"; FixMyStreet::override_config { - ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], + ALLOWED_COBRANDS => [ 'fixmystreet' ], MAPIT_URL => 'http://mapit.mysociety.org/', }, sub { $mech->submit_form_ok( diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t index 9ca05e81b..506b50edd 100644 --- a/t/app/controller/report_interest_count.t +++ b/t/app/controller/report_interest_count.t @@ -54,7 +54,7 @@ ok $report, "created test report - $report_id"; FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'fixmybarangay' ], }, sub { - $mech->create_body_ok(2504, 'Westminster City Council'); + my $body = $mech->create_body_ok(2504, 'Westminster City Council'); for my $test ( { @@ -64,13 +64,13 @@ FixMyStreet::override_config { }, { desc => 'from body user can increment supported count', - from_body => 2504, + from_body => $body->id, support_string => 'No supporters', updated_support => '1 supporter' }, { desc => 'correct grammar for more than one supporter', - from_body => 2504, + from_body => $body->id, support_string => '1 supporter', updated_support => '2 supporters' }, @@ -129,10 +129,7 @@ subtest 'check support details not shown if not enabled in cobrand' => sub { $mech->content_lacks( '1 supporter' ); }; -$report->discard_changes; -$report->bodies_str( 2504 ); -$report->update; - -# tidy up -$mech->delete_user('test@example.com'); -done_testing(); +END { + $mech->delete_user('test@example.com'); + done_testing(); +} diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 44e075f1e..67e899102 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -43,16 +43,20 @@ my %contact_params = ( note => 'Created for test', ); +my %body_ids; for my $body ( - { id => 2651, name => 'City of Edinburgh Council' }, - { id => 2226, name => 'Gloucestershire County Council' }, - { id => 2326, name => 'Cheltenham Borough Council' }, - { id => 2482, name => 'Bromley Council' }, - { id => 2227, name => 'Hampshire County Council' }, - { id => 2333, name => 'Hart Council' }, - { id => 2504, name => 'Westminster City Council' }, + { area_id => 2651, name => 'City of Edinburgh Council' }, + { 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 }, ) { - $mech->create_body_ok($body->{id}, $body->{name}); + my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name}, id => $body->{id}); + $body_ids{$body->{area_id}} = $body_obj->id; } # Let's make some contacts to send things to! @@ -61,43 +65,43 @@ FixMyStreet::App->model('DB::Contact')->search( { } )->delete; my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2651, # Edinburgh + body_id => $body_ids{2651}, # Edinburgh category => 'Street lighting', email => 'highways@example.com', } ); my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2226, # Gloucestershire + body_id => $body_ids{2226}, # Gloucestershire category => 'Potholes', email => 'potholes@example.com', } ); my $contact3 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2326, # Cheltenham + body_id => $body_ids{2326}, # Cheltenham category => 'Trees', email => 'trees@example.com', } ); my $contact4 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2482, # Bromley + body_id => $body_ids{2482}, # Bromley category => 'Trees', email => 'trees@example.com', } ); my $contact5 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2651, # Edinburgh + body_id => $body_ids{2651}, # Edinburgh category => 'Trees', email => 'trees@example.com', } ); my $contact6 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2333, # Hart + body_id => $body_ids{2333}, # Hart category => 'Trees', email => 'trees@example.com', } ); my $contact7 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2227, # Hampshire + body_id => $body_ids{2227}, # Hampshire category => 'Street lighting', email => 'highways@example.com', } ); @@ -586,7 +590,7 @@ foreach my $test ( is $mech->get( '/report/' . $report->id )->code, 404, "report not found"; # Check the report has been assigned appropriately - is $report->bodies_str, 2651; + is $report->bodies_str, $body_ids{2651}; # receive token my $email = $mech->get_email; @@ -750,7 +754,7 @@ subtest "test report creation for a user who is signing in as they report" => su is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; # Check the report has been assigned appropriately - is $report->bodies_str, 2651; + is $report->bodies_str, $body_ids{2651}; # check that no emails have been sent $mech->email_count_is(0); @@ -846,7 +850,7 @@ foreach my $test ( ok $report, "Found the report"; # Check the report has been assigned appropriately - is $report->bodies_str, $test->{council}; + is $report->bodies_str, $body_ids{$test->{council}}; # check that we got redirected to /report/ is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; @@ -1289,7 +1293,7 @@ subtest "test Hart" => sub { ok $report, "Found the report"; # Check the report has been assigned appropriately - is $report->bodies_str, $test->{council}; + is $report->bodies_str, $body_ids{$test->{council}}; if ( $test->{redirect} ) { is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; @@ -1353,10 +1357,10 @@ subtest "test SeeSomething" => sub { my $cobrand = FixMyStreet::Cobrand::SeeSomething->new(); - $mech->create_body_ok(2535, 'Sandwell Borough Council'); + my $body_ss = $mech->create_body_ok(2535, 'Sandwell Borough Council', id => 2535); my $bus_contact = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2535, + body_id => $body_ss->id, category => 'Bus', email => 'bus@example.com', non_public => 1, diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index 4745d92cd..a274d918b 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -29,7 +29,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, - body_id => 2651, # Edinburgh + body_id => $body->id, # Edinburgh category => 'Street lighting', email => '100', extra => [ { description => 'Lamppost number', code => 'number', required => 'True' }, @@ -40,7 +40,7 @@ my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( { } ); my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( { %contact_params, - body_id => 2651, # Edinburgh + body_id => $body->id, # Edinburgh category => 'Graffiti Removal', email => '101', } ); diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 99c53ef01..64ed91ac0 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -23,6 +23,8 @@ my $user2 = ->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } ); ok $user2, "created comment user"; +my $body = $mech->create_body_ok(2504, 'Westminster City Council'); + my $dt = DateTime->new( year => 2011, month => 04, @@ -35,7 +37,7 @@ my $dt = DateTime->new( my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', - bodies_str => '2504', + bodies_str => $body->id, areas => ',105255,11806,11828,2247,2504,', category => 'Other', title => 'Test 2', @@ -513,12 +515,10 @@ subtest 'check non authority user cannot change set state' => sub { is $report->state, 'confirmed', 'state unchanged'; }; -$mech->create_body_ok(2504, 'Westminster City Council'); - for my $state ( qw/unconfirmed hidden partial/ ) { subtest "check that update cannot set state to $state" => sub { $mech->log_in_ok( $user->email ); - $user->from_body( 2504 ); + $user->from_body( $body->id ); $user->update; $mech->get_ok("/report/$report_id"); @@ -668,7 +668,7 @@ for my $test ( state => 'fixed', }, state => 'fixed - council', - report_bodies => '2504,2505', + report_bodies => $body->id . ',2505', }, ) { subtest $test->{desc} => sub { @@ -679,7 +679,7 @@ for my $test ( } $mech->log_in_ok( $user->email ); - $user->from_body( 2504 ); + $user->from_body( $body->id ); $user->update; $mech->get_ok("/report/$report_id"); @@ -798,7 +798,7 @@ subtest "check comment with no status change has not status in meta" => sub { my $update_meta = $mech->extract_update_metas; unlike $update_meta->[1], qr/marked as/, 'update meta does not include state change'; - $user->from_body( 2504 ); + $user->from_body( $body->id ); $user->update; $mech->get_ok("/report/$report_id"); @@ -905,7 +905,7 @@ $user->from_body(undef); $user->update; $report->state('confirmed'); -$report->bodies_str('2504'); +$report->bodies_str($body->id); $report->update; for my $test ( diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 36af2f36a..1b4fc3526 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -9,17 +9,17 @@ use DateTime; ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); $mech->create_body_ok(2514, 'Birmingham City Council'); -$mech->create_body_ok(2651, 'City of Edinburgh Council'); -$mech->create_body_ok(2504, 'Westminster City Council'); -$mech->create_body_ok(2649, 'Fife Council'); +my $body_edin_id = $mech->create_body_ok(2651, 'City of Edinburgh Council')->id; +my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id; +my $body_fife_id = $mech->create_body_ok(2649, 'Fife Council')->id; -$mech->delete_problems_for_body( 2504 ); -$mech->delete_problems_for_body( 2651 ); -$mech->delete_problems_for_body( 2649 ); +$mech->delete_problems_for_body( $body_west_id ); +$mech->delete_problems_for_body( $body_edin_id ); +$mech->delete_problems_for_body( $body_fife_id ); -my @edinburgh_problems = $mech->create_problems_for_body(3, 2651, 'All reports'); -my @westminster_problems = $mech->create_problems_for_body(5, 2504, 'All reports'); -my @fife_problems = $mech->create_problems_for_body(15, 2649, 'All reports'); +my @edinburgh_problems = $mech->create_problems_for_body(3, $body_edin_id, 'All reports'); +my @westminster_problems = $mech->create_problems_for_body(5, $body_west_id, 'All reports'); +my @fife_problems = $mech->create_problems_for_body(15, $body_fife_id, 'All reports'); is scalar @westminster_problems, 5, 'correct number of westminster problems created'; is scalar @edinburgh_problems, 3, 'correct number of edinburgh problems created'; @@ -114,7 +114,7 @@ FixMyStreet::override_config { $mech->title_like(qr/Westminster City Council/); $mech->content_contains('Westminster City Council'); -$mech->content_contains('All reports Test 3 for 2504', 'problem to be marked non public visible'); +$mech->content_contains('All reports Test 3 for ' . $body_west_id, 'problem to be marked non public visible'); my $problems = $mech->extract_problem_list; is scalar @$problems, 5, 'correct number of problems displayed'; @@ -185,7 +185,7 @@ FixMyStreet::override_config { $problems = $mech->extract_problem_list; is scalar @$problems, 4, 'only public problems are displayed'; -$mech->content_lacks('All reports Test 3 for 2504', 'non public problem is not visible'); +$mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible'); $mech->get_ok('/reports'); $stats = $mech->extract_report_stats; |