diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-13 18:53:25 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-15 00:11:06 +0000 |
commit | f05dc118efd45e0df7f3e8d04366f732440f4fd6 (patch) | |
tree | ecac77e56cb7c9d5b9c59ae7bfd6392123d9b279 /t/app | |
parent | 9fb130a0ab1bd36e977439b7697fba5fec5b1f00 (diff) |
Update tests for new names of things and bodies needing to exist.
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/dashboard.t | 8 | ||||
-rw-r--r-- | t/app/controller/json.t | 6 | ||||
-rw-r--r-- | t/app/controller/report_display.t | 16 | ||||
-rw-r--r-- | t/app/controller/report_interest_count.t | 8 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 12 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 2 | ||||
-rw-r--r-- | t/app/controller/rss.t | 2 | ||||
-rw-r--r-- | t/app/model/alert_type.t | 8 | ||||
-rw-r--r-- | t/app/model/problem.t | 60 | ||||
-rw-r--r-- | t/app/sendreport/email.t | 10 |
10 files changed, 83 insertions, 49 deletions
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 307943abd..5a8465edc 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -12,6 +12,8 @@ my $test_pass = 'password'; my $test_council = 2651; my $test_ward = 20723; +$mech->create_body_ok($test_council, 'City of Edinburgh Council'); + $mech->delete_user( $test_user ); my $user = FixMyStreet::App->model('DB::User')->create( { email => $test_user, @@ -578,7 +580,7 @@ sub make_problem { confirmed => $args->{conf_dt}, whensent => $args->{conf_dt}, lastupdate => $args->{mark_dt} || $args->{conf_dt}, - council => $test_council, + bodies_str => $test_council, postcode => 'EH99 1SP', latitude => '51', longitude => '1', @@ -632,10 +634,10 @@ sub check_report_counts { sub delete_problems { FixMyStreet::App->model('DB::Comment') - ->search( { 'problem.council' => $test_council }, { join => 'problem' } ) + ->search( { 'problem.bodies_str' => $test_council }, { join => 'problem' } ) ->delete; FixMyStreet::App->model('DB::Problem') - ->search( { council => $test_council } )->delete(); + ->search( { bodies_str => $test_council } )->delete(); } done_testing; diff --git a/t/app/controller/json.t b/t/app/controller/json.t index e8f9c0e09..405a84821 100644 --- a/t/app/controller/json.t +++ b/t/app/controller/json.t @@ -45,6 +45,8 @@ is_deeply # # put an entry in the database for this test my $user = $mech->create_user_ok('test@example.com'); +my $body = $mech->create_body_ok(2501, 'Wandsworth Borough Council'); + my $problem_args = { postcode => 'sw1a 1aa', bodies_str => '2501', @@ -86,7 +88,7 @@ is_deeply # 'category' => 'test category', 'confirmed' => '2000-01-01 12:01:00', 'lastupdate' => '2000-01-01 12:00:00', - 'council' => 'Wandsworth Borough Council', + 'bodies_str' => 'Wandsworth Borough Council', 'detail' => 'Test detail', 'id' => $problem->id, 'name' => 'Test Name', @@ -103,7 +105,7 @@ is_deeply # 'category' => 'test category', 'confirmed' => '2000-01-01 12:02:00', 'lastupdate' => '2000-01-01 12:00:00', - 'council' => 'Wandsworth Borough Council', + 'bodies_str' => 'Wandsworth Borough Council', 'detail' => 'Test detail', 'id' => $anon_problem->id, 'name' => '', diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index b20fe4077..4c7b33f73 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -33,7 +33,7 @@ my $dt = DateTime->new( my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', - council => '2504', + bodies_str => '2504', areas => ',105255,11806,11828,2247,2504,', category => 'Other', title => 'Test 2', @@ -350,25 +350,25 @@ for my $test ( desc => 'no state dropdown if user not from authority', from_body => 0, no_state => 1, - report_council => '2504', + report_body => '2504', }, { desc => 'state dropdown if user from authority', from_body => 2504, no_state => 0, - report_council => '2504', + report_body => '2504', }, { - desc => 'no state dropdown if user not from same council as problem', + desc => 'no state dropdown if user not from same body as problem', from_body => 2505, no_state => 1, - report_council => '2504', + report_body => '2504', }, { - desc => 'state dropdown if user from authority and problem sent to multiple councils', + desc => 'state dropdown if user from authority and problem sent to multiple bodies', from_body => 2504, no_state => 0, - report_council => '2504,2506', + report_body => '2504,2506', }, ) { subtest $test->{desc} => sub { @@ -377,7 +377,7 @@ for my $test ( $user->update; $report->discard_changes; - $report->bodies_str( $test->{report_council} ); + $report->bodies_str( $test->{report_body} ); $report->update; $mech->get_ok("/report/$report_id"); diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t index 788d2c473..d0e0054c4 100644 --- a/t/app/controller/report_interest_count.t +++ b/t/app/controller/report_interest_count.t @@ -33,7 +33,7 @@ my $dt = DateTime->new( my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', - council => '2504', + bodies_str => '2504', areas => ',105255,11806,11828,2247,2504,', category => 'Other', title => 'Test 2', @@ -61,12 +61,12 @@ SKIP: { unless FixMyStreet::Cobrand->exists('fixmybarangay'); for my $test ( { - desc => 'if not from council then no supporter button', + desc => 'if not from body then no supporter button', from_body => 0, support_string => 'No supporters', }, { - desc => 'from council user can increment supported count', + desc => 'from body user can increment supported count', from_body => 2504, support_string => 'No supporters', updated_support => '1 supporter' @@ -104,7 +104,7 @@ SKIP: { }; } - subtest 'check non council user cannot increment support count' => sub { + subtest 'check non body user cannot increment support count' => sub { ok $mech->host('fixmybarangay.com'), 'changed to fixmybarangay'; $report->discard_changes; $report->interest_count(1); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 323abfa18..f6a7b0824 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -33,6 +33,18 @@ my %contact_params = ( whenedited => \'current_timestamp', note => 'Created for test', ); + +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 => 2240, name => 'Staffordshire County Council' }, + { id => 2434, name => 'Lichfield District Council' }, +) { + $mech->create_body_ok($body->{id}, $body->{name}); +} + # Let's make some contacts to send things to! FixMyStreet::App->model('DB::Contact')->search( { email => { 'like', '%example.com' }, diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 2d49d3eef..fe1c27199 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -35,7 +35,7 @@ my $dt = DateTime->new( my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', - council => '2504', + bodies_str => '2504', areas => ',105255,11806,11828,2247,2504,', category => 'Other', title => 'Test 2', diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t index 77e2c7ee1..e683806cd 100644 --- a/t/app/controller/rss.t +++ b/t/app/controller/rss.t @@ -17,7 +17,7 @@ my $user1 = FixMyStreet::App->model('DB::User') my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'eh1 1BB', - council => '2651', + bodies_str => '2651', areas => ',11808,135007,14419,134935,2651,20728,', category => 'Street lighting', title => 'Testing', diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t index c592e9d3f..ba48300b2 100644 --- a/t/app/model/alert_type.t +++ b/t/app/model/alert_type.t @@ -39,7 +39,7 @@ my $dt = DateTime->new( my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', - council => '2504', + bodies_str => '2504', areas => ',105255,11806,11828,2247,2504,', category => 'Other', title => 'Test 2', @@ -345,7 +345,7 @@ my $ward_alert = FixMyStreet::App->model('DB::Alert')->find_or_create( my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'WS13 6YY', - council => '2434', + bodies_str => '2434', areas => ',105255,11806,11828,2247,2504,7117,', category => 'Other', title => 'council report', @@ -369,7 +369,7 @@ my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create( my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'WS13 6YY', - council => '2240', + bodies_str => '2240', areas => ',105255,11806,11828,2247,2504,7117,', category => 'Other', title => 'county report', @@ -393,7 +393,7 @@ my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_c my $report_outside_district = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'WS13 6YY', - council => '2221', + bodies_str => '2221', areas => ',105255,11806,11828,2247,2504,7117,', category => 'Other', title => 'outside district report', diff --git a/t/app/model/problem.t b/t/app/model/problem.t index baec6baf0..ec82a3a4e 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -44,7 +44,7 @@ for my $test ( errors => { title => 'Please enter a subject', detail => 'Please enter some details', - council => 'No council selected', + bodies => 'No council selected', name => 'Please enter your name', } }, @@ -56,7 +56,7 @@ for my $test ( errors => { title => 'Please enter a subject', detail => 'Please enter some details', - council => 'No council selected', + bodies => 'No council selected', name => 'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below', } }, @@ -68,7 +68,7 @@ for my $test ( errors => { title => 'Please enter a subject', detail => 'Please enter some details', - council => 'No council selected', + bodies => 'No council selected', name => 'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below', } }, @@ -80,7 +80,7 @@ for my $test ( errors => { title => 'Please enter a subject', detail => 'Please enter some details', - council => 'No council selected', + bodies => 'No council selected', } }, { @@ -90,7 +90,7 @@ for my $test ( }, errors => { detail => 'Please enter some details', - council => 'No council selected', + bodies => 'No council selected', } }, { @@ -99,22 +99,22 @@ for my $test ( detail => 'Some information about the problem', }, errors => { - council => 'No council selected', + bodies => 'No council selected', } }, { - desc => 'incorrectly formatted council', + desc => 'incorrectly formatted body', changed => { - council => 'my council', + bodies_str => 'my body', }, errors => { - council => 'No council selected', + bodies => 'No council selected', } }, { - desc => 'correctly formatted council', + desc => 'correctly formatted body', changed => { - council => '1001', + bodies_str => '1001', }, errors => { } @@ -355,6 +355,20 @@ my %contact_params = ( whenedited => \'ms_current_timestamp()', note => 'Created for test', ); + +for my $body ( + { id => 2651, area_id => 2651, name => 'City of Edinburgh Council' }, + { id => 2226, area_id => 2226, name => 'Gloucestershire County Council' }, + { id => 2326, area_id => 2326, name => 'Cheltenham Borough Council' }, + { id => 2434, area_id => 2434, name => 'Lichfield District Council' }, + { id => 2240, area_id => 2240, name => 'Staffordshire County Council' }, + { id => 14279, area_id => 14279, name => 'Ballymoney Borough Council' }, + { id => 2636, area_id => 2636, name => 'Isle of Wight Council' }, + { id => 2649, area_id => 2649, name => 'Fife Council' }, +) { + $mech->create_body_ok($body->{id}, $body->{name}); +} + # Let's make some contacts to send things to! FixMyStreet::App->model('DB::Contact')->search( { email => { 'like', '%example.com' }, @@ -410,13 +424,13 @@ foreach my $test ( { email_count => 1, dear => qr'Dear City of Edinburgh Council', to => qr'City of Edinburgh Council', - council => 2651, + body => 2651, }, { %common, desc => 'no email sent if no unsent problems', unset_whendef => 0, email_count => 0, - council => 2651, + body => 2651, }, { %common, desc => 'email to two tier council', @@ -424,7 +438,7 @@ foreach my $test ( { email_count => 1, to => qr'Gloucestershire County Council.*Cheltenham Borough Council', dear => qr'Dear Gloucestershire County Council and Cheltenham Borough', - council => '2226,2326', + body => '2226,2326', multiple => 1, }, { %common, @@ -433,7 +447,7 @@ foreach my $test ( { email_count => 1, to => qr'Gloucestershire County Council" <2226@example', dear => qr'Dear Gloucestershire County Council,', - council => '2226|2649', + body => '2226|2649', missing => qr'problem might be the responsibility of Fife.*Council'ms, }, { %common, @@ -442,7 +456,7 @@ foreach my $test ( { email_count => 1, to => qr'Lichfield District Council', dear => qr'Dear Lichfield District Council,', - council => '2434', + body => '2434', cobrand => 'lichfielddc', url => 'lichfielddc.', }, { @@ -452,7 +466,7 @@ foreach my $test ( { email_count => 1, to => qr'Staffordshire County Council" <highways@example', dear => qr'Dear Staffordshire County Council,', - council => '2240', + body => '2240', cobrand => 'lichfielddc', url => '', }, { @@ -462,7 +476,7 @@ foreach my $test ( { email_count => 1, dear => qr'Dear Ballymoney Borough Council', to => qr'Ballymoney Borough Council', - council => 14279, + body => 14279, category => 'Graffiti', }, { %common, @@ -471,7 +485,7 @@ foreach my $test ( { email_count => 1, dear => qr'Dear Roads Service \(Western\)', to => qr'Roads Service \(Western\)" <roads', - council => 14279, + body => 14279, category => 'Street lighting', }, { %common, @@ -479,7 +493,7 @@ foreach my $test ( { unset_whendef => 1, stays_unsent => 1, email_count => 0, - council => 2636, + body => 2636, }, ) { subtest $test->{ desc } => sub { @@ -497,7 +511,7 @@ foreach my $test ( { $problem->discard_changes; $problem->update( { - council => $test->{ council }, + bodies_str => $test->{ body }, state => 'confirmed', confirmed => \'ms_current_timestamp()', whensent => $test->{ unset_whendef } ? undef : \'ms_current_timestamp()', @@ -519,9 +533,9 @@ foreach my $test ( { like $email->body, $test->{ dear }, 'Salutation looks correct'; if ( $test->{multiple} ) { - like $email->body, qr/This email has been sent to several councils /, 'multiple council text correct'; + like $email->body, qr/This email has been sent to several councils /, 'multiple body text correct'; } elsif ( $test->{ missing } ) { - like $email->body, $test->{ missing }, 'missing council information correct'; + like $email->body, $test->{ missing }, 'missing body information correct'; } if ( $test->{url} ) { diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t index 04b3854cc..17abd6243 100644 --- a/t/app/sendreport/email.t +++ b/t/app/sendreport/email.t @@ -14,6 +14,10 @@ use mySociety::Locale; my $e = FixMyStreet::SendReport::Email->new(); +my $params = { id => 1000, area_id => 1000, name => 'Council of the Thousand' }; +my $body = FixMyStreet::App->model('DB::Body')->find_or_create($params); +ok $body, "found/created body"; + my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( email => 'council@example.com', body_id => 1000, @@ -26,7 +30,7 @@ my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create( ); my $row = FixMyStreet::App->model('DB::Problem')->new( { - council => '1000', + bodies_str => '1000', category => 'category', } ); @@ -47,7 +51,7 @@ foreach my $test ( { count => undef, add_council => 1, unconfirmed => 1, - expected_note => 'Council 1000 deleted', + expected_note => 'Body 1000 deleted', }, { desc => 'unconfirmed contact note uses note from contact table', @@ -62,7 +66,7 @@ foreach my $test ( { my $e = FixMyStreet::SendReport::Email->new; $contact->update( { confirmed => 0 } ) if $test->{unconfirmed}; $contact->update( { note => $test->{note} } ) if $test->{note}; - $e->add_council( 1000, { name => 'test council' } ) if $test->{add_council}; + $e->add_body( $body ) if $test->{add_council}; is $e->build_recipient_list( $row, {} ), $test->{count}, 'correct recipient list count'; if ( $test->{unconfirmed} ) { |