aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Mock/MapIt.pm10
-rw-r--r--t/app/controller/around.t6
-rw-r--r--t/app/controller/report_as_other.t17
-rw-r--r--t/app/sendreport/email.t17
4 files changed, 40 insertions, 10 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index d5b73641a..11fa4200c 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -30,7 +30,6 @@ my @PLACES = (
[ 'SL9 0NX', 51.615559, -0.556903, 2217, 'Buckinghamshire County Council', 'CTY', 2257, 'Chiltern District Council', 'DIS' ],
[ 'SW1A 1AA', 51.501009, -0.141588, 2504, 'Westminster City Council', 'LBO' ],
[ 'GL50 2PR', 51.896268, -2.093063, 2226, 'Gloucestershire County Council', 'CTY', 2326, 'Cheltenham Borough Council', 'DIS', 4544, 'Lansdown', 'DIW', 143641, 'Lansdown and Park', 'CED' ],
- [ '?', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'OX20 1SZ', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'OX16 9UP', 52.038712, -1.346397, 2237, 'Oxfordshire County Council', 'CTY', 2419, 'Cherwell District Council', 'DIS', 151767, "Banbury, Calthorpe & Easington", "DIW" ],
[ 'RG9 6TL', 51.561705, -0.868388, 2217, 'Buckinghamshire County Council', 'CTY'],
@@ -39,6 +38,7 @@ my @PLACES = (
[ 'BR1 3UH', 51.4021, 0.01578, 2482, 'Bromley Council', 'LBO' ],
[ 'BR1 3UH', 51.402096, 0.015784, 2482, 'Bromley Council', 'LBO' ],
[ '?', 50.78301, -0.646929 ],
+ [ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ],
[ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ],
[ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ],
[ 'OX28 4DS', 51.784721, -1.494453 ],
@@ -72,14 +72,18 @@ sub dispatch_request {
return $self->output($response);
},
- sub (GET + /point/**.*) {
- my ($self, $point) = @_;
+ sub (GET + /point/**.* + ?*) {
+ my ($self, $point, $query) = @_;
foreach (@PLACES) {
if ($point eq "4326/$_->[2],$_->[1]") {
my %out;
for (my $i=3; $i<@$_; $i+=3) {
$out{"$_->[$i]"} = { id => $_->[$i], name => $_->[$i+1], type => $_->[$i+2] };
}
+ if ($query->{type}) {
+ my %types = map { $_ => 1 } split ',', $query->{type};
+ %out = map { $_ => $out{$_} } grep { $types{$out{$_}{type}} } keys %out;
+ }
return $self->output(\%out);
}
}
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index 3f0fff666..b123692fa 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -228,6 +228,7 @@ subtest 'check category, status and extra filtering works on /around' => sub {
# Regression test for filter_category in /around URL
FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fixmystreet',
MAPIT_URL => 'http://mapit.uk/',
}, sub {
$mech->get_ok( '/around?filter_category=Pothole&bbox=' . $bbox );
@@ -331,15 +332,17 @@ subtest 'check skip_around skips around page' => sub {
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.uk/',
+ MAPIT_TYPES => ['CTY', 'DIS'],
}, sub {
$mech->get('/around?latitude=51.754926&longitude=-1.256179');
- is $mech->res->code, 302, "around page is a redirect";
+ is $mech->res->previous->code, 302, "around page is a redirect";
is $mech->uri->path, '/report/new', "and redirects to /report/new";
};
};
subtest 'check map zoom level customisation' => sub {
FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fixmystreet',
MAPIT_URL => 'http://mapit.uk/',
MAP_TYPE => 'OSM',
}, sub {
@@ -350,6 +353,7 @@ subtest 'check map zoom level customisation' => sub {
FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fixmystreet',
MAPIT_URL => 'http://mapit.uk/',
MAP_TYPE => 'Tester',
}, sub {
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index 9ed46190b..0c8b7d995 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -16,6 +16,8 @@ my $test_email = 'body-user@example.net';
my $user = $mech->log_in_ok($test_email);
$user->update({ from_body => $body->id, name => 'Body User' });
+my $superuser = $mech->create_user_ok('superuser@example.net', name => "Super", is_superuser => 1);
+
my ($report_to_update) = $mech->create_problems_for_body(1, $body->id, 'Title', { category => 'Potholes' });
subtest "Body user, no permissions, no special reporting tools shown" => sub {
@@ -150,10 +152,11 @@ subtest "Body user, has permission to add report as another (existing) user with
push @users, $report->user;
};
-subtest "Body user, has permission to add report as anonymous user" => sub {
+subtest "Superuser, can add report as anonymous user" => sub {
FixMyStreet::Script::Reports::send();
$mech->clear_emails_ok;
+ my $user = $mech->log_in_ok($superuser->email);
my $report = add_report(
'contribute_as_anonymous_user',
form_as => 'anonymous_user',
@@ -161,8 +164,8 @@ subtest "Body user, has permission to add report as anonymous user" => sub {
detail => 'Test report details.',
category => 'Street lighting',
);
- is $report->name, 'Oxfordshire County Council', 'report name is body';
- is $report->user->name, 'Body User', 'user name unchanged';
+ is $report->name, 'an administrator', 'report name is admin';
+ is $report->user->name, 'Super', 'user name unchanged';
is $report->user->id, $user->id, 'user matches';
is $report->anonymous, 1, 'report anonymous';
@@ -172,12 +175,12 @@ subtest "Body user, has permission to add report as anonymous user" => sub {
);
FixMyStreet::Script::Reports::send();
- # No report sent email is sent
- $mech->email_count_is(1);
my $email = $mech->get_email;
like $email->header('Subject'), qr/Problem Report: Test Report/, 'report email title correct';
$mech->clear_emails_ok;
$send_confirmation_mail_override->restore();
+
+ $mech->log_in_ok($test_email);
};
subtest "Body user, has permission to add update as council" => sub {
@@ -329,7 +332,9 @@ sub add_report {
with_fields => \%fields,
}, "submit details");
};
- $mech->content_contains('Thank you for reporting this issue');
+ # Anonymous test done as superuser, which redirects
+ $mech->content_contains('Thank you for reporting this issue')
+ unless $permission eq 'contribute_as_anonymous_user';
my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first;
ok $report, "Found the report";
is $report->state, 'confirmed', "report is now confirmed";
diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t
index 6b292725b..3e6db4f67 100644
--- a/t/app/sendreport/email.t
+++ b/t/app/sendreport/email.t
@@ -20,6 +20,8 @@ my $contact = $mech->create_contact_ok(
);
my $row = FixMyStreet::DB->resultset('Problem')->new( {
+ latitude => 51.023569,
+ longitude => -3.099055,
bodies_str => '1000',
category => 'category',
cobrand => '',
@@ -67,4 +69,19 @@ foreach my $test ( {
};
}
+$body->body_areas->delete;
+$body->body_areas->create({ area_id => 2429 });
+
+subtest 'Test special behaviour' => sub {
+ my $e = FixMyStreet::SendReport::Email->new;
+ $contact->update( { state => 'confirmed', email => 'SPECIAL' } );
+ $e->add_body( $body );
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/'
+ }, sub {
+ my ($e) = $e->build_recipient_list( $row, {} );
+ like $e->[0], qr/tauntondeane/, 'correct recipient';
+ };
+};
+
done_testing();