From 1bb94cd0bf0821927b3f449d832a9982b0397fa9 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 31 May 2017 12:48:17 +0100 Subject: Auto-add strict/warnings/Test::More with TestMech. --- t/app/controller/admin.t | 4 ---- 1 file changed, 4 deletions(-) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 5f8abe5a6..48a5edc44 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; -- cgit v1.2.3 From e57cbf483790bedfef6496be3c7ffa42882c3ffc Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 13 Jun 2017 18:39:05 +0100 Subject: [UK] Remove requirement for fixed body IDs. Historically in UK cobrands, bodies have had IDs the same as the MapIt area ID they cover. This can be confusing (if you are setting up a dev environment, say) and should not be necessary. This commit removes the requirement entirely, by switching any ID checks to either the name of the body, or the actual area it covers. One note: the body name in the test has to match so that we do not get two bodies both covering 2237 created. This will not be necessary when the tests are compartmentalized in the next commit. --- t/app/controller/admin.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 48a5edc44..07759197e 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -8,7 +8,7 @@ my $user2 = $mech->create_user_ok('test2@example.com', name => 'Test User 2'); my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); -my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $oxfordshirecontact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => 'potholes@example.com' ); $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Traffic lights', email => 'lights@example.com' ); my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxfordshire); @@ -16,7 +16,7 @@ my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => ' my $oxford = $mech->create_body_ok(2421, 'Oxford City Council'); $mech->create_contact_ok( body_id => $oxford->id, category => 'Graffiti', email => 'graffiti@example.net' ); -my $bromley = $mech->create_body_ok(2482, 'Bromley Council', id => 2482); +my $bromley = $mech->create_body_ok(2482, 'Bromley Council'); my $user3 = $mech->create_user_ok('test3@example.com', name => 'Test User 2'); @@ -115,7 +115,7 @@ subtest 'check summary counts' => sub { my ($num_alerts) = $mech->content =~ /(\d+) confirmed alerts/; my ($num_qs) = $mech->content =~ /(\d+) questionnaires sent/; - $report->bodies_str(2237); + $report->bodies_str($oxfordshire->id); $report->cobrand('oxfordshire'); $report->update; -- cgit v1.2.3 From 3b72526db1cdb4695f61a188261351ddd2aea395 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 14 Jun 2017 13:59:43 +0100 Subject: Run each test file in a transaction. This means that the tests can be run in parallel. --- t/app/controller/admin.t | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 07759197e..4384123bd 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -18,11 +18,7 @@ $mech->create_contact_ok( body_id => $oxford->id, category => 'Graffiti', email my $bromley = $mech->create_body_ok(2482, 'Bromley Council'); -my $user3 = $mech->create_user_ok('test3@example.com', name => 'Test User 2'); - -if ( $user3 ) { - $mech->delete_user( $user3 ); -} +my $user3; my $dt = DateTime->new( year => 2011, @@ -154,16 +150,6 @@ $mech->content_like(qr{AB\d\d}); $mech->content_contains("http://www.example.org/around"); subtest 'check contact creation' => sub { - my $contact = FixMyStreet::App->model('DB::Contact')->search( - { body_id => $body->id, category => [ 'test category', 'test/category' ] } - ); - $contact->delete_all; - - my $history = FixMyStreet::App->model('DB::ContactsHistory')->search( - { body_id => $body->id, category => [ 'test category', 'test/category' ] } - ); - $history->delete_all; - $mech->get_ok('/admin/body/' . $body->id); $mech->submit_form_ok( { with_fields => { @@ -1542,15 +1528,4 @@ subtest "response priorities can't be viewed across councils" => sub { }; }; -END { - $mech->delete_user( $user ); - $mech->delete_user( $user2 ); - $mech->delete_user( $user3 ); - $mech->delete_user( $superuser ); - $mech->delete_user( 'test4@example.com' ); - $mech->delete_body( $oxfordshire ); - $mech->delete_body( $oxford ); - $mech->delete_body( $bromley ); - $mech->delete_body( $westminster ); - done_testing(); -} +done_testing(); -- cgit v1.2.3 From 466c5cac0f000bfa80ab49c88ec6e03c388ac328 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Sat, 8 Jul 2017 22:11:57 +0100 Subject: Add inactive state to categories. A new 'state' column replaces confirmed and deleted, allowing categories to be unconfirmed, confirmed, deleted or inactive. --- t/app/controller/admin.t | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 4384123bd..db7f9fc3c 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -157,13 +157,13 @@ subtest 'check contact creation' => sub { email => 'test@example.com', note => 'test note', non_public => undef, - confirmed => 0, + state => 'unconfirmed', } } ); $mech->content_contains( 'test category' ); $mech->content_contains( 'test@example.com' ); $mech->content_contains( 'test note' ); - $mech->content_contains( 'Private: No' ); + $mech->content_like( qr/\s*unconfirmed\s*<\/td>/ ); # No private $mech->submit_form_ok( { with_fields => { category => 'private category', @@ -173,7 +173,7 @@ subtest 'check contact creation' => sub { } } ); $mech->content_contains( 'private category' ); - $mech->content_contains( 'Private: Yes' ); + $mech->content_like( qr{test\@example.com\s*\s*\s*confirmed\s*
\s*\s*Private\s*\s*} ); $mech->submit_form_ok( { with_fields => { category => 'test/category', @@ -195,9 +195,8 @@ subtest 'check contact editing' => sub { } } ); $mech->content_contains( 'test category' ); - $mech->content_contains( 'test2@example.com' ); + $mech->content_like( qr{test2\@example.com\s*\s*\s*unconfirmed\s*} ); $mech->content_contains( 'test2 note' ); - $mech->content_contains( 'Private: No' ); $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); $mech->submit_form_ok( { with_fields => { @@ -210,14 +209,13 @@ subtest 'check contact editing' => sub { $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); $mech->content_contains( 'test2@example.com,test3@example.com' ); - $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); $mech->submit_form_ok( { with_fields => { email => 'test2@example.com', note => 'test2 note', non_public => 'on', } } ); - $mech->content_contains( 'Private: Yes' ); + $mech->content_like( qr{test2\@example.com\s*\s*\s*unconfirmed\s*
\s*\s*Private\s*\s*} ); $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); $mech->content_contains( 'test2@example.com' ); @@ -225,7 +223,7 @@ subtest 'check contact editing' => sub { subtest 'check contact updating' => sub { $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); - $mech->content_like(qr{test2\@example.com[^<]*[^<]*No}s); + $mech->content_like(qr{test2\@example.com
[^<]*[^<]*unconfirmed}s); $mech->get_ok('/admin/body/' . $body->id); @@ -233,9 +231,9 @@ subtest 'check contact updating' => sub { $mech->tick( 'confirmed', 'test category' ); $mech->submit_form_ok({form_number => 1}); - $mech->content_like(qr'test2@example.com[^<]*\s*Confirmed: Yes's); + $mech->content_like(qr'test2@example.com[^<]*\s*confirmed's); $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); - $mech->content_like(qr{test2\@example.com[^<]*[^<]*Yes}s); + $mech->content_like(qr{test2\@example.com[^<]*[^<]*confirmed}s); }; $body->update({ send_method => undef }); -- cgit v1.2.3 From df1494f5a9de03c80764adf6108cbf699f547459 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 31 Jul 2017 15:15:02 +0100 Subject: Body/category translation admin interface. --- t/app/controller/admin.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index db7f9fc3c..069e00b5e 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -182,7 +182,7 @@ subtest 'check contact creation' => sub { non_public => 'on', } } ); $mech->get_ok('/admin/body/' . $body->id . '/test/category'); - + $mech->content_contains('

test/category

'); }; subtest 'check contact editing' => sub { -- cgit v1.2.3 From f066a3937216e0cc4dc0413efc8e8f90e79b6066 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 9 Aug 2017 16:46:39 +0100 Subject: enable body users to report problems anonymously uses the body user but flags the report as anonymous Fixes #fixmystreetforcouncils/207 --- t/app/controller/admin.t | 1 + 1 file changed, 1 insertion(+) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 069e00b5e..075ab0fd0 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1177,6 +1177,7 @@ my %default_perms = ( "permissions[report_inspect]" => undef, "permissions[report_instruct]" => undef, "permissions[contribute_as_another_user]" => undef, + "permissions[contribute_as_anonymous_user]" => undef, "permissions[contribute_as_body]" => undef, "permissions[view_body_contribute_details]" => undef, "permissions[user_edit]" => undef, -- cgit v1.2.3 From d9c0917b84d501e6cfca7e0113470997b6ff2f35 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 8 Sep 2017 17:19:57 +0100 Subject: edit and display default response priority in admin --- t/app/controller/admin.t | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 't/app/controller/admin.t') diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 075ab0fd0..bd0f9e408 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1470,6 +1470,7 @@ subtest "response priorities can be added" => sub { name => "Cat 1A", description => "Fixed within 24 hours", deleted => undef, + is_default => undef, "contacts[".$oxfordshirecontact->id."]" => 1, }; $mech->submit_form_ok( { with_fields => $fields } ); @@ -1478,6 +1479,25 @@ subtest "response priorities can be added" => sub { is $oxfordshirecontact->response_priorities->count, 1, "Response template was added to contact"; }; +subtest "response priorities can set to default" => sub { + my $priority_id = $oxfordshire->response_priorities->first->id; + is $oxfordshire->response_priorities->count, 1, "Response priority exists"; + $mech->get_ok( "/admin/responsepriorities/" . $oxfordshire->id . "/$priority_id" ); + + my $fields = { + name => "Cat 1A", + description => "Fixed within 24 hours", + deleted => undef, + is_default => 1, + "contacts[".$oxfordshirecontact->id."]" => 1, + }; + $mech->submit_form_ok( { with_fields => $fields } ); + + is $oxfordshire->response_priorities->count, 1, "Still one response priority"; + is $oxfordshirecontact->response_priorities->count, 1, "Still one response template"; + ok $oxfordshire->response_priorities->first->is_default, "Response priority set to default"; +}; + subtest "response priorities can be listed" => sub { $mech->get_ok( "/admin/responsepriorities/" . $oxfordshire->id ); -- cgit v1.2.3