From becb211aac950c1557d634bd0b5aba402081d483 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 28 Nov 2011 17:17:58 +0000 Subject: add in postcode to email alert titles --- t/app/controller/alert_new.t | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 't/app/controller') diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 580a5ad9a..8231b1996 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -452,8 +452,9 @@ subtest "Test normal alert signups and that alerts are sent" => sub { $count++ if $_->body =~ /The following updates have been left on this problem:/; $count++ if $_->body =~ /The following new problems have been reported to City of\s*Edinburgh Council:/; $count++ if $_->body =~ /The following nearby problems have been added:/; + $count++ if $_->body =~ / - Testing, EH1 1BB/; } - is $count, 3, 'Three emails with the right things in them'; + is $count, 5, 'Three emails with the right things in them'; my $email = $emails[0]; like $email->body, qr/Other User/, 'Update name given'; -- cgit v1.2.3 From 7b84603eba13109bee0d39b2bb48d6e55371f8ec Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 28 Nov 2011 17:35:43 +0000 Subject: include nearest road data in rss feed if available, plus tests --- t/app/controller/rss.t | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 t/app/controller/rss.t (limited to 't/app/controller') diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t new file mode 100644 index 000000000..39a7db5bc --- /dev/null +++ b/t/app/controller/rss.t @@ -0,0 +1,118 @@ +use strict; +use warnings; +use Test::More; + +use FixMyStreet::TestMech; + +my $mech = FixMyStreet::TestMech->new; + +my $dt = DateTime->new( + year => 2011, + month => 10, + day => 10 +); + +my $user1 = FixMyStreet::App->model('DB::User') + ->find_or_create( { email => 'reporter@example.com', name => 'Reporter User' } ); + +my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { + postcode => 'EH1 1BB', + council => '2651', + areas => ',11808,135007,14419,134935,2651,20728,', + category => 'Street lighting', + title => 'Testing', + detail => 'Testing Detail', + used_map => 1, + name => $user1->name, + anonymous => 0, + state => 'confirmed', + confirmed => $dt, + lastupdate => $dt, + whensent => $dt->clone->add( minutes => 5 ), + lang => 'en-gb', + service => '', + cobrand => 'default', + cobrand_data => '', + send_questionnaire => 1, + latitude => '55.951963', + longitude => '-3.189944', + user_id => $user1->id, +} ); + + +$mech->get_ok("/rss/pc/EH11BB/2"); +$mech->content_contains( "Testing, 10th October, EH1 1BB" ); +$mech->content_lacks( 'Nearest road to the pin' ); + +$report->geocode( +{ + 'traceId' => 'ae7c4880b70b423ebc8ab4d80961b3e9|LTSM001158|02.00.71.1600|LTSMSNVM002010, LTSMSNVM001477', + 'statusDescription' => 'OK', + 'brandLogoUri' => 'http://dev.virtualearth.net/Branding/logo_powered_by.png', + 'resourceSets' => [ + { + 'resources' => [ + { + 'geocodePoints' => [ + { + 'calculationMethod' => 'Interpolation', + 'coordinates' => [ + '55.9532357007265', + '-3.18906001746655' + ], + 'usageTypes' => [ + 'Display', + 'Route' + ], + 'type' => 'Point' + } + ], + 'entityType' => 'Address', + 'name' => '18 N Bridge, Edinburgh EH1 1', + 'point' => { + 'coordinates' => [ + '55.9532357007265', + '-3.18906001746655' + ], + 'type' => 'Point' + }, + 'bbox' => [ + '55.9493729831558', + '-3.19825819222605', + '55.9570984182972', + '-3.17986184270704' + ], + 'matchCodes' => [ + 'Good' + ], + 'address' => { + 'countryRegion' => 'United Kingdom', + 'adminDistrict2' => 'Edinburgh City', + 'adminDistrict' => 'Scotland', + 'addressLine' => '18 North Bridge', + 'formattedAddress' => '18 N Bridge, Edinburgh EH1 1', + 'postalCode' => 'EH1 1', + 'locality' => 'Edinburgh' + }, + 'confidence' => 'Medium', + '__type' => 'Location:http://schemas.microsoft.com/search/local/ws/rest/v1' + } + ], + 'estimatedTotal' => 1 + } + ], + 'copyright' => "Copyright \x{a9} 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.", + 'statusCode' => 200, + 'authenticationResultCode' => 'ValidCredentials' + } +); +$report->update(); + +$mech->get_ok("/rss/pc/EH11BB/2"); +$mech->content_contains( "Testing, 10th October, EH1 1BB" ); +$mech->content_contains( '18 North Bridge, Edinburgh' ); + +$report->delete(); +$user1->delete(); + +done_testing(); -- cgit v1.2.3 From d4fbdc003253456acade79af4b5e1fcdae34ce02 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 29 Nov 2011 15:35:19 +0000 Subject: canonicalise postcode for display in RSS titles --- t/app/controller/rss.t | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 't/app/controller') diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t index 39a7db5bc..a820a9586 100644 --- a/t/app/controller/rss.t +++ b/t/app/controller/rss.t @@ -16,7 +16,7 @@ my $user1 = FixMyStreet::App->model('DB::User') ->find_or_create( { email => 'reporter@example.com', name => 'Reporter User' } ); my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { - postcode => 'EH1 1BB', + postcode => 'eh1 1BB', council => '2651', areas => ',11808,135007,14419,134935,2651,20728,', category => 'Street lighting', @@ -106,6 +106,7 @@ $report->geocode( 'authenticationResultCode' => 'ValidCredentials' } ); +$report->postcode('eh11bb'); $report->update(); $mech->get_ok("/rss/pc/EH11BB/2"); -- cgit v1.2.3 From 2b39d9ad6e308880958d83c0e011bc3d627ad191 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 29 Nov 2011 15:43:21 +0000 Subject: sanity check that non postcodes come through --- t/app/controller/rss.t | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't/app/controller') diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t index a820a9586..c6ab20574 100644 --- a/t/app/controller/rss.t +++ b/t/app/controller/rss.t @@ -113,6 +113,12 @@ $mech->get_ok("/rss/pc/EH11BB/2"); $mech->content_contains( "Testing, 10th October, EH1 1BB" ); $mech->content_contains( '18 North Bridge, Edinburgh' ); +$report->postcode('Princes St, Edinburgh'); +$report->update(); + +$mech->get_ok("/rss/pc/EH11BB/2"); +$mech->content_contains( "Testing, 10th October, Princes St, Edinburgh" ); + $report->delete(); $user1->delete(); -- cgit v1.2.3 From 7137be3b574611d526b047798013d9c785ef4242 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 29 Nov 2011 18:04:15 +0000 Subject: make the test and description match --- t/app/controller/alert_new.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/app/controller') diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 8231b1996..950666d2d 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -454,7 +454,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { $count++ if $_->body =~ /The following nearby problems have been added:/; $count++ if $_->body =~ / - Testing, EH1 1BB/; } - is $count, 5, 'Three emails with the right things in them'; + is $count, 5, 'Five emails with the right things in them'; my $email = $emails[0]; like $email->body, qr/Other User/, 'Update name given'; -- cgit v1.2.3 From 218df95e31b42374dc390f8e8abe9c49ef62c2b6 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 6 Jan 2012 10:26:47 +0000 Subject: fix date format for dates that are now from a previous year --- t/app/controller/contact.t | 6 +++--- t/app/controller/report_display.t | 18 +++++++++--------- t/app/controller/report_updates.t | 16 ++++++++-------- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 't/app/controller') diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index 86b845eb3..970241d12 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -21,7 +21,7 @@ for my $test ( postcode => 'EH99 1SP', confirmed => '2011-05-04 10:44:28.145168', anonymous => 0, - meta => 'Reported by A User at 10:44, Wednesday 4 May 2011', + meta => 'Reported by A User at 10:44, Wed 4 May 2011', main => 1, }, { @@ -32,7 +32,7 @@ for my $test ( postcode => 'EH99 1SP', confirmed => '2011-05-03 13:24:28.145168', anonymous => 1, - meta => 'Reported anonymously at 13:24, Tuesday 3 May 2011', + meta => 'Reported anonymously at 13:24, Tue 3 May 2011', }, { name => 'A User', @@ -42,7 +42,7 @@ for my $test ( postcode => 'EH99 1SP', confirmed => '2011-05-03 13:24:28.145168', anonymous => 1, - meta => 'Reported anonymously at 13:24, Tuesday 3 May 2011', + meta => 'Reported anonymously at 13:24, Tue 3 May 2011', update => { name => 'Different User', email => 'commenter@example.com', diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index c7455a99b..548580fe1 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -103,7 +103,7 @@ subtest "test a good report" => sub { is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; is $mech->extract_problem_title, 'Test 2', 'problem title'; is $mech->extract_problem_meta, - 'Reported by Test User at 15:47, Saturday 16 April 2011', + 'Reported by Test User at 15:47, Sat 16 April 2011', 'correct problem meta information'; $mech->content_contains('Test 2 Detail'); @@ -124,55 +124,55 @@ foreach my $meta ( anonymous => 'f', category => 'Other', service => '', - meta => 'Reported by Test User at 15:47, Saturday 16 April 2011' + meta => 'Reported by Test User at 15:47, Sat 16 April 2011' }, { anonymous => 'f', category => 'Roads', service => '', meta => -'Reported in the Roads category by Test User at 15:47, Saturday 16 April 2011' +'Reported in the Roads category by Test User at 15:47, Sat 16 April 2011' }, { anonymous => 'f', category => '', service => 'Transport service', meta => -'Reported by Transport service by Test User at 15:47, Saturday 16 April 2011' +'Reported by Transport service by Test User at 15:47, Sat 16 April 2011' }, { anonymous => 'f', category => 'Roads', service => 'Transport service', meta => -'Reported by Transport service in the Roads category by Test User at 15:47, Saturday 16 April 2011' +'Reported by Transport service in the Roads category by Test User at 15:47, Sat 16 April 2011' }, { anonymous => 't', category => 'Other', service => '', - meta => 'Reported anonymously at 15:47, Saturday 16 April 2011' + meta => 'Reported anonymously at 15:47, Sat 16 April 2011' }, { anonymous => 't', category => 'Roads', service => '', meta => -'Reported in the Roads category anonymously at 15:47, Saturday 16 April 2011' +'Reported in the Roads category anonymously at 15:47, Sat 16 April 2011' }, { anonymous => 't', category => '', service => 'Transport service', meta => -'Reported by Transport service anonymously at 15:47, Saturday 16 April 2011' +'Reported by Transport service anonymously at 15:47, Sat 16 April 2011' }, { anonymous => 't', category => 'Roads', service => 'Transport service', meta => -'Reported by Transport service in the Roads category anonymously at 15:47, Saturday 16 April 2011' +'Reported by Transport service in the Roads category anonymously at 15:47, Sat 16 April 2011' }, ) { diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 5719b13e3..39cb5d6d8 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -81,7 +81,7 @@ for my $test ( anonymous => 'f', mark_fixed => 'false', mark_open => 'false', - meta => 'Posted by Other User at 15:47, Saturday 16 April 2011', + meta => 'Posted by Other User at 15:47, Sat 16 April 2011', }, { description => 'blank user, anon is false', @@ -89,7 +89,7 @@ for my $test ( anonymous => 'f', mark_fixed => 'false', mark_open => 'false', - meta => 'Posted anonymously at 15:47, Saturday 16 April 2011', + meta => 'Posted anonymously at 15:47, Sat 16 April 2011', }, { description => 'named user, anon is true', @@ -97,7 +97,7 @@ for my $test ( anonymous => 't', mark_fixed => 'false', mark_open => 'false', - meta => 'Posted anonymously at 15:47, Saturday 16 April 2011', + meta => 'Posted anonymously at 15:47, Sat 16 April 2011', }, { description => 'named user, anon is true, fixed', @@ -106,7 +106,7 @@ for my $test ( mark_fixed => 'true', mark_open => 'false', meta => -'Posted anonymously at 15:47, Saturday 16 April 2011, marked as fixed', +'Posted anonymously at 15:47, Sat 16 April 2011, marked as fixed', }, { description => 'named user, anon is true, reopened', @@ -114,7 +114,7 @@ for my $test ( anonymous => 't', mark_fixed => 'false', mark_open => 'true', - meta => 'Posted anonymously at 15:47, Saturday 16 April 2011, reopened', + meta => 'Posted anonymously at 15:47, Sat 16 April 2011, reopened', } ) { @@ -185,9 +185,9 @@ subtest "several updates shown in correct order" => sub { my $meta = $mech->extract_update_metas; is scalar @$meta, 3, 'number of updates'; - is $meta->[0], 'Posted by Other User at 12:23, Thursday 10 March 2011', 'first update'; - is $meta->[1], 'Posted by Main User at 12:23, Thursday 10 March 2011', 'second update'; - is $meta->[2], 'Posted anonymously at 08:12, Tuesday 15 March 2011, marked as fixed', 'third update'; + is $meta->[0], 'Posted by Other User at 12:23, Thu 10 March 2011', 'first update'; + is $meta->[1], 'Posted by Main User at 12:23, Thu 10 March 2011', 'second update'; + is $meta->[2], 'Posted anonymously at 08:12, Tue 15 March 2011, marked as fixed', 'third update'; }; for my $test ( -- cgit v1.2.3 From bc7b6ef0d99a10f5c5d370df195cb5f80f145b0a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 6 Jan 2012 14:18:16 +0000 Subject: Fix test for when long domain name pushes things over one line. --- t/app/controller/alert_new.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/app/controller') diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 950666d2d..5ea73625a 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -452,7 +452,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { $count++ if $_->body =~ /The following updates have been left on this problem:/; $count++ if $_->body =~ /The following new problems have been reported to City of\s*Edinburgh Council:/; $count++ if $_->body =~ /The following nearby problems have been added:/; - $count++ if $_->body =~ / - Testing, EH1 1BB/; + $count++ if $_->body =~ / -\s+Testing, EH1 1BB/; } is $count, 5, 'Five emails with the right things in them'; -- cgit v1.2.3