aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-04-26 13:05:29 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-04-26 13:05:29 +0100
commit3806b6b39ace2d38c264615eb95370a303ede34c (patch)
tree4da84289e6053c1e7059d67f71a0ba1511c16637 /t
parent56dca800a946f8cef66e9839590c5a9f37cad12f (diff)
parent41a5f14388e92fa9dbbb5dc3a72d9ad83291eeb4 (diff)
Merge branch 'collideoscope-anew'
Diffstat (limited to 't')
-rw-r--r--t/Mock/MapIt.pm1
-rw-r--r--t/app/controller/report_new.t1
-rw-r--r--t/app/controller/reports.t3
-rw-r--r--t/cobrand/form_extras.t35
4 files changed, 36 insertions, 4 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index 1e94bb3e6..c57f7e0ed 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -23,6 +23,7 @@ sub output {
}
my @PLACES = (
+ [ '?', 53.387402, -2.943997, 2527, 'Liverpool City Council', 'MTD' ],
[ 'EH1 1BB', 55.952055, -3.189579, 2651, 'Edinburgh City Council', 'UTA', 20728, 'City Centre', 'UTE' ],
[ 'BS10 5EE', 51.494885, -2.602237, 2561, 'Bristol City Council', 'UTA', 148646, 'Bedminster', 'UTW' ],
[ 'SW1A 1AA', 51.501009, -0.141588, 2504, 'Westminster City Council', 'LBO' ],
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 0e7547a85..e12391804 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -1169,6 +1169,7 @@ FixMyStreet::override_config {
$extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon );
};
$mech->content_contains( "Pothol\xc3\xa9s" );
+like $extra_details->{councils_text}, qr/<strong>Cheltenham/;
ok !$extra_details->{titles_list}, 'Non Bromley does not send back list of titles';
FixMyStreet::override_config {
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 76c920562..8cdfddd1b 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -95,6 +95,9 @@ $fife_problems[10]->update( {
state => 'hidden',
});
+# Run the cron script old-data (for the table no longer used by default)
+FixMyStreet::Script::UpdateAllReports::generate(1);
+
# Run the cron script that makes the data for /reports so we don't get an error.
my $data = FixMyStreet::Script::UpdateAllReports::generate_dashboard();
diff --git a/t/cobrand/form_extras.t b/t/cobrand/form_extras.t
index 84ded5bc1..df76ccbe1 100644
--- a/t/cobrand/form_extras.t
+++ b/t/cobrand/form_extras.t
@@ -2,7 +2,10 @@ package FixMyStreet::Cobrand::Tester;
use parent 'FixMyStreet::Cobrand::FixMyStreet';
sub report_form_extras {
- ( { name => 'address', required => 1 }, { name => 'passport', required => 0 } )
+ (
+ { name => 'address', required => 1 },
+ { name => 'passport', required => 0, validator => sub { die "Invalid number\n" if $_[0] && $_[0] !~ /^P/; return $_[0] } },
+ )
}
# To allow a testing template override
@@ -30,6 +33,7 @@ FixMyStreet::override_config {
$mech->get_ok('/around');
$mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" );
$mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
+
$mech->submit_form_ok( {
button => 'submit_register',
with_fields => {
@@ -38,13 +42,24 @@ FixMyStreet::override_config {
name => 'Joe Bloggs',
may_show_name => '1',
username => 'test-1@example.com',
- passport => '123456',
password_register => '',
}
},
- "submit details without address, with passport",
+ "submit details without address or passport",
);
$mech->content_like(qr{<label for="form_address">Address</label>\s*<p class='form-error'>This information is required</p>}, 'Address is required');
+ $mech->content_lacks("<p class='form-error'>Invalid number", 'Passport is optional');
+
+ $mech->submit_form_ok( {
+ button => 'submit_register',
+ with_fields => {
+ passport => '123456',
+ }
+ },
+ "submit details with bad passport",
+ );
+ $mech->content_like(qr{<label for="form_address">Address</label>\s*<p class='form-error'>This information is required</p>}, 'Address is required');
+ $mech->content_like(qr{<p class='form-error'>Invalid number}, 'Passport format wrong');
$mech->content_contains('value="123456" name="passport"', 'Passport number reshown');
$mech->submit_form_ok( {
@@ -55,11 +70,23 @@ FixMyStreet::override_config {
},
"submit details, now with address",
);
+ $mech->content_lacks('This information is required', 'Address is present');
+ $mech->content_like(qr{<p class='form-error'>Invalid number}, 'Passport format wrong');
+ $mech->content_contains('value="123456" name="passport"', 'Passport number reshown');
+
+ $mech->submit_form_ok( {
+ button => 'submit_register',
+ with_fields => {
+ passport => 'P123456',
+ }
+ },
+ "submit details with correct passport",
+ );
$mech->content_contains('Now check your email');
my $problem = FixMyStreet::DB->resultset('Problem')->search({}, { order_by => '-id' })->first;
is $problem->get_extra_metadata('address'), 'My address', 'Address is stored';
- is $problem->get_extra_metadata('passport'), '123456', 'Passport number is stored';
+ is $problem->get_extra_metadata('passport'), 'P123456', 'Passport number is stored';
};
END {