aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/report_new_anon.t72
1 files changed, 72 insertions, 0 deletions
diff --git a/t/app/controller/report_new_anon.t b/t/app/controller/report_new_anon.t
index 5a4f35f5d..e9ce23c44 100644
--- a/t/app/controller/report_new_anon.t
+++ b/t/app/controller/report_new_anon.t
@@ -3,6 +3,11 @@ use parent 'FixMyStreet::Cobrand::FixMyStreet';
sub allow_anonymous_reports { 1 }
sub anonymous_account { { email => 'anon@example.org', name => 'Anonymous' } }
+package FixMyStreet::Cobrand::AnonAllowedByButton;
+use parent 'FixMyStreet::Cobrand::FixMyStreet';
+sub allow_anonymous_reports { 'button' }
+sub anonymous_account { { email => 'anonbutton@example.org', name => 'Anonymous Button' } }
+
package main;
use FixMyStreet::TestMech;
@@ -89,4 +94,71 @@ subtest "test report creation anonymously" => sub {
};
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'anonallowedbybutton',
+ MAPIT_URL => 'http://mapit.uk/',
+}, sub {
+
+subtest "test report creation anonymously by button" => sub {
+ $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 => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ category => 'Street lighting',
+ }
+ },
+ "submit good details"
+ );
+
+ is_deeply $mech->page_errors, [
+ 'Please enter your email'
+ ], "check there were no errors";
+
+ $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 => 'report_anonymously',
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ category => 'Street lighting',
+ }
+ },
+ "submit good details"
+ );
+ $mech->content_contains('Thank you');
+
+ is_deeply $mech->page_errors, [], "check there were no errors";
+
+ my $report = FixMyStreet::DB->resultset("Problem")->search({}, { order_by => { -desc => 'id' } })->first;
+ ok $report, "Found the report";
+
+ is $report->state, 'confirmed', "report confirmed";
+ $mech->get_ok( '/report/' . $report->id );
+
+ is $report->bodies_str, $body->id;
+ is $report->name, 'Anonymous Button';
+ is $report->anonymous, 1; # Doesn't change behaviour here, but uses anon account's name always
+
+ my $alert = FixMyStreet::App->model('DB::Alert')->find( {
+ user => $report->user,
+ alert_type => 'new_updates',
+ parameter => $report->id,
+ } );
+ is $alert, undef, "no alert created";
+
+ $mech->not_logged_in_ok;
+};
+
+};
+
done_testing();