diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-07-14 16:25:31 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-07-14 16:25:31 +0100 |
commit | 8c3f0fbfb4bcd33fa8dbc93c2ecb8e0f25ebf383 (patch) | |
tree | 0b596b32bc9248d10e6f4409e39d3285e957d40a /t | |
parent | 298db521933eb65591fafa218e78f5f4cdb547ad (diff) | |
parent | 426bc926a422af21ff39cebed836d34e46238500 (diff) |
Merge branch 'issues/forcouncils/192-unused-categories'
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin.t | 18 | ||||
-rw-r--r-- | t/app/controller/dashboard.t | 3 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 26 | ||||
-rw-r--r-- | t/app/controller/reports.t | 2 | ||||
-rw-r--r-- | t/app/model/extra.t | 3 | ||||
-rw-r--r-- | t/app/model/problem.t | 2 | ||||
-rw-r--r-- | t/app/sendreport/email.t | 2 | ||||
-rw-r--r-- | t/app/sendreport/open311.t | 3 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 3 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 41 |
10 files changed, 55 insertions, 48 deletions
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( '<td>test note' ); - $mech->content_contains( 'Private: No' ); + $mech->content_like( qr/<td>\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*</td>\s*<td>\s*confirmed\s*<br>\s*<small>\s*Private\s*</small>\s*</td>} ); $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*</td>\s*<td>\s*unconfirmed\s*</td>} ); $mech->content_contains( '<td>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( '<td><strong>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*</td>\s*<td>\s*unconfirmed\s*<br>\s*<small>\s*Private\s*</small>\s*</td>} ); $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); $mech->content_contains( '<td><strong>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</strong>[^<]*</td>[^<]*<td>No}s); + $mech->content_like(qr{test2\@example.com</strong>[^<]*</td>[^<]*<td>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</td>[^<]*<td>\s*Confirmed: Yes's); + $mech->content_like(qr'test2@example.com</td>[^<]*<td>\s*confirmed's); $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); - $mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>Yes}s); + $mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>confirmed}s); }; $body->update({ send_method => undef }); diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 9713d2d2c..9d424c1ae 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -59,9 +59,8 @@ FixMyStreet::override_config { body_id => $body->id, category => $contact, email => "$contact\@example.org", - confirmed => 1, + state => 'confirmed', whenedited => DateTime->now, - deleted => 0, editor => 'test', note => 'test', } diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 52bf6da3e..ab6b5d78e 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -890,6 +890,32 @@ foreach my $test ( } +subtest "Test inactive categories" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], + BASE_URL => 'https://www.fixmystreet.com', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + # Around and New report have both categories + $mech->get_ok('/around?pc=GL50+2PR'); + $mech->content_contains('Potholes'); + $mech->content_contains('Trees'); + $mech->get_ok("/report/new?lat=$saved_lat&lon=$saved_lon"); + $mech->content_contains('Potholes'); + $mech->content_contains('Trees'); + $contact2->update( { state => 'inactive' } ); # Potholes + # But when Potholes is inactive, it's not on New report + $mech->get_ok('/around?pc=GL50+2PR'); + $mech->content_contains('Potholes'); + $mech->content_contains('Trees'); + $mech->get_ok("/report/new?lat=$saved_lat&lon=$saved_lon"); + $mech->content_lacks('Potholes'); + $mech->content_contains('Trees'); + # Change back + $contact2->update( { state => 'confirmed' } ); + }; +}; + subtest "test report creation for a category that is non public" => sub { $mech->log_out_ok; $mech->clear_emails_ok; diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 464a78c24..15e7e3718 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -201,7 +201,7 @@ subtest "test greenwich all reports page" => sub { body_id => $body->id, category => 'Deleted', email => 'deleted@example.com', - deleted => 1 + state => 'deleted', ); ok $mech->host("greenwich.fixmystreet.com"), 'change host to greenwich'; $mech->get_ok('/reports/Royal+Borough+of+Greenwich'); diff --git a/t/app/model/extra.t b/t/app/model/extra.t index c073ae161..4e2a8ed37 100644 --- a/t/app/model/extra.t +++ b/t/app/model/extra.t @@ -13,8 +13,7 @@ sub get_test_contact { category => "Testing ${serial}", body => $body, email => 'test@example.com', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => 'test script', note => 'test script', whenedited => DateTime->now(), diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 142262ae9..76b7c476a 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -425,7 +425,7 @@ for my $contact ( { category => 'Graffiti', email => 'highways@example.net', }, { - confirmed => 0, + state => 'unconfirmed', body_id => $body_ids{2636}, # Isle of Wight category => 'potholes', email => '2636@example.com', diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t index 0cdf49378..718b0a495 100644 --- a/t/app/sendreport/email.t +++ b/t/app/sendreport/email.t @@ -56,7 +56,7 @@ foreach my $test ( { ) { subtest $test->{desc} => sub { my $e = FixMyStreet::SendReport::Email->new; - $contact->update( { confirmed => 0 } ) if $test->{unconfirmed}; + $contact->update( { state => 'unconfirmed' } ) if $test->{unconfirmed}; $contact->update( { note => $test->{note} } ) if $test->{note}; $e->add_body( $body ) if $test->{add_council}; is $e->build_recipient_list( $row, {} ), $test->{count}, 'correct recipient list count'; diff --git a/t/app/sendreport/open311.t b/t/app/sendreport/open311.t index b60b199b0..8f933065c 100644 --- a/t/app/sendreport/open311.t +++ b/t/app/sendreport/open311.t @@ -167,10 +167,9 @@ sub test_overrides { $body->update({ can_be_devolved => 1 }); my $contact = $body->contacts->find_or_create( - confirmed => 1, + state => 'confirmed', email => 'ZZ', category => 'ZZ', - deleted => 0, editor => 'test suite', note => '', whenedited => DateTime->now, diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index be5dcbb48..64d754663 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -796,8 +796,7 @@ subtest "photo must be supplied for categories that require it" => sub { body => $division, category => "Graffiti - photo required", email => "graffiti\@example.org", - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => "editor", whenedited => DateTime->now(), note => "note for graffiti", diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index 3ebe8e535..04740a9e8 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -49,8 +49,7 @@ subtest 'check non open311 contacts marked as deleted' => sub { body_id => 1, email => 'contact@example.com', category => 'An old category', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -66,7 +65,7 @@ subtest 'check non open311 contacts marked as deleted' => sub { my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count(); is $contact_count, 4, 'correct number of contacts'; - $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1, deleted => 1 } )->count(); + $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1, state => 'deleted' } )->count(); is $contact_count, 1, 'correct number of deleted contacts'; }; @@ -78,8 +77,7 @@ subtest 'check email changed if matching category' => sub { body_id => 1, email => '009', category => 'Cans left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -96,8 +94,7 @@ subtest 'check email changed if matching category' => sub { $contact->discard_changes; is $contact->email, '001', 'email unchanged'; - is $contact->confirmed, 1, 'contact still confirmed'; - is $contact->deleted, 0, 'contact still not deleted'; + is $contact->state, 'confirmed', 'contact still confirmed'; my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count(); is $contact_count, 3, 'correct number of contacts'; @@ -111,8 +108,7 @@ subtest 'check category name changed if updated' => sub { body_id => 1, email => '001', category => 'Bins left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -130,8 +126,7 @@ subtest 'check category name changed if updated' => sub { $contact->discard_changes; is $contact->email, '001', 'email unchanged'; is $contact->category, 'Cans left out 24x7', 'category changed'; - is $contact->confirmed, 1, 'contact still confirmed'; - is $contact->deleted, 0, 'contact still not deleted'; + is $contact->state, 'confirmed', 'contact still confirmed'; my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count(); is $contact_count, 3, 'correct number of contacts'; @@ -145,8 +140,7 @@ subtest 'check conflicting contacts not changed' => sub { body_id => 1, email => 'existing@example.com', category => 'Cans left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -160,8 +154,7 @@ subtest 'check conflicting contacts not changed' => sub { body_id => 1, email => '001', category => 'Bins left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -179,14 +172,12 @@ subtest 'check conflicting contacts not changed' => sub { $contact->discard_changes; is $contact->email, 'existing@example.com', 'first contact email unchanged'; is $contact->category, 'Cans left out 24x7', 'first contact category unchanged'; - is $contact->confirmed, 1, 'first contact contact still confirmed'; - is $contact->deleted, 0, 'first contact contact still not deleted'; + is $contact->state, 'confirmed', 'first contact still confirmed'; $contact2->discard_changes; is $contact2->email, '001', 'second contact email unchanged'; is $contact2->category, 'Bins left out 24x7', 'second contact category unchanged'; - is $contact2->confirmed, 1, 'second contact contact still confirmed'; - is $contact2->deleted, 0, 'second contact contact still not deleted'; + is $contact2->state, 'confirmed', 'second contact still confirmed'; my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count(); is $contact_count, 4, 'correct number of contacts'; @@ -217,8 +208,7 @@ subtest 'check meta data population' => sub { body_id => 1, email => '001', category => 'Bins left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -397,8 +387,7 @@ for my $test ( body_id => 1, email => '100', category => 'Cans left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -471,8 +460,7 @@ subtest 'check attribute ordering' => sub { body_id => 1, email => '001', category => 'Bins left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', @@ -573,8 +561,7 @@ subtest 'check bromely skip code' => sub { body_id => 1, email => '001', category => 'Bins left out 24x7', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'test contact', |