aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-07-14 16:25:31 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-07-14 16:25:31 +0100
commit8c3f0fbfb4bcd33fa8dbc93c2ecb8e0f25ebf383 (patch)
tree0b596b32bc9248d10e6f4409e39d3285e957d40a /t/app
parent298db521933eb65591fafa218e78f5f4cdb547ad (diff)
parent426bc926a422af21ff39cebed836d34e46238500 (diff)
Merge branch 'issues/forcouncils/192-unused-categories'
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/admin.t18
-rw-r--r--t/app/controller/dashboard.t3
-rw-r--r--t/app/controller/report_new.t26
-rw-r--r--t/app/controller/reports.t2
-rw-r--r--t/app/model/extra.t3
-rw-r--r--t/app/model/problem.t2
-rw-r--r--t/app/sendreport/email.t2
-rw-r--r--t/app/sendreport/open311.t3
8 files changed, 40 insertions, 19 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:&nbsp;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:&nbsp;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:&nbsp;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:&nbsp;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:&nbsp;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,