aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/app/controller/admin.t1
-rw-r--r--t/app/controller/report_as_other.t1
-rw-r--r--t/app/controller/report_display.t57
3 files changed, 55 insertions, 4 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 1ab0cb488..ab6cac842 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -1190,6 +1190,7 @@ my %default_perms = (
"permissions[report_instruct]" => undef,
"permissions[contribute_as_another_user]" => undef,
"permissions[contribute_as_body]" => undef,
+ "permissions[view_body_contribute_details]" => undef,
"permissions[user_edit]" => undef,
"permissions[user_manage_permissions]" => undef,
"permissions[user_assign_body]" => undef,
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index 505a1bf6b..b4405be57 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -191,4 +191,3 @@ sub dropdown_shown {
my ($shown, $name) = @_;
is grep({ $_ eq 'form_as' } keys %{$mech->visible_form_values($name)}), $shown, "Dropdown shown = $shown";
}
-
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index fad8b2bbb..b35a4a026 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -210,13 +210,13 @@ foreach my $meta (
$report->update;
subtest "test correct problem meta information" => sub {
$mech->get_ok("/report/$report_id");
-
+
is $mech->extract_problem_meta, $meta->{meta};
};
}
-for my $test (
+for my $test (
{
description => 'new report',
date => DateTime->now,
@@ -385,7 +385,7 @@ for my $test (
my $body_westminster = $mech->create_body_ok(2504, 'Westminster City Council');
my $body_camden = $mech->create_body_ok(2505, 'Camden Borough Council');
-for my $test (
+for my $test (
{
desc => 'no state dropdown if user not from authority',
from_body => undef,
@@ -530,6 +530,57 @@ subtest "Zurich banners are displayed correctly" => sub {
};
};
+my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237);
+my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxfordshire);
+
+subtest "check user details show when a user has correct permissions" => sub {
+ $report->update( {
+ name => 'Oxfordshire County Council',
+ user_id => $oxfordshireuser->id,
+ service => '',
+ anonymous => 'f',
+ bodies_str => $oxfordshire->id,
+ confirmed => '2012-01-10 15:17:00'
+ });
+
+ ok $oxfordshireuser->user_body_permissions->create({
+ body => $oxfordshire,
+ permission_type => 'view_body_contribute_details',
+ });
+
+ $mech->log_in_ok( $oxfordshireuser->email );
+ ok $mech->get("/report/$report_id"), "get '/report/$report_id'";
+ is $mech->extract_problem_meta,
+ 'Reported in the Roads category by Oxfordshire County Council (Council User) at 15:17, Tue 10 January 2012',
+ 'correct problem meta information';
+
+ ok $oxfordshireuser->user_body_permissions->delete_all, "Remove view_body_contribute_details permissions";
+
+ ok $mech->get("/report/$report_id"), "get '/report/$report_id'";
+ is $mech->extract_problem_meta,
+ 'Reported in the Roads category by Oxfordshire County Council at 15:17, Tue 10 January 2012',
+ 'correct problem meta information for user without relevant permissions';
+
+ $mech->log_out_ok;
+
+ ok $mech->get("/report/$report_id"), "get '/report/$report_id'";
+ is $mech->extract_problem_meta,
+ 'Reported in the Roads category by Oxfordshire County Council at 15:17, Tue 10 January 2012',
+ 'correct problem meta information for logged out user';
+
+};
+
+subtest "check brackets don't appear when username and report name are the same" => sub {
+ $report->update( {
+ name => 'Council User'
+ });
+
+ $mech->log_in_ok( $oxfordshireuser->email );
+ ok $mech->get("/report/$report_id"), "get '/report/$report_id'";
+ is $mech->extract_problem_meta,
+ 'Reported in the Roads category by Council User at 15:17, Tue 10 January 2012',
+ 'correct problem meta information';
+};
END {
$mech->delete_user('test@example.com');