aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Mock/MapIt.pm3
-rw-r--r--t/app/controller/alert.t17
-rw-r--r--t/app/controller/alert_new.t24
-rw-r--r--t/app/model/alert_type.t8
-rw-r--r--t/cobrand/fiksgatami.t30
5 files changed, 60 insertions, 22 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index c57f7e0ed..8cb5d777f 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -37,6 +37,9 @@ my @PLACES = (
[ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ],
[ 'OX28 4DS', 51.784721, -1.494453 ],
[ 'E14 2DN', 51.508536, '0.000001' ],
+ # Norway
+ [ '3290', 59, 10, 709, 'Larvik', 'NKO', 7, 'Vestfold', 'NFY' ],
+ [ '0045', "59.9", "10.9", 301, 'Oslo', 'NKO', 3, 'Oslo', 'NFY' ],
);
sub dispatch_request {
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index 57e73e5ec..41aee5bbc 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -9,6 +9,11 @@ $mech->title_like(qr/^Local RSS feeds and email alerts/);
$mech->content_contains('Local RSS feeds and email alerts');
$mech->content_contains('html class="no-js" lang="en-gb"');
+my $body = $mech->create_body_ok(2651, 'Edinburgh');
+$mech->create_body_ok(2504, 'Birmingham City Council');
+$mech->create_body_ok(2226, 'Gloucestershire County Council');
+$mech->create_body_ok(2326, 'Cheltenham Borough Council');
+
# check that we can get list page
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
@@ -33,8 +38,8 @@ FixMyStreet::override_config {
$mech->content_contains('Problems within City Centre ward');
$mech->content_contains('/rss/reports/Edinburgh');
$mech->content_contains('/rss/reports/Edinburgh/City+Centre');
- $mech->content_contains('council:2651:Edinburgh');
- $mech->content_contains('ward:2651:20728:Edinburgh:City_Centre');
+ $mech->content_contains('council:' . $body->id . ':Edinburgh');
+ $mech->content_contains('ward:' . $body->id . ':20728:Edinburgh:City_Centre');
subtest "Test Nominatim lookup" => sub {
$mech->get_ok('/alert/list?pc=High Street');
@@ -49,16 +54,12 @@ FixMyStreet::override_config {
$mech->content_contains('Problems in an area');
$mech->content_contains('Reports by destination');
- $mech->get_ok('/alert/subscribe?rss=1&type=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=' );
+ $mech->get_ok('/alert/subscribe?rss=1&type=local&pc=EH1+1BB&rss=Give+me+an+RSS+feed&rznvy=' );
$mech->content_contains('Please select the feed you want');
- $mech->get_ok('/alert/subscribe?rss=1&feed=invalid:1000:A_Locationtype=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=');
+ $mech->get_ok('/alert/subscribe?rss=1&feed=invalid:1000:A_Locationtype=local&pc=EH1+1BB&rss=Give+me+an+RSS+feed&rznvy=');
$mech->content_contains('Illegal feed selection');
- $mech->create_body_ok(2504, 'Birmingham City Council');
- $mech->create_body_ok(2226, 'Gloucestershire County Council');
- $mech->create_body_ok(2326, 'Cheltenham Borough Council');
-
$mech->get_ok('/alert/subscribe?rss=1&feed=area:1000:Birmingham');
is $mech->uri->path, '/rss/reports/Birmingham';
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 27371e4a9..49efc4efa 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -184,13 +184,15 @@ foreach my $test (
};
}
+my $body = $mech->create_body_ok(2651, 'Edinburgh Council');
+
foreach my $test (
{
desc => 'logged in user signing up',
email => 'test-sign-in@example.com',
type => 'council',
- param1 => 2651,
- param2 => 2651,
+ param1 => $body->id,
+ param2 => $body->id,
confirmed => 1,
}
)
@@ -207,9 +209,9 @@ foreach my $test (
ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
- $mech->get_ok('/alert/list?pc=EH991SP');
+ $mech->get_ok('/alert/list?pc=EH11BB');
};
- $mech->set_visible( [ radio => 'council:2651:City_of_Edinburgh' ] );
+ $mech->set_visible( [ radio => 'council:' . $body->id . ':City_of_Edinburgh' ] );
$mech->click('alert');
my $alert = FixMyStreet::App->model('DB::Alert')->find(
@@ -789,7 +791,7 @@ subtest "Test signature template is used from cobrand" => 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 => $body->id,
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Testing',
@@ -884,15 +886,15 @@ for my $test (
desc => 'check non public reports are not included in council problems alerts',
alert_params => {
alert_type => 'council_problems',
- parameter => '2651',
- parameter2 => '2651',
+ parameter => $body->id,
+ parameter2 => $body->id,
}
},
{
desc => 'check non public reports are not included in ward problems alerts',
alert_params => {
alert_type => 'ward_problems',
- parameter => '2651',
+ parameter => $body->id,
parameter2 => '20728',
}
},
@@ -936,7 +938,7 @@ for my $test (
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
postcode => 'EH1 1BB',
- bodies_str => '2651',
+ bodies_str => $body->id,
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Alert test for non public reports',
@@ -998,7 +1000,7 @@ subtest 'check new updates alerts for non public reports only go to report owner
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
postcode => 'EH1 1BB',
- bodies_str => '2651',
+ bodies_str => $body->id,
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Alert test for non public reports',
@@ -1091,7 +1093,7 @@ subtest 'check setting inlude dates in new updates cobrand option' => sub {
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
postcode => 'EH1 1BB',
- bodies_str => '2651',
+ bodies_str => $body->id,
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Alert test for non public reports',
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index c978b5ccf..124e838ee 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -22,6 +22,8 @@ my $user3 =
->find_or_create( { email => 'bystander@example.com', name => 'Bystander' } );
ok $user3, "created bystander";
+my $body = $mech->create_body_ok(2504, 'Westminster');
+
my $dt = DateTime->new(
year => 2011,
month => 04,
@@ -34,7 +36,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::DB->resultset('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',
@@ -165,8 +167,8 @@ $report->update();
my $council_alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
{
user => $user2,
- parameter => 2504,
- parameter2 => 2504,
+ parameter => $body->id,
+ parameter2 => $body->id,
alert_type => 'council_problems',
whensubscribed => $dt->ymd . ' ' . $dt->hms,
confirmed => 1,
diff --git a/t/cobrand/fiksgatami.t b/t/cobrand/fiksgatami.t
new file mode 100644
index 000000000..6510f5ebe
--- /dev/null
+++ b/t/cobrand/fiksgatami.t
@@ -0,0 +1,30 @@
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+my $oslo = $mech->create_body_ok(3, 'Oslo');
+my $vestfold = $mech->create_body_ok(7, 'Vestfold');
+my $larvik = $mech->create_body_ok(709, 'Larvik');
+
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fiksgatami',
+ MAPIT_URL => 'http://mapit.uk/',
+ GEOCODER => '',
+}, sub {
+ $mech->get_ok('/alert/list?pc=0045');
+ $mech->content_contains('rss/l/59.9,10.9/2');
+ $mech->content_contains('/rss/reports/Oslo');
+ $mech->content_contains('council:' . $oslo->id . ':Oslo');
+
+ $mech->get_ok('/alert/list?pc=3290');
+ $mech->content_contains('rss/l/59,10/5');
+ $mech->content_contains('/rss/area/Larvik');
+ $mech->content_contains('/rss/area/Vestfold');
+ $mech->content_contains('/rss/reports/Larvik');
+ $mech->content_contains('/rss/reports/Vestfold');
+ $mech->content_contains('area:7:Vestfold');
+ $mech->content_contains('area:709:Larvik');
+ $mech->content_contains('council:' . $vestfold->id . ':Vestfold');
+ $mech->content_contains('council:' . $larvik->id . ':Larvik');
+};
+
+done_testing();