aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/admin/bodies.t34
-rw-r--r--t/app/controller/report_new_anon.t75
2 files changed, 109 insertions, 0 deletions
diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t
index 9f7b18cde..80ee22630 100644
--- a/t/app/controller/admin/bodies.t
+++ b/t/app/controller/admin/bodies.t
@@ -1,3 +1,13 @@
+package FixMyStreet::Cobrand::AnonAllowedByCategory;
+use parent 'FixMyStreet::Cobrand::UKCouncils';
+sub council_url { 'anonbycategory' }
+sub council_name { 'Aberdeen City Council' }
+sub council_area { 'Aberdeen' }
+sub council_area_id { 2650 }
+sub anonymous_account { { email => 'anoncategory@example.org', name => 'Anonymous Category' } }
+
+package main;
+
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -295,8 +305,32 @@ subtest 'reopen disabling' => sub {
is $contact->get_extra_metadata('reopening_disallowed'), 1, 'Reopening disallowed flag set';
};
+subtest 'allow anonymous reporting' => sub {
+ $mech->get_ok('/admin/body/' . $body->id . '/test%20category');
+ $mech->content_lacks('Allow anonymous reports');
+};
}; # END of override wrap
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ MAPIT_TYPES => [ 'UTA' ],
+ BASE_URL => 'http://www.example.org',
+ ALLOWED_COBRANDS => [ "fixmystreet", "anonallowedbycategory" ],
+}, sub {
+
+subtest 'allow anonymous reporting' => sub {
+ $mech->get_ok('/admin/body/' . $body->id . '/test%20category');
+ $mech->submit_form_ok( { with_fields => {
+ anonymous_allowed => 1,
+ note => 'Anonymous Allowed',
+ } } );
+ $mech->content_contains('Values updated');
+ my $contact = $body->contacts->find({ category => 'test category' });
+ is $contact->get_extra_metadata('anonymous_allowed'), 1, 'Anonymous reports allowed flag set';
+};
+
+};
+
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.uk/',
diff --git a/t/app/controller/report_new_anon.t b/t/app/controller/report_new_anon.t
index d86bc8134..cba360f05 100644
--- a/t/app/controller/report_new_anon.t
+++ b/t/app/controller/report_new_anon.t
@@ -17,6 +17,14 @@ sub allow_anonymous_reports {
}
sub anonymous_account { { email => 'anoncategory@example.org', name => 'Anonymous Category' } }
+package FixMyStreet::Cobrand::AnonAllowedByCategory;
+use parent 'FixMyStreet::Cobrand::UKCouncils';
+sub council_url { 'anonbycategory' }
+sub council_name { 'Edinburgh City Council' }
+sub council_area { 'Edinburgh' }
+sub council_area_id { 2651 }
+sub anonymous_account { { email => 'anoncategory@example.org', name => 'Anonymous Category' } }
+
package main;
use FixMyStreet::TestMech;
@@ -269,4 +277,71 @@ subtest "test report creation anonymously by button, per category" => sub {
};
+$contact2->set_extra_metadata( anonymous_allowed => 1 );
+$contact2->update;
+
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'anonallowedbycategory',
+ MAPIT_URL => 'http://mapit.uk/',
+}, sub {
+
+subtest "test report creation anonymously by button, per category from metadata" => 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_category_part_only',
+ with_fields => {
+ category => 'Street lighting',
+ }
+ }, "submit category with no anonymous reporting");
+ $mech->content_lacks('<button name="report_anonymously" value="yes" class="btn btn--block">'); # non-JS button, JS button always there
+ $mech->submit_form_ok({
+ button => 'submit_register',
+ with_fields => {
+ category => 'Trees',
+ }
+ }, "submit category with anonymous reporting");
+
+ $mech->submit_form_ok({
+ button => 'report_anonymously',
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ }
+ }, "submit good details");
+ $mech->content_contains('Your issue is on its way to the council');
+
+ my $report = FixMyStreet::DB->resultset("Problem")->search({}, { order_by => { -desc => 'id' } })->first;
+ ok $report, "Found the report";
+
+ is $report->state, 'confirmed', "report confirmed";
+ is $report->bodies_str, $body->id;
+ is $report->name, 'Anonymous Category';
+ is $report->anonymous, 1; # Doesn't change behaviour here, but uses anon account's name always
+ is $report->get_extra_metadata('contributed_as'), 'anonymous_user';
+};
+
+};
+
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ BASE_URL => 'https://www.fixmystreet.com',
+ MAPIT_URL => 'http://mapit.uk/',
+}, sub {
+subtest "test anonymously by button, per category from metadata limited to cobrand" => 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_category_part_only',
+ with_fields => {
+ category => 'Trees',
+ }
+ }, "submit category with no anonymous reporting");
+ $mech->content_lacks('<button name="report_anonymously" value="yes" class="btn btn--block">'); # non-JS button, JS button always there
+};
+
+};
+
done_testing();