aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand/zurich.t
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2013-12-06 17:26:00 +0000
committerHakim Cassimally <hakim@mysociety.org>2013-12-09 16:52:35 +0000
commit8283029eea61f5e5bf915487d3950a7e849b1596 (patch)
tree8d14eaf53e302e24155ca0523dac7530ee9b41c1 /t/cobrand/zurich.t
parent6c9d3d59502b2d5cc90799474b1d9ab87866a8f7 (diff)
[Zurich] test /admin/stats
First test that this page is only available to superuser. Then test that the moderated and fixed stats are doing something that is (hopefully) the spec in mysociety/FixMyStreet-Commercial#459
Diffstat (limited to 't/cobrand/zurich.t')
-rw-r--r--t/cobrand/zurich.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index a77363621..0cb4e36cf 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -405,6 +405,29 @@ like $email->body, qr/test\@example.com/, 'body does contain email address';
$mech->clear_emails_ok;
$mech->log_out_ok;
+subtest "only superuser can see stats" => sub {
+ $user = $mech->log_in_ok( 'super@example.org' );
+ # a user from body $zurich is a superuser, as $zurich has no parent id!
+ $user->update({ from_body => $zurich->id });
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->get( '/admin/stats' );
+ };
+ is $mech->res->code, 200, "superuser should be able to see stats page";
+ $mech->log_out_ok;
+
+ $user = $mech->log_in_ok( 'dm1@example.org' );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->get( '/admin/stats' );
+ };
+ is $mech->res->code, 404, "only superuser should be able to see stats page";
+ $mech->log_out_ok;
+};
+
subtest "only superuser can edit bodies" => sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
FixMyStreet::override_config {
@@ -509,6 +532,22 @@ subtest "hidden report email are only sent when requested" => sub {
};
};
+subtest "test stats" => sub {
+ $user = $mech->log_in_ok( 'super@example.org' );
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->get( '/admin/stats' );
+ };
+ is $mech->res->code, 200, "superuser should be able to see stats page";
+
+ $mech->content_contains('Innerhalb eines Arbeitstages moderiert: 1');
+ $mech->content_contains('Innerhalb von f&uuml;nf Arbeitstagen abgeschlossen: 1');
+
+ $mech->log_out_ok;
+};
+
$mech->delete_problems_for_body( 2 );
$mech->delete_user( 'dm1@example.org' );
$mech->delete_user( 'sdm1@example.org' );