aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-05-08 12:24:35 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2015-07-28 16:18:15 +0100
commit9d00e9bc88bde0c604a30d7f72890768b13ee7f0 (patch)
treedfbbb4496c2b4fe3d00ccd1e76e40d9b93108ad1 /t
parenta6390b55a0f05ef348b831ad76ce07834ac26e7e (diff)
[fixmystreet.com] Unresponsive bodies page/warning
Add a special category email address used to show an unresponsive message and page when trying to report in that category. Add a "Refused" send method for setting a whole body to be unresponsive and show the message immediately, not on category selection. Factor out category template, and put at top where needed.
Diffstat (limited to 't')
-rw-r--r--t/app/controller/report_new.t100
-rw-r--r--t/app/controller/report_new_open311.t2
2 files changed, 100 insertions, 2 deletions
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 3e1446068..bd0001be8 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -462,7 +462,7 @@ foreach my $test (
};
# check that we got the errors expected
- is_deeply $mech->page_errors, $test->{errors}, "check errors";
+ is_deeply [ sort @{$mech->page_errors} ], [ sort @{$test->{errors}} ], "check errors";
# check that fields have changed as expected
my $new_values = {
@@ -1462,6 +1462,104 @@ subtest "categories from deleted bodies shouldn't be visible for new reports" =>
};
};
+subtest "unresponsive body handling works" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ # Test body-level send method
+ my $old_send = $contact1->body->send_method;
+ $contact1->body->update( { send_method => 'Refused' } );
+ $mech->get_ok('/report/new/ajax?latitude=55.9&longitude=-3.2'); # Edinburgh
+ my $body_id = $contact1->body->id;
+ ok $mech->content_like( qr{Edinburgh.*accept reports.*/unresponsive\?body=$body_id} );
+
+ my $test_email = 'test-2@example.com';
+ my $user = $mech->log_in_ok($test_email);
+ $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(
+ {
+ with_fields => {
+ title => "Test Report at café",
+ detail => 'Test report details.',
+ photo => '',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ phone => '07903 123 456',
+ category => 'Trees',
+ }
+ },
+ "submit good details"
+ );
+
+ my $report = $user->problems->first;
+ ok $report, "Found the report";
+ is $report->bodies_str, undef, "Report not going anywhere";
+
+ $user->problems->delete;
+ $contact1->body->update( { send_method => $old_send } );
+
+ # And test per-category refusing
+ my $old_email = $contact3->email;
+ $contact3->update( { email => 'REFUSED' } );
+ $mech->get_ok('/report/new/category_extras?category=Trees&latitude=51.89&longitude=-2.09');
+ ok $mech->content_like( qr/Cheltenham.*Trees.*unresponsive.*category=Trees/ );
+
+ $mech->get_ok('/around');
+ $mech->submit_form_ok( { with_fields => { pc => 'GL50 2PR', } }, "submit location" );
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ title => "Test Report at café",
+ detail => 'Test report details.',
+ photo => '',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ phone => '07903 123 456',
+ category => 'Trees',
+ }
+ },
+ "submit good details"
+ );
+
+ $report = $user->problems->first;
+ ok $report, "Found the report";
+ is $report->bodies_str, undef, "Report not going anywhere";
+
+ $contact3->update( { email => $old_email } );
+ $mech->delete_user($user);
+ };
+};
+
+subtest "unresponsive body page works" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ my $old_send = $contact1->body->send_method;
+ my $body_id = $contact1->body->id;
+ my $url = "/unresponsive?body=$body_id";
+ is $mech->get($url)->code, 404, "page not found";
+ $contact1->body->update( { send_method => 'Refused' } );
+ $mech->get_ok($url);
+ $mech->content_contains('Edinburgh');
+ $contact1->body->update( { send_method => $old_send } );
+
+ my $old_email = $contact3->email;
+ $body_id = $contact3->body->id;
+ $url = "/unresponsive?body=$body_id;category=Trees";
+ is $mech->get($url)->code, 404, "page not found";
+ $contact3->update( { email => 'REFUSED' } );
+ $mech->get_ok($url);
+ $mech->content_contains('Cheltenham');
+ $mech->content_contains('Trees');
+ $contact3->update( { email => $old_email } );
+ };
+};
+
subtest "extra google analytics code displayed on logged in problem creation" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 53b84b92d..d3ca93f0e 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -60,9 +60,9 @@ foreach my $test (
type => 'old',
},
errors => [
+ 'This information is required',
'Please enter a subject',
'Please enter some details',
- 'This information is required',
'Please enter your email',
'Please enter your name',
],