diff options
Diffstat (limited to 't')
-rw-r--r-- | t/Mock/MapIt.pm | 4 | ||||
-rw-r--r-- | t/app/controller/admin/users.t | 43 | ||||
-rw-r--r-- | t/app/controller/report_import.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_new_open311.t | 2 |
4 files changed, 47 insertions, 4 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 337b4049f..b5cc694df 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -96,8 +96,8 @@ sub dispatch_request { } } my $response = { - "63999" => {"parent_area" => 2245, "generation_high" => 25, "all_names" => {}, "id" => 63999, "codes" => {"ons" => "00HYNS", "gss" => "E05008366", "unit_id" => "44025"}, "name" => "Kington", "country" => "E", "type_name" => "Unitary Authority electoral division (UTE)", "generation_low" => 12, "country_name" => "England", "type" => "UTE"}, - "2245" => {"parent_area" => undef, "generation_high" => 25, "all_names" => {}, "id" => 2245, "codes" => {"ons" => "00HY", "gss" => "E06000054", "unit_id" => "43925"}, "name" => "Wiltshire Council", "country" => "E", "type_name" => "Unitary Authority", "generation_low" => 11, "country_name" => "England", "type" => "UTA"} + "153255" => {"parent_area" => 2608, "generation_high" => 36, "all_names" => {}, "id" => 153255, "codes" => {"gss" => "E05012110", "unit_id" => "174450"}, "name" => "Chipping Sodbury & Cotswold Edge", "country" => "E", "type_name" => "Unitary Authority ward (UTW)", "generation_low" => 36, "country_name" => "England", "type" => "UTW"}, + "2608" => {"parent_area" => undef, "generation_high" => 36, "all_names" => {}, "id" => 2608, "codes" => {"ons" => "00HD", "gss" => "E06000025", "unit_id" => "25559"}, "name" => "South Gloucestershire Council", "country" => "E", "type_name" => "Unitary Authority", "generation_low" => 1, "country_name" => "England", "type" => "UTA"} }; return $self->output($response); }, 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', |