aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/admin/users.t43
-rw-r--r--t/app/controller/report_import.t2
-rw-r--r--t/app/controller/report_new_open311.t2
3 files changed, 45 insertions, 2 deletions
diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t
index ce29a5f7c..b6da170ba 100644
--- a/t/app/controller/admin/users.t
+++ b/t/app/controller/admin/users.t
@@ -3,6 +3,8 @@ use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
my $user = $mech->create_user_ok('test@example.com', name => 'Test User');
+my $user2 = $mech->create_user_ok('test2@example.com', name => 'Test User 2');
+my $user3 = $mech->create_user_ok('test3@example.com', name => 'Test User 3');
my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1);
@@ -120,6 +122,47 @@ subtest 'user_edit does not show user from another council' => sub {
};
};
+$mech->log_out_ok;
+
+subtest 'user_edit redirects appropriately' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $user2->update({ from_body => $oxfordshire->id });
+ $user3->update({ from_body => $oxfordshire->id });
+ $user3->user_body_permissions->create( {
+ body => $oxfordshire,
+ permission_type => 'user_edit',
+ } );
+ $user3->user_body_permissions->create( {
+ body => $oxfordshire,
+ permission_type => 'user_assign_body',
+ } );
+ $mech->log_in_ok( $user3->email );
+
+ $mech->get_ok('/admin/users/' . $user2->id);
+ $mech->submit_form_ok( { with_fields => {
+ name => "Updated Name"
+ } } );
+ $user2->discard_changes;
+ is $user2->name, "Updated Name", "Name set correctly";
+ is $mech->uri->path, '/admin/users/' . $user2->id, 'redirected back to user form';
+
+ $mech->get_ok('/admin/users/' . $user2->id);
+ $mech->submit_form_ok( { with_fields => {
+ body => undef
+ } } );
+ $user2->discard_changes;
+ is $user2->from_body, undef, "from_body unset";
+ is $mech->uri->path, '/admin/users', 'redirected back to users list';
+
+ $mech->log_out_ok;
+ };
+};
+
+$mech->log_in_ok( $superuser->email );
+
for my $test (
{
desc => 'add user - blank form',
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t
index 223979d1b..eb3a54963 100644
--- a/t/app/controller/report_import.t
+++ b/t/app/controller/report_import.t
@@ -17,7 +17,7 @@ ok -e $sample_file, "sample file $sample_file exists";
FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }
-my $body = $mech->create_body_ok(2245, 'Wiltshire Council');
+my $body = $mech->create_body_ok(2608, 'Borsetshire Council');
$mech->create_contact_ok(
body_id => $body->id,
category => 'Street lighting',
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index d2f39f40f..3b733622b 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -9,7 +9,7 @@ END { FixMyStreet::App->log->enable('info'); }
my $mech = FixMyStreet::TestMech->new;
-my $body = $mech->create_body_ok(2245, 'Wiltshire Council');
+my $body = $mech->create_body_ok(2608, 'Borsetshire Council');
$body->update({
endpoint => 'http://example.com/open311',
jurisdiction => 'mySociety',